Public Member Functions | |
SparseMatrix (int num_rows, int num_cols) | |
SparseMatrix (const SparseMatrix &mat) | |
SparseMatrix (const SparseMatrix &mat, int num_rows, int num_cols, int first_row=0, int first_col=0) | |
SparseMatrix (int num_rows, int num_cols, SparseVector_p *rows) | |
virtual | ~SparseMatrix () |
const SparseMatrix & | operator= (const SparseMatrix &mat) |
virtual double | operator() (int row, int col) const |
virtual void | set (int row, int col, const double val, bool grow_matrix=false) |
virtual void | append_in_row (int row, int col, const double val) |
virtual int | nnz () const |
virtual int | max_nz () const |
virtual void | print (std::ostream &out=std::cout) const |
virtual void | print (const std::string &file_name) const |
virtual void | print_stats () const |
virtual void | print_pattern () const |
virtual void | save_pattern_eps (const std::string &file_name) const |
virtual const SparseVector & | get_row (int row) const |
virtual void | set_row (int row, const SparseVector &new_row) |
virtual void | import_rows (int num_rows, int num_cols, SparseVector_p *rows) |
virtual void | append_new_rows (int num) |
virtual void | append_new_cols (int num) |
virtual void | ensure_num_rows (int num_rows) |
virtual void | ensure_num_cols (int num_cols) |
virtual void | remove_row () |
virtual void | apply_givens (int row, int col, double *c_givens=NULL, double *s_givens=NULL) |
virtual int | triangulate_with_givens () |
int | num_rows () const |
int | num_cols () const |
Friends | |
class | OrderedSparseMatrix |
Definition at line 39 of file SparseMatrix.h.
isam::SparseMatrix::SparseMatrix | ( | int | num_rows, |
int | num_cols | ||
) |
Constructor.
num_rows | Initial number of rows. |
num_cols | Initial number of columns. |
Definition at line 76 of file SparseMatrix.cpp.
isam::SparseMatrix::SparseMatrix | ( | const SparseMatrix & | mat | ) |
isam::SparseMatrix::SparseMatrix | ( | const SparseMatrix & | mat, |
int | num_rows, | ||
int | num_cols, | ||
int | first_row = 0 , |
||
int | first_col = 0 |
||
) |
Submatrix copy constructor
mat | Matrix to copy. |
num_rows | Number of rows to copy. |
num_cols | Number of columns to copy. |
first_row | Row offset. |
first_col | Column offset. |
Definition at line 86 of file SparseMatrix.cpp.
isam::SparseMatrix::~SparseMatrix | ( | ) | [virtual] |
Destructor.
Definition at line 105 of file SparseMatrix.cpp.
void isam::SparseMatrix::append_in_row | ( | int | row, |
int | col, | ||
const double | val | ||
) | [virtual] |
Append a new entry to a row. Allows efficient adding of presorted elements.
row | Row of new entry. |
col | Column of new entry - must be after last existing one in this row. |
val | Value of new entry. |
Definition at line 141 of file SparseMatrix.cpp.
void isam::SparseMatrix::append_new_cols | ( | int | num | ) | [virtual] |
Append new columns to matrix.
num | Number of columns to add. |
Reimplemented in isam::OrderedSparseMatrix.
Definition at line 270 of file SparseMatrix.cpp.
void isam::SparseMatrix::append_new_rows | ( | int | num | ) | [virtual] |
Append new rows to matrix.
num | Number of rows to add. |
Reimplemented in isam::SparseSystem.
Definition at line 252 of file SparseMatrix.cpp.
void isam::SparseMatrix::apply_givens | ( | int | row, |
int | col, | ||
double * | c_givens = NULL , |
||
double * | s_givens = NULL |
||
) | [virtual] |
Zero out an entry by applying a Givens rotation. Note that both sparse rows have to be completely 0 on the left of col.
row | The row from which row_bot is taken. |
col | The column of row_bot that should become 0. |
c_givens | Returns cosine of givens rotation if not NULL. |
s_givens | Returns sine of givens rotation if not NULL. |
Reimplemented in isam::SparseSystem.
Definition at line 301 of file SparseMatrix.cpp.
void isam::SparseMatrix::ensure_num_cols | ( | int | num_cols | ) | [virtual] |
Grow matrix to given number of columns; ignore if already at least as large.
num_cols | Number of columns. |
Definition at line 286 of file SparseMatrix.cpp.
void isam::SparseMatrix::ensure_num_rows | ( | int | num_rows | ) | [virtual] |
Grow matrix to given number of rows; ignore if already at least as large.
num_rows | Number of rows. |
Definition at line 279 of file SparseMatrix.cpp.
const SparseVector & isam::SparseMatrix::get_row | ( | int | row | ) | const [virtual] |
Return a sparse row.
row | Number of row to return. |
Definition at line 230 of file SparseMatrix.cpp.
void isam::SparseMatrix::import_rows | ( | int | num_rows, |
int | num_cols, | ||
SparseVector_p * | rows | ||
) | [virtual] |
Import externally allocated rows.
num_rows | Number of rows of new matrix. |
num_cols | Number of columns of new matrix. |
rows | Array of SparseVector of length num_rows. |
Definition at line 240 of file SparseMatrix.cpp.
int isam::SparseMatrix::max_nz | ( | ) | const [virtual] |
Determine maximum number of non-zero entries in any column.
Definition at line 155 of file SparseMatrix.cpp.
int isam::SparseMatrix::nnz | ( | ) | const [virtual] |
Determine number of non-zero entries in sparse matrix.
Definition at line 147 of file SparseMatrix.cpp.
double isam::SparseMatrix::operator() | ( | int | row, |
int | col | ||
) | const [virtual] |
Read a matrix entry.
row | Row of entry. |
col | Column of entry. |
Definition at line 124 of file SparseMatrix.cpp.
const SparseMatrix & isam::SparseMatrix::operator= | ( | const SparseMatrix & | mat | ) |
Assignment operator.
mat | Right-hand-side matrix in assignment |
Definition at line 109 of file SparseMatrix.cpp.
void isam::SparseMatrix::print | ( | std::ostream & | out = std::cout | ) | const [virtual] |
Print sparse matrix as triples to stream; also readable by Matlab: "load R.txt; S=spconvert(R); spy(S)"
out | Output stream. |
Definition at line 163 of file SparseMatrix.cpp.
void isam::SparseMatrix::print | ( | const std::string & | file_name | ) | const [virtual] |
Print sparse matrix as triples to file
file_name | File name to write sparse matrix to. |
Definition at line 175 of file SparseMatrix.cpp.
void isam::SparseMatrix::print_pattern | ( | ) | const [virtual] |
Prints non-zero pattern to stdout.
Definition at line 185 of file SparseMatrix.cpp.
void isam::SparseMatrix::print_stats | ( | ) | const [virtual] |
Print size of matrix and number of entries for debugging.
Definition at line 181 of file SparseMatrix.cpp.
void isam::SparseMatrix::remove_row | ( | ) | [virtual] |
Removes the last row (used in SparseSystem::add_row_givens).
Definition at line 293 of file SparseMatrix.cpp.
void isam::SparseMatrix::save_pattern_eps | ( | const std::string & | file_name | ) | const [virtual] |
Save eps graphics file with sparse matrix patterns.
Definition at line 199 of file SparseMatrix.cpp.
void isam::SparseMatrix::set | ( | int | row, |
int | col, | ||
const double | val, | ||
bool | grow_matrix = false |
||
) | [virtual] |
Set one entry of the matrix. Non-existing entries are created.
row | Row of entry. |
col | Column of entry. |
val | New value of entry. |
grow_matrix | Enlarge matrix if entry outside current size (default: false). |
Definition at line 130 of file SparseMatrix.cpp.
void isam::SparseMatrix::set_row | ( | int | row, |
const SparseVector & | new_row | ||
) | [virtual] |
Replace the given row.
row | Number of row to replace. |
new_row | New row vector. |
Reimplemented in isam::OrderedSparseMatrix.
Definition at line 235 of file SparseMatrix.cpp.
int isam::SparseMatrix::triangulate_with_givens | ( | ) | [virtual] |
Triangulate matrix by applying Givens rotations to all entries below the diagonal.
Definition at line 371 of file SparseMatrix.cpp.