Isis 3 Programmer Reference
SparseBlockMatrix.h
1#ifndef SparseBlockMatrix_h
2#define SparseBlockMatrix_h
3
9/* SPDX-License-Identifier: CC0-1.0 */
10
11// std library
12#include <iostream>
13
14// Qt library
15#include <QMap>
16#include <QList>
17
18// boost library
19#include <boost/numeric/ublas/fwd.hpp>
20
21// Isis library
22#include "LinearAlgebra.h"
23
24// Qt library
25class QDebug;
26
27namespace Isis {
28
58 public QMap< int, LinearAlgebra::Matrix * > {
59
60 public:
61 SparseBlockColumnMatrix(); // default constructor
62 ~SparseBlockColumnMatrix(); // destructor
63
64 // copy constructor
66
68
69 void wipe();
70 void copy(const SparseBlockColumnMatrix& src);
71
72 void zeroBlocks();
73 bool insertMatrixBlock(int nColumnBlock, int nRows, int nCols);
74
75 void setStartColumn(int nStartColumn);
76 int startColumn() const;
77 int numberOfElements();
78 int numberOfRows();
79 int numberOfColumns();
80 void print(std::ostream& outstream);
81 void printClean(std::ostream& outstream);
82
83 protected:
87 };
88
89 // operators to read/write SparseBlockColumnMatrix to/from binary disk file
90 QDataStream &operator<<(QDataStream &, const SparseBlockColumnMatrix &);
91 QDataStream &operator>>(QDataStream &, SparseBlockColumnMatrix &);
92
93 // operator to write SparseBlockColumnMatrix to QDebug stream
94 QDebug operator<<(QDebug dbg, const SparseBlockColumnMatrix &sbcm);
95
96
125 public QMap< int, LinearAlgebra::Matrix * > {
126
127 public:
128 SparseBlockRowMatrix(){} // default constructor
130
131 // copy constructor
133
135
136
137 void wipe();
138 void copy(const SparseBlockRowMatrix& src);
139
140 void zeroBlocks();
141 bool insertMatrixBlock(int nRowBlock, int nRows, int nCols);
142 void copyToBoost(boost::numeric::ublas::compressed_matrix<double>& B);
143 int getLeadingColumnsForBlock(int nblockColumn);
144 int numberOfElements();
145 void print(std::ostream& outstream);
146 void printClean(std::ostream& outstream);
147 };
148
149 // operators to read/write SparseBlockRowMatrix to/from binary disk file
150 QDataStream &operator<<(QDataStream &, const SparseBlockRowMatrix &);
151 QDataStream &operator>>(QDataStream &, SparseBlockRowMatrix &);
152
153 // operator to write SparseBlockRowMatrix to QDebug stream
154 QDebug operator<<(QDebug dbg, const SparseBlockRowMatrix &sbcm);
155
186 class SparseBlockMatrix : public QList< SparseBlockColumnMatrix* > {
187
188 public:
189 SparseBlockMatrix() {} // default constructor
191
192 // copy constructor
194
196
197 void wipe();
198 void copy(const SparseBlockMatrix& src);
199
200 bool setNumberOfColumns( int n );
201 void zeroBlocks();
202 bool insertMatrixBlock(int nColumnBlock, int nRowBlock, int nRows, int nCols);
203 LinearAlgebra::Matrix *getBlock(int column, int row);
204 int numberOfBlocks();
207 int numberOfElements();
208 void print(std::ostream& outstream);
209 void printClean(std::ostream& outstream);
210 bool write(std::ofstream &fp_out, bool binary=true);
211 int getLeadingColumnsForBlock(int nblockColumn);
212 int getLeadingRowsForBlock(int nblockRow);
213 };
214
215 // operators to read/write SparseBlockMatrix to/from binary disk file
216 QDataStream &operator<<(QDataStream &, const SparseBlockMatrix &);
217 QDataStream &operator>>(QDataStream &, SparseBlockMatrix &);
218
219 // operator to write SparseBlockMatrix to QDebug stream
220 QDebug operator<<(QDebug dbg, const SparseBlockMatrix &m);
221}
222
223#endif
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
SparseBlockColumnMatrix.
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
void wipe()
Deletes all pointer elements and removes them from the map.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
int startColumn() const
Sets starting column for block in full matrix.
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
SparseBlockColumnMatrix & operator=(const SparseBlockColumnMatrix &src)
"Equals" operator.
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
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...
int numberOfColumns()
Returns total number of columns in map (NOTE: NOT the number of matrix blocks).
int numberOfRows()
Returns total number of rows in map (this needs to be clarified and maybe rewritten).
int m_startColumn
starting column for this Block Column in full matrix e.g.
SparseBlockColumnMatrix()
Default constructor.
void copy(const SparseBlockColumnMatrix &src)
Copy method.
void setStartColumn(int nStartColumn)
Sets starting column for block in full matrix.
void copy(const SparseBlockMatrix &src)
Copy method.
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
int numberOfBlocks()
Returns total number of blocks in matrix.
int numberOfDiagonalBlocks()
Returns number of diagonal matrix blocks (equivalent to size - there is one per column).
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 list.
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...
int numberOfOffDiagonalBlocks()
Returns number of off-diagonal matrix blocks.
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
SparseBlockMatrix & operator=(const SparseBlockMatrix &src)
"Equals" operator.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
LinearAlgebra::Matrix * getBlock(int column, int row)
Returns pointer to boost matrix at position (column, row).
bool setNumberOfColumns(int n)
Initializes number of columns (SparseBlockColumnMatrix).
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.
int numberOfElements()
Returns number of matrix elements in matrix.
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
void copy(const SparseBlockRowMatrix &src)
Copy method.
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
SparseBlockRowMatrix & operator=(const SparseBlockRowMatrix &src)
"Equals" operator.
void copyToBoost(boost::numeric::ublas::compressed_matrix< double > &B)
Copies a SparseBlockRowMatrix to a Boost compressed_matrix.
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
void wipe()
Deletes all pointer elements and removes them from the map.
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.
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...
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.