Isis 3 Programmer Reference
SparseBlockMatrix.h
Go to the documentation of this file.
1 #ifndef SparseBlockMatrix_h
2 #define SparseBlockMatrix_h
3 
23 // std library
24 #include <iostream>
25 
26 // Qt library
27 #include <QMap>
28 #include <QList>
29 
30 // boost library
31 #include <boost/numeric/ublas/fwd.hpp>
32 
33 // Isis library
34 #include "LinearAlgebra.h"
35 
36 // Qt library
37 class QDebug;
38 
39 namespace Isis {
40 
70  public QMap< int, LinearAlgebra::Matrix * > {
71 
72  public:
73  SparseBlockColumnMatrix(); // default constructor
74  ~SparseBlockColumnMatrix(); // destructor
75 
76  // copy constructor
78 
80 
81  void wipe();
82  void copy(const SparseBlockColumnMatrix& src);
83 
84  void zeroBlocks();
85  bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols);
86 
87  void setStartColumn(int nStartColumn);
88  int startColumn() const;
89  int numberOfElements();
90  int numberOfRows();
91  int numberOfColumns();
92  void print(std::ostream& outstream);
93  void printClean(std::ostream& outstream);
94 
95  protected:
99  };
100 
101  // operators to read/write SparseBlockColumnMatrix to/from binary disk file
102  QDataStream &operator<<(QDataStream &, const SparseBlockColumnMatrix &);
103  QDataStream &operator>>(QDataStream &, SparseBlockColumnMatrix &);
104 
105  // operator to write SparseBlockColumnMatrix to QDebug stream
106  QDebug operator<<(QDebug dbg, const SparseBlockColumnMatrix &sbcm);
107 
108 
137  public QMap< int, LinearAlgebra::Matrix * > {
138 
139  public:
140  SparseBlockRowMatrix(){} // default constructor
142 
143  // copy constructor
145 
147 
148 
149  void wipe();
150  void copy(const SparseBlockRowMatrix& src);
151 
152  void zeroBlocks();
153  bool insertMatrixBlock(int nRowBlock, int nRows, int nCols);
154  void copyToBoost(boost::numeric::ublas::compressed_matrix<double>& B);
155  int getLeadingColumnsForBlock(int nblockColumn);
156  int numberOfElements();
157  void print(std::ostream& outstream);
158  void printClean(std::ostream& outstream);
159  };
160 
161  // operators to read/write SparseBlockRowMatrix to/from binary disk file
162  QDataStream &operator<<(QDataStream &, const SparseBlockRowMatrix &);
163  QDataStream &operator>>(QDataStream &, SparseBlockRowMatrix &);
164 
165  // operator to write SparseBlockRowMatrix to QDebug stream
166  QDebug operator<<(QDebug dbg, const SparseBlockRowMatrix &sbcm);
167 
198  class SparseBlockMatrix : public QList< SparseBlockColumnMatrix* > {
199 
200  public:
201  SparseBlockMatrix() {} // default constructor
203 
204  // copy constructor
206 
208 
209  void wipe();
210  void copy(const SparseBlockMatrix& src);
211 
212  bool setNumberOfColumns( int n );
213  void zeroBlocks();
214  bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols);
215  LinearAlgebra::Matrix *getBlock(int column, int row);
216  int numberOfBlocks();
219  int numberOfElements();
220  void print(std::ostream& outstream);
221  void printClean(std::ostream& outstream);
222  bool write(std::ofstream &fp_out, bool binary=true);
223  int getLeadingColumnsForBlock(int nblockColumn);
224  int getLeadingRowsForBlock(int nblockRow);
225  };
226 
227  // operators to read/write SparseBlockMatrix to/from binary disk file
228  QDataStream &operator<<(QDataStream &, const SparseBlockMatrix &);
229  QDataStream &operator>>(QDataStream &, SparseBlockMatrix &);
230 
231  // operator to write SparseBlockMatrix to QDebug stream
232  QDebug operator<<(QDebug dbg, const SparseBlockMatrix &m);
233 }
234 
235 #endif
bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols)
Inserts a "newed" boost LinearAlgebra::Matrix pointer of size (nRows, nCols) into the matrix at nColu...
void copy(const SparseBlockRowMatrix &src)
Copy method.
SparseBlockMatrix.
void setStartColumn(int nStartColumn)
Sets starting column for block in full matrix.
SparseBlockColumnMatrix.
void wipe()
Deletes all pointer elements and removes them from the map.
SparseBlockRowMatrix & operator=(const SparseBlockRowMatrix &src)
"Equals" operator.
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
SparseBlockColumnMatrix & operator=(const SparseBlockColumnMatrix &src)
"Equals" operator.
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.
int m_startColumn
starting column for this Block Column in full matrix e.g.
int getLeadingRowsForBlock(int nblockRow)
Sums and returns the number of rows in each matrix block prior to nblockRow.
void wipe()
Deletes all pointer elements and removes them from the map.
int numberOfElements()
Returns number of matrix elements in matrix.
int numberOfRows()
Returns total number of rows in map (this needs to be clarified and maybe rewritten).
bool insertMatrixBlock(int nRowBlock, int nRows, int nCols)
Inserts a "newed" LinearAlgebra::Matrix pointer of size (nRows, nCols) into the map with the block ro...
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
void wipe()
Deletes all pointer elements and removes them from the list.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
int numberOfColumns()
Returns total number of columns in map (NOTE: NOT the number of matrix blocks).
int numberOfOffDiagonalBlocks()
Returns number of off-diagonal matrix blocks.
LinearAlgebra::Matrix * getBlock(int column, int row)
Returns pointer to boost matrix at position (column, row).
void copyToBoost(boost::numeric::ublas::compressed_matrix< double > &B)
Copies a SparseBlockRowMatrix to a Boost compressed_matrix.
int numberOfDiagonalBlocks()
Returns number of diagonal matrix blocks (equivalent to size - there is one per column).
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
SparseBlockColumnMatrix()
Default constructor.
bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols)
Inserts a "newed" LinearAlgebra::Matrix pointer of size (nRows, nCols) into the map with the block co...
void copy(const SparseBlockColumnMatrix &src)
Copy method.
bool setNumberOfColumns(int n)
Initializes number of columns (SparseBlockColumnMatrix).
int numberOfBlocks()
Returns total number of blocks in matrix.
int startColumn() const
Sets starting column for block in full matrix.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
SparseBlockMatrix & operator=(const SparseBlockMatrix &src)
"Equals" operator.
SparseBlockRowMatrix.
void copy(const SparseBlockMatrix &src)
Copy method.
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.