Mac binaries
[jabaws.git] / website / archive / binaries / mac / 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 216 2011-03-19 10:11:53Z 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
40 /**
41  * @brief symmetric matrix structure
42  */
43 typedef struct {
44     int nrows; /**< number of rows */
45     int ncols; /**< number of columns */
46     /**
47      * stored data
48      *
49      * @note indices range: [i][j-i] i<=j. use getvalue() and
50      * setvalue() instead of accessing directly
51      *
52      * @see SymMatrixGetValue(), SymMatrixSetValue()
53      */
54     double **data; 
55 } symmatrix_t;
56
57
58
59 extern int
60 NewSymMatrix(symmatrix_t **symmat, const int nrows, const int ncols);
61
62 extern void
63 SymMatrixSetValue(symmatrix_t *symmat, const int i, const int j, const double value);
64
65 extern double
66 SymMatrixGetValue(symmatrix_t *symmat, const int i, const int j);
67
68 extern void
69 SymMatrixGetValueP(double **value, symmatrix_t *symmat, const int i, const int j);
70
71 extern void
72 FreeSymMatrix(symmatrix_t **symmat);
73
74 extern void
75 SymMatrixPrint(symmatrix_t *symmat, char **labels,  const char *path);
76
77 extern int
78 SymMatrixRead(char *pcFileIn, symmatrix_t **prSymMat_p);
79
80 #endif