Isis 3.0 Developer's Reference (API) |
Home |
00001 #ifndef SparseBlockMatrix_h 00002 #define SparseBlockMatrix_h 00003 00024 #include <QMap> 00025 #include <QList> 00026 00027 #include <iostream> 00028 00029 #include <boost/numeric/ublas/fwd.hpp> 00030 00031 class QDebug; 00032 00033 namespace Isis { 00034 00058 class SparseBlockColumnMatrix : 00059 public QMap< int, boost::numeric::ublas::matrix<double>* > { 00060 00061 public: 00062 SparseBlockColumnMatrix(){} // default constructor 00063 ~SparseBlockColumnMatrix(); // destructor 00064 00065 // copy constructor 00066 SparseBlockColumnMatrix(const SparseBlockColumnMatrix& src); 00067 00068 SparseBlockColumnMatrix& operator=(const SparseBlockColumnMatrix& src); 00069 00070 void wipe(); 00071 void copy(const SparseBlockColumnMatrix& src); 00072 00073 void zeroBlocks(); 00074 bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols); 00075 int numberOfElements(); 00076 int numberOfRows(); 00077 int numberOfColumns(); 00078 void print(std::ostream& outstream); 00079 void printClean(std::ostream& outstream); 00080 }; 00081 00082 // operators to read/write SparseBlockColumnMatrix to/from binary disk file 00083 QDataStream &operator<<(QDataStream &, const SparseBlockColumnMatrix &); 00084 QDataStream &operator>>(QDataStream &, SparseBlockColumnMatrix &); 00085 00086 // operator to write SparseBlockColumnMatrix to QDebug stream 00087 QDebug operator<<(QDebug dbg, const SparseBlockColumnMatrix &sbcm); 00088 00089 00117 class SparseBlockRowMatrix : 00118 public QMap< int, boost::numeric::ublas::matrix<double>* > { 00119 00120 public: 00121 SparseBlockRowMatrix(){} // default constructor 00122 ~SparseBlockRowMatrix(); 00123 00124 // copy constructor 00125 SparseBlockRowMatrix(const SparseBlockRowMatrix& src); 00126 00127 SparseBlockRowMatrix& operator=(const SparseBlockRowMatrix& src); 00128 00129 00130 void wipe(); 00131 void copy(const SparseBlockRowMatrix& src); 00132 00133 void zeroBlocks(); 00134 bool insertMatrixBlock(int nRowBlock, int nRows, int nCols); 00135 void copyToBoost(boost::numeric::ublas::compressed_matrix<double>& B); 00136 int getLeadingColumnsForBlock(int nblockColumn); 00137 int numberOfElements(); 00138 void print(std::ostream& outstream); 00139 void printClean(std::ostream& outstream); 00140 }; 00141 00142 // operators to read/write SparseBlockRowMatrix to/from binary disk file 00143 QDataStream &operator<<(QDataStream &, const SparseBlockRowMatrix &); 00144 QDataStream &operator>>(QDataStream &, SparseBlockRowMatrix &); 00145 00146 // operator to write SparseBlockRowMatrix to QDebug stream 00147 QDebug operator<<(QDebug dbg, const SparseBlockRowMatrix &sbcm); 00148 00179 class SparseBlockMatrix : public QList< SparseBlockColumnMatrix* > { 00180 00181 public: 00182 SparseBlockMatrix() {} // default constructor 00183 ~SparseBlockMatrix(); 00184 00185 // copy constructor 00186 SparseBlockMatrix(const SparseBlockMatrix& src); 00187 00188 SparseBlockMatrix& operator=(const SparseBlockMatrix& src); 00189 00190 void wipe(); 00191 void copy(const SparseBlockMatrix& src); 00192 00193 bool setNumberOfColumns( int n ); 00194 void zeroBlocks(); 00195 bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols); 00196 boost::numeric::ublas::matrix<double>* getBlock(int column, int row); 00197 int numberOfBlocks(); 00198 int numberOfDiagonalBlocks(); 00199 int numberOfOffDiagonalBlocks(); 00200 int numberOfElements(); 00201 void print(std::ostream& outstream); 00202 void printClean(std::ostream& outstream); 00203 bool write(std::ofstream &fp_out, bool binary=true); 00204 int getLeadingColumnsForBlock(int nblockColumn); 00205 int getLeadingRowsForBlock(int nblockRow); 00206 }; 00207 00208 // operators to read/write SparseBlockMatrix to/from binary disk file 00209 QDataStream &operator<<(QDataStream &, const SparseBlockMatrix &); 00210 QDataStream &operator>>(QDataStream &, SparseBlockMatrix &); 00211 00212 // operator to write SparseBlockMatrix to QDebug stream 00213 QDebug operator<<(QDebug dbg, const SparseBlockMatrix &m); 00214 } 00215 00216 #endif