JWS-112 Bumping version of ClustalO (src, binaries and windows) to version 1.2.4.
[jabaws.git] / binaries / src / clustalo / src / clustal / symmatrix.h
1 /*********************************************************************
2  * Clustal Omega - Multiple sequence alignment
3  *
4  * Copyright (C) 2010 University College Dublin
5  *
6  * Clustal-Omega is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This file is part of Clustal-Omega.
12  *
13  ********************************************************************/
14
15 /*
16  *  RCS $Id: symmatrix.h 288 2013-07-29 13:15:50Z andreas $
17  */
18
19 /**
20  * Functions for symmetric (square) matrices including diagonal.
21  *
22  * Supports the notion of non-square sub-matrices of a symmetric
23  * matrix, i.e. where |rows|<|cols| and the corresponding full matrix
24  * would be |cols|x|cols|
25  *
26  * Instead of making this one big chunk of memory we keep pointers to
27  * pointers, so that we can easily realloc (the project where this file
28  * originated from needed this for growing a "seed" matrix).
29  *
30  * FIXME Allocating one big chunk of memory is probably
31  * much faster and also easier to maintain.
32  * 
33  * 
34  */
35
36 #ifndef CLUSTALO_SYMMATRIX_H
37 #define CLUSTALO_SYMMATRIX_H
38
39 /* ugly, but necessary for cross-checking of names in distmat and
40  * mseq */
41 #include "seq.h"
42
43
44
45 /**
46  * @brief symmetric matrix structure
47  */
48 typedef struct {
49     int nrows; /**< number of rows */
50     int ncols; /**< number of columns */
51     /**
52      * stored data
53      *
54      * @note indices range: [i][j-i] i<=j. use getvalue() and
55      * setvalue() instead of accessing directly
56      *
57      * @see SymMatrixGetValue(), SymMatrixSetValue()
58      */
59     double **data; 
60 } symmatrix_t;
61
62
63
64 extern int
65 NewSymMatrix(symmatrix_t **symmat, const int nrows, const int ncols);
66
67 extern void
68 SymMatrixSetValue(symmatrix_t *symmat, const int i, const int j, const double value);
69
70 extern double
71 SymMatrixGetValue(symmatrix_t *symmat, const int i, const int j);
72
73 extern void
74 SymMatrixGetValueP(double **value, symmatrix_t *symmat, const int i, const int j);
75
76 extern void
77 FreeSymMatrix(symmatrix_t **symmat);
78
79 extern void
80 SymMatrixPrint(symmatrix_t *symmat, char **labels,  const char *path, bool bPercID);
81
82 extern int
83 SymMatrixRead(char *pcFileIn, symmatrix_t **prSymMat_p, mseq_t *prMSeq);
84
85 #endif