CppNoddy
0.92
|
A matrix class that constructs a SPARSE matrix as a row major std::vector of SparseVectors. More...
#include <SparseMatrix.h>
Public Member Functions | |
SparseMatrix (const std::size_t &rows, const std::size_t &cols) | |
Construct with a set number of rows. More... | |
SparseMatrix (const SparseMatrix< _Type > &source, const std::vector< std::size_t > &source_rows) | |
Construct from a row permutation of another sparse matrix. More... | |
SparseMatrix (const SparseMatrix &source) | |
Copy constructor. More... | |
SparseMatrix & | operator= (const SparseMatrix &source) |
Assignment operator. More... | |
~SparseMatrix () | |
Default d-tor. More... | |
void | blank () |
Blank the contents of this matrix. More... | |
const _Type & | operator() (const std::size_t &row, const std::size_t &col) const |
Access operator. More... | |
_Type & | operator() (const std::size_t &row, const std::size_t &col) |
Access operator. More... | |
const _Type & | get (const std::size_t &row, const std::size_t &col) const |
Access operator. More... | |
_Type & | set (const std::size_t &row, const std::size_t &col) |
Access operator. More... | |
SparseVector< _Type > | get_row (const std::size_t &row) const |
Get a row of the matrix. More... | |
void | set_row (const std::size_t &row, const SparseVector< _Type > &row_vector) |
Set a row of the matrix. More... | |
std::size_t | nrows () const |
Get the number of rows in the matrix. More... | |
std::size_t | ncols () const |
Get the number of columns in the matrix. More... | |
std::size_t | nelts () const |
Get the number of (non-zero) elements in the matrix. More... | |
void | scale (const _Type &mult) |
Scale the matrix by a scalar. More... | |
double | one_norm () const |
Transpose the matrix in place. More... | |
double | two_norm () const |
double | inf_norm () const |
double | frob_norm () const |
DenseVector< _Type > | multiply (const DenseVector< _Type > &X) const |
Right-multiply by a DENSE vector. More... | |
void | dump () const |
Output the contents of the matrix to std::cout. More... | |
void | dump (std::string filename, int precision=10) const |
A simple method for dumping the matrix to a file. More... | |
SparseVector< _Type > & | operator[] (const std::size_t &row) |
Operator overloading for ROW access. More... | |
const SparseVector< _Type > & | operator[] (const std::size_t &row) const |
Operator overloading for ROW access. More... | |
std::size_t | nelts_in_row (int row) |
The number of non-zero elements in a specified row. More... | |
std::size_t | max_in_col (const std::size_t &col, const std::size_t &row_min, const std::size_t &row_max) const |
Find the maximum entry in a column – used in the native solver. More... | |
void | row_swap (const std::size_t &row1, const std::size_t &row2) |
Swap two rows in the matrix – used in the native solver. More... | |
![]() | |
Sequential_Matrix_base () | |
An empty constructor. More... | |
virtual | ~Sequential_Matrix_base () |
virtual const _Type & | operator() (const std::size_t &row, const std::size_t &col) const =0 |
virtual _Type & | operator() (const std::size_t &row, const std::size_t &col)=0 |
virtual const _Type & | get (const std::size_t &row, const std::size_t &col) const =0 |
virtual _Type & | set (const std::size_t &row, const std::size_t &col)=0 |
virtual std::size_t | nrows () const =0 |
virtual std::size_t | ncols () const =0 |
virtual std::size_t | nelts () const =0 |
virtual void | scale (const _Type &mult)=0 |
virtual void | dump () const =0 |
Friends | |
template<typename _SystemType > | |
class | SparseLinearSystem |
A matrix class that constructs a SPARSE matrix as a row major std::vector of SparseVectors.
Definition at line 31 of file SparseMatrix.h.
CppNoddy::SparseMatrix< _Type >::SparseMatrix | ( | const std::size_t & | rows, |
const std::size_t & | cols | ||
) |
Construct with a set number of rows.
rows | The number of rows in the matrix |
cols | The number of columns in the matrix |
Definition at line 15 of file SparseMatrix.cpp.
CppNoddy::SparseMatrix< _Type >::SparseMatrix | ( | const SparseMatrix< _Type > & | source, |
const std::vector< std::size_t > & | source_rows | ||
) |
Construct from a row permutation of another sparse matrix.
source_rows | Defines the permutation, row i of this matrix is row source_rows[i] of the source |
Definition at line 25 of file SparseMatrix.cpp.
CppNoddy::SparseMatrix< _Type >::SparseMatrix | ( | const SparseMatrix< _Type > & | source | ) |
Copy constructor.
source | The source object to be copied |
Definition at line 34 of file SparseMatrix.cpp.
|
inline |
|
inline |
Blank the contents of this matrix.
Definition at line 60 of file SparseMatrix.h.
|
virtual |
Output the contents of the matrix to std::cout.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 197 of file SparseMatrix.cpp.
Referenced by CppNoddy::SparseMatrix< _Type >::dump().
|
inline |
A simple method for dumping the matrix to a file.
filename | The filename to write the data to (will overwrite) |
precision | Precision of the output strings |
Definition at line 137 of file SparseMatrix.h.
References CppNoddy::SparseMatrix< _Type >::dump().
double CppNoddy::SparseMatrix< _Type >::frob_norm |
Definition at line 112 of file SparseMatrix.cpp.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 239 of file SparseMatrix.h.
|
inline |
Get a row of the matrix.
row | The index of the row to be get |
Definition at line 83 of file SparseMatrix.h.
double CppNoddy::SparseMatrix< _Type >::inf_norm |
Definition at line 103 of file SparseMatrix.cpp.
std::size_t CppNoddy::SparseMatrix< _Type >::max_in_col | ( | const std::size_t & | col, |
const std::size_t & | row_min, | ||
const std::size_t & | row_max | ||
) | const |
Find the maximum entry in a column – used in the native solver.
col | The column to search through |
row_min | The start row for the search |
row_max | The end row for the search (NOT INCLUSIVE) |
Definition at line 58 of file SparseMatrix.cpp.
DenseVector< _Type > CppNoddy::SparseMatrix< _Type >::multiply | ( | const DenseVector< _Type > & | X | ) | const |
Right-multiply by a DENSE vector.
X | The DENSE vector to be multiplied by |
|
inlinevirtual |
Get the number of columns in the matrix.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 277 of file SparseMatrix.h.
|
virtual |
Get the number of (non-zero) elements in the matrix.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 49 of file SparseMatrix.cpp.
|
inline |
The number of non-zero elements in a specified row.
row | The row index to return the number of non-zero elts for |
Definition at line 194 of file SparseMatrix.h.
|
inlinevirtual |
Get the number of rows in the matrix.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 272 of file SparseMatrix.h.
double CppNoddy::SparseMatrix< _Type >::one_norm |
Transpose the matrix in place.
Definition at line 85 of file SparseMatrix.cpp.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 234 of file SparseMatrix.h.
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 229 of file SparseMatrix.h.
|
inline |
Assignment operator.
source | The source object for the assignment |
Definition at line 39 of file SparseMatrix.cpp.
|
inline |
Operator overloading for ROW access.
row | The row to access |
Definition at line 249 of file SparseMatrix.h.
|
inline |
Operator overloading for ROW access.
row | The row to access |
Definition at line 261 of file SparseMatrix.h.
|
inline |
Swap two rows in the matrix – used in the native solver.
row1 | The first row to be exchanged |
row2 | The second row to be exchanged |
Definition at line 282 of file SparseMatrix.h.
|
virtual |
Scale the matrix by a scalar.
mult | The scalar multiplier |
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 78 of file SparseMatrix.cpp.
Referenced by main().
|
inlinevirtual |
Access operator.
Implements CppNoddy::Sequential_Matrix_base< _Type >.
Definition at line 244 of file SparseMatrix.h.
|
inline |
Set a row of the matrix.
row | The index of the row to be set |
A | sparse vector of values to go into the row |
Definition at line 90 of file SparseMatrix.h.
double CppNoddy::SparseMatrix< _Type >::two_norm |
Definition at line 94 of file SparseMatrix.cpp.
Definition at line 220 of file SparseMatrix.h.
© 2012
R.E. Hewitt