vnl_sparse_matrix< T > Class Template Reference

#include <vnl_sparse_matrix.h>

List of all members.


Detailed Description

template<class T>
class vnl_sparse_matrix< T >

Simple sparse matrix.

Stores non-zero elements as a sparse_matrix_pair

Definition at line 87 of file vnl_sparse_matrix.h.


Public Types

typedef vnl_sparse_matrix_pair<
T > 
pair_t
typedef vcl_vector< pair_trow
typedef vcl_vector< rowvnl_sparse_matrix_elements

Public Member Functions

 vnl_sparse_matrix ()
 Construct an empty matrix.
 vnl_sparse_matrix (unsigned int m, unsigned int n)
 Construct an empty m*n matrix.
 vnl_sparse_matrix (const vnl_sparse_matrix< T > &rhs)
 Construct an m*n Matrix and copy rhs into it.
vnl_sparse_matrix< T > & operator= (const vnl_sparse_matrix< T > &rhs)
 Copy another vnl_sparse_matrix<T> into this.
void mult (vnl_sparse_matrix< T > const &rhs, vnl_sparse_matrix< T > &result) const
 Multiply this*rhs, another sparse matrix.
void mult (vnl_vector< T > const &rhs, vnl_vector< T > &result) const
 Multiply this*rhs, where rhs is a vector.
void mult (unsigned int n, unsigned int m, T const *p, T *q) const
 Multiply this*p, a fortran order matrix.
void pre_mult (const vnl_vector< T > &lhs, vnl_vector< T > &result) const
 Multiplies lhs*this, where lhs is a vector.
void add (const vnl_sparse_matrix< T > &rhs, vnl_sparse_matrix< T > &result) const
 Add rhs to this.
void subtract (const vnl_sparse_matrix< T > &rhs, vnl_sparse_matrix< T > &result) const
 Subtract rhs from this.
T & operator() (unsigned int row, unsigned int column)
 Get a reference to an entry in the matrix.
void diag_AtA (vnl_vector< T > &result) const
 Get diag(A_tranpose * A).
void set_row (unsigned int r, vcl_vector< int > const &cols, vcl_vector< T > const &vals)
 Set a whole row at once. Much faster.
rowget_row (unsigned int r)
 Return row as vector of pairs.
vnl_sparse_matrix< T > & vcat (vnl_sparse_matrix< T > const &A)
 Laminate matrix A onto the bottom of this one.
unsigned int rows () const
 Get the number of rows in the matrix.
unsigned int columns () const
 Get the number of columns in the matrix.
unsigned int cols () const
 Get the number of columns in the matrix.
bool empty_row (unsigned int r) const
 Return whether a given row is empty.
sum_row (unsigned int r)
 This is occasionally useful.
void scale_row (unsigned int r, T scale)
 Useful for normalizing row sums in convolution operators.
void set_size (int r, int c)
 Resizes the array to have r rows and c cols -- sets elements to null.
void resize (int r, int c)
 Resizes the array to have r rows and c cols.
void reset () const
 Resets the internal iterator.
bool next () const
 Moves the internal iterator to next non-zero entry in matrix.
int getrow () const
 Returns the row of the entry pointed to by internal iterator.
int getcolumn () const
 Returns the column of the entry pointed to by internal iterator.
value () const
 Returns the value pointed to by the internal iterator.

Protected Attributes

vnl_sparse_matrix_elements elements
unsigned int rs_
unsigned int cs_
unsigned int itr_row
row::const_iterator itr_cur
bool itr_isreset

Member Typedef Documentation

template<class T>
typedef vnl_sparse_matrix_pair<T> vnl_sparse_matrix< T >::pair_t

Definition at line 90 of file vnl_sparse_matrix.h.

template<class T>
typedef vcl_vector< pair_t > vnl_sparse_matrix< T >::row

Definition at line 96 of file vnl_sparse_matrix.h.

template<class T>
typedef vcl_vector< row > vnl_sparse_matrix< T >::vnl_sparse_matrix_elements

Definition at line 97 of file vnl_sparse_matrix.h.


Constructor & Destructor Documentation

template<class T>
vnl_sparse_matrix< T >::vnl_sparse_matrix (  ) 

Construct an empty matrix.

Definition at line 23 of file vnl_sparse_matrix.txx.

template<class T>
vnl_sparse_matrix< T >::vnl_sparse_matrix ( unsigned int  m,
unsigned int  n 
)

Construct an empty m*n matrix.

Definition at line 31 of file vnl_sparse_matrix.txx.

template<class T>
vnl_sparse_matrix< T >::vnl_sparse_matrix ( const vnl_sparse_matrix< T > &  rhs  ) 

Construct an m*n Matrix and copy rhs into it.

Definition at line 39 of file vnl_sparse_matrix.txx.


Member Function Documentation

template<class T>
vnl_sparse_matrix< T > & vnl_sparse_matrix< T >::operator= ( const vnl_sparse_matrix< T > &  rhs  ) 

Copy another vnl_sparse_matrix<T> into this.

Definition at line 47 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::mult ( vnl_sparse_matrix< T > const &  rhs,
vnl_sparse_matrix< T > &  result 
) const

Multiply this*rhs, another sparse matrix.

Definition at line 62 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::mult ( vnl_vector< T > const &  rhs,
vnl_vector< T > &  result 
) const

Multiply this*rhs, where rhs is a vector.

Definition at line 229 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::mult ( unsigned int  prows,
unsigned int  pcols,
T const *  p,
T *  q 
) const

Multiply this*p, a fortran order matrix.

The matrix p has n rows and m columns, and is in fortran order, ie. columns first.

Definition at line 143 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::pre_mult ( const vnl_vector< T > &  lhs,
vnl_vector< T > &  result 
) const

Multiplies lhs*this, where lhs is a vector.

Definition at line 255 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::add ( const vnl_sparse_matrix< T > &  rhs,
vnl_sparse_matrix< T > &  result 
) const

Add rhs to this.

Definition at line 292 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::subtract ( const vnl_sparse_matrix< T > &  rhs,
vnl_sparse_matrix< T > &  result 
) const

Subtract rhs from this.

Definition at line 345 of file vnl_sparse_matrix.txx.

template<class T>
T & vnl_sparse_matrix< T >::operator() ( unsigned int  row,
unsigned int  column 
)

Get a reference to an entry in the matrix.

Definition at line 398 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::diag_AtA ( vnl_vector< T > &  result  )  const

Get diag(A_tranpose * A).

Useful for forming Jacobi preconditioners for linear solvers.

Definition at line 414 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::set_row ( unsigned int  r,
vcl_vector< int > const &  cols,
vcl_vector< T > const &  vals 
)

Set a whole row at once. Much faster.

Definition at line 435 of file vnl_sparse_matrix.txx.

template<class T>
row& vnl_sparse_matrix< T >::get_row ( unsigned int  r  )  [inline]

Return row as vector of pairs.

Added to aid binary I/O

Definition at line 146 of file vnl_sparse_matrix.h.

template<class T>
vnl_sparse_matrix< T > & vnl_sparse_matrix< T >::vcat ( vnl_sparse_matrix< T > const &  A  ) 

Laminate matrix A onto the bottom of this one.

Definition at line 451 of file vnl_sparse_matrix.txx.

template<class T>
unsigned int vnl_sparse_matrix< T >::rows (  )  const [inline]

Get the number of rows in the matrix.

Definition at line 152 of file vnl_sparse_matrix.h.

template<class T>
unsigned int vnl_sparse_matrix< T >::columns (  )  const [inline]

Get the number of columns in the matrix.

Definition at line 155 of file vnl_sparse_matrix.h.

template<class T>
unsigned int vnl_sparse_matrix< T >::cols (  )  const [inline]

Get the number of columns in the matrix.

Definition at line 158 of file vnl_sparse_matrix.h.

template<class T>
bool vnl_sparse_matrix< T >::empty_row ( unsigned int  r  )  const [inline]

Return whether a given row is empty.

Definition at line 161 of file vnl_sparse_matrix.h.

template<class T>
T vnl_sparse_matrix< T >::sum_row ( unsigned int  r  ) 

This is occasionally useful.

Definition at line 470 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::scale_row ( unsigned int  r,
scale 
)

Useful for normalizing row sums in convolution operators.

Definition at line 482 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::set_size ( int  r,
int  c 
)

Resizes the array to have r rows and c cols -- sets elements to null.

Definition at line 494 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::resize ( int  r,
int  c 
)

Resizes the array to have r rows and c cols.

This is more wasteful of resources than set_size, but it preserves the contents.

Definition at line 513 of file vnl_sparse_matrix.txx.

template<class T>
void vnl_sparse_matrix< T >::reset (  )  const

Resets the internal iterator.

Definition at line 537 of file vnl_sparse_matrix.txx.

template<class T>
bool vnl_sparse_matrix< T >::next (  )  const

Moves the internal iterator to next non-zero entry in matrix.

Returns true if there is another value, false otherwise. Use in combination with methods reset, getrow, getcolumn, and value.

Definition at line 549 of file vnl_sparse_matrix.txx.

template<class T>
int vnl_sparse_matrix< T >::getrow (  )  const

Returns the row of the entry pointed to by internal iterator.

Definition at line 584 of file vnl_sparse_matrix.txx.

template<class T>
int vnl_sparse_matrix< T >::getcolumn (  )  const

Returns the column of the entry pointed to by internal iterator.

Definition at line 593 of file vnl_sparse_matrix.txx.

template<class T>
T vnl_sparse_matrix< T >::value (  )  const

Returns the value pointed to by the internal iterator.

Definition at line 602 of file vnl_sparse_matrix.txx.


Member Data Documentation

template<class T>
vnl_sparse_matrix_elements vnl_sparse_matrix< T >::elements [protected]

Definition at line 194 of file vnl_sparse_matrix.h.

template<class T>
unsigned int vnl_sparse_matrix< T >::rs_ [protected]

Definition at line 195 of file vnl_sparse_matrix.h.

template<class T>
unsigned int vnl_sparse_matrix< T >::cs_ [protected]

Definition at line 195 of file vnl_sparse_matrix.h.

template<class T>
unsigned int vnl_sparse_matrix< T >::itr_row [mutable, protected]

Definition at line 198 of file vnl_sparse_matrix.h.

template<class T>
row::const_iterator vnl_sparse_matrix< T >::itr_cur [mutable, protected]

Definition at line 199 of file vnl_sparse_matrix.h.

template<class T>
bool vnl_sparse_matrix< T >::itr_isreset [mutable, protected]

Definition at line 200 of file vnl_sparse_matrix.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 22 05:06:30 2008 for core/vnl by  doxygen 1.5.1