Isis 3.0 Programmer Reference
Back | Home
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 
67  public QMap< int, LinearAlgebra::Matrix * > {
68 
69  public:
70  SparseBlockColumnMatrix(){} // default constructor
71  ~SparseBlockColumnMatrix(); // destructor
72 
73  // copy constructor
75 
77 
78  void wipe();
79  void copy(const SparseBlockColumnMatrix& src);
80 
81  void zeroBlocks();
82  bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols);
83  int numberOfElements();
84  int numberOfRows();
85  int numberOfColumns();
86  void print(std::ostream& outstream);
87  void printClean(std::ostream& outstream);
88  };
89 
90  // operators to read/write SparseBlockColumnMatrix to/from binary disk file
91  QDataStream &operator<<(QDataStream &, const SparseBlockColumnMatrix &);
92  QDataStream &operator>>(QDataStream &, SparseBlockColumnMatrix &);
93 
94  // operator to write SparseBlockColumnMatrix to QDebug stream
95  QDebug operator<<(QDebug dbg, const SparseBlockColumnMatrix &sbcm);
96 
97 
126  public QMap< int, LinearAlgebra::Matrix * > {
127 
128  public:
129  SparseBlockRowMatrix(){} // default constructor
131 
132  // copy constructor
134 
136 
137 
138  void wipe();
139  void copy(const SparseBlockRowMatrix& src);
140 
141  void zeroBlocks();
142  bool insertMatrixBlock(int nRowBlock, int nRows, int nCols);
143  void copyToBoost(boost::numeric::ublas::compressed_matrix<double>& B);
144  int getLeadingColumnsForBlock(int nblockColumn);
145  int numberOfElements();
146  void print(std::ostream& outstream);
147  void printClean(std::ostream& outstream);
148  };
149 
150  // operators to read/write SparseBlockRowMatrix to/from binary disk file
151  QDataStream &operator<<(QDataStream &, const SparseBlockRowMatrix &);
152  QDataStream &operator>>(QDataStream &, SparseBlockRowMatrix &);
153 
154  // operator to write SparseBlockRowMatrix to QDebug stream
155  QDebug operator<<(QDebug dbg, const SparseBlockRowMatrix &sbcm);
156 
187  class SparseBlockMatrix : public QList< SparseBlockColumnMatrix* > {
188 
189  public:
190  SparseBlockMatrix() {} // default constructor
192 
193  // copy constructor
195 
197 
198  void wipe();
199  void copy(const SparseBlockMatrix& src);
200 
201  bool setNumberOfColumns( int n );
202  void zeroBlocks();
203  bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols);
204  LinearAlgebra::Matrix *getBlock(int column, int row);
205  int numberOfBlocks();
208  int numberOfElements();
209  void print(std::ostream& outstream);
210  void printClean(std::ostream& outstream);
211  bool write(std::ofstream &fp_out, bool binary=true);
212  int getLeadingColumnsForBlock(int nblockColumn);
213  int getLeadingRowsForBlock(int nblockRow);
214  };
215 
216  // operators to read/write SparseBlockMatrix to/from binary disk file
217  QDataStream &operator<<(QDataStream &, const SparseBlockMatrix &);
218  QDataStream &operator>>(QDataStream &, SparseBlockMatrix &);
219 
220  // operator to write SparseBlockMatrix to QDebug stream
221  QDebug operator<<(QDebug dbg, const SparseBlockMatrix &m);
222 }
223 
224 #endif
bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols)
Inserts a &quot;newed&quot; boost LinearAlgebra::Matrix pointer of size (nRows, nCols) into the matrix at nColu...
void copy(const SparseBlockRowMatrix &src)
Copy method.
SparseBlockMatrix.
SparseBlockColumnMatrix.
void wipe()
Deletes all pointer elements and removes them from the map.
SparseBlockRowMatrix & operator=(const SparseBlockRowMatrix &src)
&quot;Equals&quot; 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)
&quot;Equals&quot; 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 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 &quot;newed&quot; 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.
bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols)
Inserts a &quot;newed&quot; 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.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
SparseBlockMatrix & operator=(const SparseBlockMatrix &src)
&quot;Equals&quot; 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.

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:29:24