1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
//////////////////////////////////////////////////////////////////////
// ScoreMatrix.h
//
// Matrix storage class for storing a set of two-dimensional arrays.
//////////////////////////////////////////////////////////////////////
#ifndef SCOREMATRIX_H
#define SCOREMATRIX_H
#include <stdio.h>
#include "Score.h"
#include "Sequence.h"
//////////////////////////////////////////////////////////////////////
// ScoreMatrix object
//////////////////////////////////////////////////////////////////////
class ScoreMatrix {
friend class Matrix;
int layers;
int rows;
int cols;
SCORE *data;
// printing utility function
void PrintVal (FILE *file, const SCORE &value) const;
public:
// constructors and destructor
ScoreMatrix (int layers, int rows, int cols);
ScoreMatrix (const ScoreMatrix &m);
~ScoreMatrix ();
// fill all entries with value
void Fill (const SCORE &value);
// printing functions
void PrintLayer (FILE *file, int layer) const;
void Print (FILE *file) const;
void PrintSumRange(FILE *file, int beginy, int endy, int beginx, int endx);
//////////////////////////////////////////////////////////////////////
// Access matrix element
//////////////////////////////////////////////////////////////////////
SCORE &operator() (int layer, int row, int col){
/* ASSERT (0 <= layer && layer < layers, "Requested layer out-of-bounds.");
ASSERT (0 <= row && row < rows, "Requested row out-of-bounds.");
ASSERT (0 <= col && col < cols, "Requested column out-of-bounds.");*/
return data[(row * cols + col) * layers + layer];
}
//////////////////////////////////////////////////////////////////////
// Access matrix element (const version)
//////////////////////////////////////////////////////////////////////
const SCORE &operator() (int layer, int row, int col) const {
/*ASSERT (0 <= layer && layer < layers, "Requested layer out-of-bounds.");
ASSERT (0 <= row && row < rows, "Requested row out-of-bounds.");
ASSERT (0 <= col && col < cols, "Requested column out-of-bounds.");*/
return data[(row * cols + col) * layers + layer];
}
//////////////////////////////////////////////////////////////////////
// Access matrix element
//////////////////////////////////////////////////////////////////////
SCORE *GetPtr (int layer, int row, int col){
return data + (row * cols + col) * layers + layer;
}
//////////////////////////////////////////////////////////////////////
// Access matrix element (const version)
//////////////////////////////////////////////////////////////////////
const SCORE *GetPtr (int layer, int row, int col) const {
return data + (row * cols + col) * layers + layer;
}
//////////////////////////////////////////////////////////////////////
// Return number of matrix layers
//////////////////////////////////////////////////////////////////////
const int GetNumLayers() const {
return layers;
}
//////////////////////////////////////////////////////////////////////
// Return number of matrix rows
//////////////////////////////////////////////////////////////////////
const int GetNumRows() const {
return rows;
}
//////////////////////////////////////////////////////////////////////
// Return number of matrix columns
//////////////////////////////////////////////////////////////////////
const int GetNumCols() const {
return cols;
}
};
#endif
|