USGS

Isis 3.0 Object Programmers' Reference

Home

SparseBlockMatrix.h
Go to the documentation of this file.
1 #ifndef SparseBlockMatrix_h
2 #define SparseBlockMatrix_h
3 
24 #include <QMap>
25 #include <QList>
26 
27 #include <iostream>
28 
29 #include <boost/numeric/ublas/fwd.hpp>
30 
31 class QDebug;
32 
33 namespace Isis {
34 
59  public QMap< int, boost::numeric::ublas::matrix<double>* > {
60 
61  public:
62  SparseBlockColumnMatrix(){} // default constructor
63  ~SparseBlockColumnMatrix(); // destructor
64 
65  // copy constructor
67 
69 
70  void wipe();
71  void copy(const SparseBlockColumnMatrix& src);
72 
73  void zeroBlocks();
74  bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols);
75  int numberOfElements();
76  int numberOfRows();
77  int numberOfColumns();
78  void print(std::ostream& outstream);
79  void printClean(std::ostream& outstream);
80  };
81 
82  // operators to read/write SparseBlockColumnMatrix to/from binary disk file
83  QDataStream &operator<<(QDataStream &, const SparseBlockColumnMatrix &);
84  QDataStream &operator>>(QDataStream &, SparseBlockColumnMatrix &);
85 
86  // operator to write SparseBlockColumnMatrix to QDebug stream
87  QDebug operator<<(QDebug dbg, const SparseBlockColumnMatrix &sbcm);
88 
89 
118  public QMap< int, boost::numeric::ublas::matrix<double>* > {
119 
120  public:
121  SparseBlockRowMatrix(){} // default constructor
123 
124  // copy constructor
126 
128 
129 
130  void wipe();
131  void copy(const SparseBlockRowMatrix& src);
132 
133  void zeroBlocks();
134  bool insertMatrixBlock(int nRowBlock, int nRows, int nCols);
135  void copyToBoost(boost::numeric::ublas::compressed_matrix<double>& B);
136  int getLeadingColumnsForBlock(int nblockColumn);
137  int numberOfElements();
138  void print(std::ostream& outstream);
139  void printClean(std::ostream& outstream);
140  };
141 
142  // operators to read/write SparseBlockRowMatrix to/from binary disk file
143  QDataStream &operator<<(QDataStream &, const SparseBlockRowMatrix &);
144  QDataStream &operator>>(QDataStream &, SparseBlockRowMatrix &);
145 
146  // operator to write SparseBlockRowMatrix to QDebug stream
147  QDebug operator<<(QDebug dbg, const SparseBlockRowMatrix &sbcm);
148 
179  class SparseBlockMatrix : public QList< SparseBlockColumnMatrix* > {
180 
181  public:
182  SparseBlockMatrix() {} // default constructor
184 
185  // copy constructor
187 
189 
190  void wipe();
191  void copy(const SparseBlockMatrix& src);
192 
193  bool setNumberOfColumns( int n );
194  void zeroBlocks();
195  bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols);
196  boost::numeric::ublas::matrix<double>* getBlock(int column, int row);
197  int numberOfBlocks();
200  int numberOfElements();
201  void print(std::ostream& outstream);
202  void printClean(std::ostream& outstream);
203  bool write(std::ofstream &fp_out, bool binary=true);
204  int getLeadingColumnsForBlock(int nblockColumn);
205  int getLeadingRowsForBlock(int nblockRow);
206  };
207 
208  // operators to read/write SparseBlockMatrix to/from binary disk file
209  QDataStream &operator<<(QDataStream &, const SparseBlockMatrix &);
210  QDataStream &operator>>(QDataStream &, SparseBlockMatrix &);
211 
212  // operator to write SparseBlockMatrix to QDebug stream
213  QDebug operator<<(QDebug dbg, const SparseBlockMatrix &m);
214 }
215 
216 #endif