1 /*********************************************************************
2 * Clustal Omega - Multiple sequence alignment
4 * Copyright (C) 2010 University College Dublin
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.
11 * This file is part of Clustal-Omega.
13 ********************************************************************/
16 * RCS $Id: symmatrix.h 288 2013-07-29 13:15:50Z andreas $
20 * Functions for symmetric (square) matrices including diagonal.
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|
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).
30 * FIXME Allocating one big chunk of memory is probably
31 * much faster and also easier to maintain.
36 #ifndef CLUSTALO_SYMMATRIX_H
37 #define CLUSTALO_SYMMATRIX_H
39 /* ugly, but necessary for cross-checking of names in distmat and
46 * @brief symmetric matrix structure
49 int nrows; /**< number of rows */
50 int ncols; /**< number of columns */
54 * @note indices range: [i][j-i] i<=j. use getvalue() and
55 * setvalue() instead of accessing directly
57 * @see SymMatrixGetValue(), SymMatrixSetValue()
65 NewSymMatrix(symmatrix_t **symmat, const int nrows, const int ncols);
68 SymMatrixSetValue(symmatrix_t *symmat, const int i, const int j, const double value);
71 SymMatrixGetValue(symmatrix_t *symmat, const int i, const int j);
74 SymMatrixGetValueP(double **value, symmatrix_t *symmat, const int i, const int j);
77 FreeSymMatrix(symmatrix_t **symmat);
80 SymMatrixPrint(symmatrix_t *symmat, char **labels, const char *path, bool bPercID);
83 SymMatrixRead(char *pcFileIn, symmatrix_t **prSymMat_p, mseq_t *prMSeq);