iSAM
isam::SparseMatrix Class Reference
Inheritance diagram for isam::SparseMatrix:

List of all members.

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 SparseMatrixoperator= (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 SparseVectorget_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

Detailed Description

Definition at line 39 of file SparseMatrix.h.


Constructor & Destructor Documentation

isam::SparseMatrix::SparseMatrix ( int  num_rows,
int  num_cols 
)

Constructor.

Parameters:
num_rowsInitial number of rows.
num_colsInitial number of columns.

Definition at line 76 of file SparseMatrix.cpp.

Copy constructor.

Parameters:
matMatrix to copy.

Definition at line 82 of file SparseMatrix.cpp.

isam::SparseMatrix::SparseMatrix ( const SparseMatrix mat,
int  num_rows,
int  num_cols,
int  first_row = 0,
int  first_col = 0 
)

Submatrix copy constructor

Parameters:
matMatrix to copy.
num_rowsNumber of rows to copy.
num_colsNumber of columns to copy.
first_rowRow offset.
first_colColumn offset.

Definition at line 86 of file SparseMatrix.cpp.

Destructor.

Definition at line 105 of file SparseMatrix.cpp.


Member Function Documentation

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.

Parameters:
rowRow of new entry.
colColumn of new entry - must be after last existing one in this row.
valValue 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.

Parameters:
numNumber 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.

Parameters:
numNumber 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.

Parameters:
rowThe row from which row_bot is taken.
colThe column of row_bot that should become 0.
c_givensReturns cosine of givens rotation if not NULL.
s_givensReturns 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.

Parameters:
num_colsNumber 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.

Parameters:
num_rowsNumber of rows.

Definition at line 279 of file SparseMatrix.cpp.

const SparseVector & isam::SparseMatrix::get_row ( int  row) const [virtual]

Return a sparse row.

Parameters:
rowNumber of row to return.
Returns:
Sparse row vector.

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.

Parameters:
num_rowsNumber of rows of new matrix.
num_colsNumber of columns of new matrix.
rowsArray 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.

Returns:
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.

Returns:
Number of non-zero entries.

Definition at line 147 of file SparseMatrix.cpp.

double isam::SparseMatrix::operator() ( int  row,
int  col 
) const [virtual]

Read a matrix entry.

Parameters:
rowRow of entry.
colColumn of entry.
Returns:
Value of entry.

Definition at line 124 of file SparseMatrix.cpp.

const SparseMatrix & isam::SparseMatrix::operator= ( const SparseMatrix mat)

Assignment operator.

Parameters:
matRight-hand-side matrix in assignment
Returns:
self.

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)"

Parameters:
outOutput 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

Parameters:
file_nameFile 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.

Parameters:
rowRow of entry.
colColumn of entry.
valNew value of entry.
grow_matrixEnlarge 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.

Parameters:
rowNumber of row to replace.
new_rowNew row vector.

Reimplemented in isam::OrderedSparseMatrix.

Definition at line 235 of file SparseMatrix.cpp.

Triangulate matrix by applying Givens rotations to all entries below the diagonal.

Returns:
Number of Givens rotations applied (for analysis).

Definition at line 371 of file SparseMatrix.cpp.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables