Isis Developer Reference
SparseBlockMatrix.h
Go to the documentation of this file.
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.
Definition LinearAlgebra.h:102
SparseBlockColumnMatrix.
Definition SparseBlockMatrix.h:58
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
Definition SparseBlockMatrix.cpp:168
void wipe()
Deletes all pointer elements and removes them from the map.
Definition SparseBlockMatrix.cpp:52
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:266
int startColumn() const
Sets starting column for block in full matrix.
Definition SparseBlockMatrix.cpp:157
~SparseBlockColumnMatrix()
Destructor.
Definition SparseBlockMatrix.cpp:43
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:239
SparseBlockColumnMatrix & operator=(const SparseBlockColumnMatrix &src)
"Equals" operator.
Definition SparseBlockMatrix.cpp:99
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
Definition SparseBlockMatrix.cpp:299
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...
Definition SparseBlockMatrix.cpp:121
int numberOfColumns()
Returns total number of columns in map (NOTE: NOT the number of matrix blocks).
Definition SparseBlockMatrix.cpp:190
int numberOfRows()
Returns total number of rows in map (this needs to be clarified and maybe rewritten).
Definition SparseBlockMatrix.cpp:215
int m_startColumn
starting column for this Block Column in full matrix e.g.
Definition SparseBlockMatrix.h:84
SparseBlockColumnMatrix()
Default constructor.
Definition SparseBlockMatrix.cpp:35
void copy(const SparseBlockColumnMatrix &src)
Copy method.
Definition SparseBlockMatrix.cpp:73
void setStartColumn(int nStartColumn)
Sets starting column for block in full matrix.
Definition SparseBlockMatrix.cpp:147
SparseBlockMatrix.
Definition SparseBlockMatrix.h:186
void copy(const SparseBlockMatrix &src)
Copy method.
Definition SparseBlockMatrix.cpp:839
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
Definition SparseBlockMatrix.cpp:994
int numberOfBlocks()
Returns total number of blocks in matrix.
Definition SparseBlockMatrix.cpp:905
int numberOfDiagonalBlocks()
Returns number of diagonal matrix blocks (equivalent to size - there is one per column).
Definition SparseBlockMatrix.cpp:924
int getLeadingRowsForBlock(int nblockRow)
Sums and returns the number of rows in each matrix block prior to nblockRow.
Definition SparseBlockMatrix.cpp:1088
void wipe()
Deletes all pointer elements and removes them from the list.
Definition SparseBlockMatrix.cpp:818
SparseBlockMatrix()
Definition SparseBlockMatrix.h:189
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...
Definition SparseBlockMatrix.cpp:895
int numberOfOffDiagonalBlocks()
Returns number of off-diagonal matrix blocks.
Definition SparseBlockMatrix.cpp:953
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:1005
SparseBlockMatrix & operator=(const SparseBlockMatrix &src)
"Equals" operator.
Definition SparseBlockMatrix.cpp:855
~SparseBlockMatrix()
Destructor.
Definition SparseBlockMatrix.cpp:809
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:1029
LinearAlgebra::Matrix * getBlock(int column, int row)
Returns pointer to boost matrix at position (column, row).
Definition SparseBlockMatrix.cpp:986
bool setNumberOfColumns(int n)
Initializes number of columns (SparseBlockColumnMatrix).
Definition SparseBlockMatrix.cpp:873
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.
Definition SparseBlockMatrix.cpp:1054
int numberOfElements()
Returns number of matrix elements in matrix.
Definition SparseBlockMatrix.cpp:963
bool write(std::ofstream &fp_out, bool binary=true)
SparseBlockRowMatrix.
Definition SparseBlockMatrix.h:125
int numberOfElements()
Returns total number of matrix elements in map (NOTE: NOT the number of matrix blocks).
Definition SparseBlockMatrix.cpp:530
void print(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:552
SparseBlockRowMatrix()
Definition SparseBlockMatrix.h:128
void copy(const SparseBlockRowMatrix &src)
Copy method.
Definition SparseBlockMatrix.cpp:458
void printClean(std::ostream &outstream)
Prints matrix blocks to std output stream out for debugging.
Definition SparseBlockMatrix.cpp:578
SparseBlockRowMatrix & operator=(const SparseBlockRowMatrix &src)
"Equals" operator.
Definition SparseBlockMatrix.cpp:482
~SparseBlockRowMatrix()
Destructor.
Definition SparseBlockMatrix.cpp:428
void copyToBoost(boost::numeric::ublas::compressed_matrix< double > &B)
Copies a SparseBlockRowMatrix to a Boost compressed_matrix.
Definition SparseBlockMatrix.cpp:626
void zeroBlocks()
Sets all elements of all matrix blocks to zero.
Definition SparseBlockMatrix.cpp:611
void wipe()
Deletes all pointer elements and removes them from the map.
Definition SparseBlockMatrix.cpp:437
int getLeadingColumnsForBlock(int nblockColumn)
Sums and returns the number of columns in each matrix block prior to nblockColumn.
Definition SparseBlockMatrix.cpp:661
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...
Definition SparseBlockMatrix.cpp:507
This is free and unencumbered software released into the public domain.
Definition BoxcarCachingAlgorithm.h:13
This is free and unencumbered software released into the public domain.
Definition CubeIoHandler.h:22
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.
Definition CSVReader.cpp:447
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition Hillshade.cpp:313