Public Member Functions | Private Member Functions | Private Attributes | Friends
isam::SparseMatrix Class Reference

#include <SparseMatrix.h>

Inheritance diagram for isam::SparseMatrix:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void append_in_row (int row, int col, const double val)
virtual void append_new_cols (int num)
virtual void append_new_rows (int num)
virtual void apply_givens (int row, int col, double *c_givens=NULL, double *s_givens=NULL)
virtual void ensure_num_cols (int num_cols)
virtual void ensure_num_rows (int num_rows)
virtual const SparseVectorget_row (int row) const
virtual void import_rows (int num_rows, int num_cols, SparseVector_p *rows)
virtual int max_nz () const
virtual int nnz () const
int num_cols () const
int num_rows () const
virtual double operator() (int row, int col) const
const SparseMatrixoperator= (const SparseMatrix &mat)
virtual void print (std::ostream &out=std::cout) const
virtual void print (const std::string &file_name) const
virtual void print_pattern () const
virtual void print_stats () const
virtual void remove_row ()
virtual void save_pattern_eps (const std::string &file_name) const
virtual void set (int row, int col, const double val, bool grow_matrix=false)
virtual void set_row (int row, const SparseVector &new_row)
 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 int triangulate_with_givens ()
virtual ~SparseMatrix ()

Private Member Functions

void _allocate_SparseMatrix (int num_rows, int num_cols, int max_num_rows, int max_num_cols, bool init_rows=true)
void _copy_from_SparseMatrix (const SparseMatrix &mat)
void _dealloc_SparseMatrix ()

Private Attributes

int _max_num_cols
int _max_num_rows
int _num_cols
int _num_rows
SparseVector_p_rows

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.

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

Definition at line 94 of file SparseMatrix.cpp.

Destructor.

Definition at line 105 of file SparseMatrix.cpp.


Member Function Documentation

void isam::SparseMatrix::_allocate_SparseMatrix ( int  num_rows,
int  num_cols,
int  max_num_rows,
int  max_num_cols,
bool  init_rows = true 
) [private]

Allocate memory - private.

Parameters:
num_rowsNumber of active rows.
num_colsNumber of active columns.
max_num_rowsNumber of rows to reserve memory for.
max_num_colsNumber of columns to reserve memory for.

Definition at line 47 of file SparseMatrix.cpp.

Copy data from one sparse matrix to a new one - private.

Parameters:
vecExisting sparse vector to copy from.

Definition at line 60 of file SparseMatrix.cpp.

Deallocate memory - private.

Definition at line 67 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.

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.

int isam::SparseMatrix::num_cols ( ) const [inline]

Definition at line 238 of file SparseMatrix.h.

int isam::SparseMatrix::num_rows ( ) const [inline]

Definition at line 237 of file SparseMatrix.h.

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.

virtual 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.
virtual 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.
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.


Friends And Related Function Documentation

friend class OrderedSparseMatrix [friend]

Definition at line 240 of file SparseMatrix.h.


Member Data Documentation

Definition at line 43 of file SparseMatrix.h.

Definition at line 42 of file SparseMatrix.h.

Definition at line 41 of file SparseMatrix.h.

Definition at line 40 of file SparseMatrix.h.

Definition at line 44 of file SparseMatrix.h.


The documentation for this class was generated from the following files:


demo_rgbd
Author(s): Ji Zhang
autogenerated on Tue Mar 3 2015 18:01:08