Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::SparseMatrix Class Reference

#include <SparseMatrix.h>

Collaboration diagram for PLearn::SparseMatrix:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int length () const
int width () const
 SparseMatrix ()
 SparseMatrix (int nbrows, int n_columns, int n_non_zero)
 SparseMatrix (Vec bRow, Vec eRow, Vec Row, Vec Values, int nbrows)
 SparseMatrix (Mat m)
 convert Mat into SparseMatrix:

 SparseMatrix (string filename)
void resize (int nbrows, int n_columns, int n_non_zero)
void loadFortran (const char *filename)
 load SparseMatrix from file in ascii Harwell-Boeing Fortran format: 4-line header, followed by beginRow, row, and values.

void saveFortran (const char *filename)
Mat toMat ()
 convert to the equivalent full matrix

void product (const Vec &x, Vec &y)
 multiply a sparse matrix by a full vector and set resulting vector y = matrix * x

void diag (Vec &d)
 extract the diagonal of the sparse matrix: d[i] = A[i,i]

void diagonalOfSquare (Vec &d)
 d = diagonal(A'*A), i.e.

real dotRow (int i, Vec v)
 return dot product of i-th row with vector v

real dotColumn (int j, Vec v)
 return dot product of j-th column with vector v


Public Attributes

int n_rows
 the dimensions of the matrix are: n_rows x beginRow.length()

Vec beginRow
Vec endRow
Vec row
Vec values

Detailed Description

Sparse matrices

beginRow(n_columns): beginning of block of (not necessarily contiguous) elements of column j in the values vector endRow(n_columns): last element of block of (not necessarily contiguous) elements of column j in the values vector row(n_non_zero_elements): row of a non-zero element values(n_non_zero_elements): value of a non-zero element so for example values[k] is the value of an element (i,j) of the matrix such that row[k]=i and beginRow[i]<=k<=endRow[i].

Definition at line 57 of file SparseMatrix.h.


Constructor & Destructor Documentation

PLearn::SparseMatrix::SparseMatrix  )  [inline]
 

Definition at line 68 of file SparseMatrix.h.

PLearn::SparseMatrix::SparseMatrix int  nbrows,
int  n_columns,
int  n_non_zero
[inline]
 

Definition at line 69 of file SparseMatrix.h.

References beginRow, endRow, n_rows, row, and values.

PLearn::SparseMatrix::SparseMatrix Vec  bRow,
Vec  eRow,
Vec  Row,
Vec  Values,
int  nbrows
[inline]
 

Definition at line 72 of file SparseMatrix.h.

References beginRow, endRow, n_rows, row, and values.

PLearn::SparseMatrix::SparseMatrix Mat  m  ) 
 

convert Mat into SparseMatrix:

Definition at line 149 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, k, PLearn::TMat< T >::mod(), n_rows, PLearn::TVec< T >::resize(), row, values, and PLearn::TMat< T >::width().

PLearn::SparseMatrix::SparseMatrix string  filename  )  [inline]
 

Definition at line 79 of file SparseMatrix.h.

References loadFortran().


Member Function Documentation

void PLearn::SparseMatrix::diag Vec d  ) 
 

extract the diagonal of the sparse matrix: d[i] = A[i,i]

Definition at line 204 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, k, PLearn::TVec< T >::length(), row, and values.

void PLearn::SparseMatrix::diagonalOfSquare Vec d  ) 
 

d = diagonal(A'*A), i.e.

d[i] = |A[i]|^2 where A[i] is i-th column

Definition at line 220 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, k, PLearn::TVec< T >::length(), and values.

real PLearn::SparseMatrix::dotColumn int  j,
Vec  v
 

return dot product of j-th column with vector v

Definition at line 243 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, k, length(), PLearn::TVec< T >::length(), PLERROR, row, and values.

real PLearn::SparseMatrix::dotRow int  i,
Vec  v
 

return dot product of i-th row with vector v

Definition at line 236 of file SparseMatrix.cc.

References PLERROR.

int PLearn::SparseMatrix::length  )  const [inline]
 

Definition at line 65 of file SparseMatrix.h.

References n_rows.

Referenced by dotColumn().

void PLearn::SparseMatrix::loadFortran const char *  filename  ) 
 

load SparseMatrix from file in ascii Harwell-Boeing Fortran format: 4-line header, followed by beginRow, row, and values.

Definition at line 52 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, n_rows, PLERROR, PLearn::TVec< T >::resize(), row, and values.

Referenced by SparseMatrix().

void PLearn::SparseMatrix::product const Vec x,
Vec y
 

multiply a sparse matrix by a full vector and set resulting vector y = matrix * x

Definition at line 182 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::clear(), PLearn::TVec< T >::data(), endRow, k, PLearn::TVec< T >::length(), n_rows, PLERROR, row, values, and x.

void PLearn::SparseMatrix::resize int  nbrows,
int  n_columns,
int  n_non_zero
 

Definition at line 41 of file SparseMatrix.cc.

References beginRow, endRow, n_rows, PLearn::TVec< T >::resize(), row, and values.

void PLearn::SparseMatrix::saveFortran const char *  filename  ) 
 

Definition at line 105 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, PLearn::TVec< T >::length(), n_rows, PLERROR, row, and values.

Mat PLearn::SparseMatrix::toMat  ) 
 

convert to the equivalent full matrix

Definition at line 133 of file SparseMatrix.cc.

References beginRow, PLearn::TVec< T >::data(), endRow, k, PLearn::TVec< T >::length(), PLearn::Mat, n_rows, row, and values.

int PLearn::SparseMatrix::width  )  const [inline]
 

Definition at line 66 of file SparseMatrix.h.

References beginRow, and PLearn::TVec< T >::length().


Member Data Documentation

Vec PLearn::SparseMatrix::beginRow
 

Definition at line 60 of file SparseMatrix.h.

Referenced by PLearn::add(), diag(), diagonalOfSquare(), dotColumn(), loadFortran(), PLearn::operator+(), product(), resize(), PLearn::RowMapSparseMatrix< real >::RowMapSparseMatrix(), saveFortran(), SparseMatrix(), toMat(), and width().

Vec PLearn::SparseMatrix::endRow
 

Definition at line 61 of file SparseMatrix.h.

Referenced by PLearn::add(), diag(), diagonalOfSquare(), dotColumn(), loadFortran(), PLearn::operator+(), product(), resize(), PLearn::RowMapSparseMatrix< real >::RowMapSparseMatrix(), saveFortran(), SparseMatrix(), and toMat().

int PLearn::SparseMatrix::n_rows
 

the dimensions of the matrix are: n_rows x beginRow.length()

Definition at line 59 of file SparseMatrix.h.

Referenced by length(), loadFortran(), PLearn::operator+(), product(), resize(), saveFortran(), SparseMatrix(), and toMat().

Vec PLearn::SparseMatrix::row
 

Definition at line 62 of file SparseMatrix.h.

Referenced by PLearn::add(), diag(), dotColumn(), loadFortran(), PLearn::operator+(), product(), resize(), PLearn::RowMapSparseMatrix< real >::RowMapSparseMatrix(), saveFortran(), SparseMatrix(), and toMat().

Vec PLearn::SparseMatrix::values
 

Definition at line 63 of file SparseMatrix.h.

Referenced by PLearn::add(), diag(), diagonalOfSquare(), dotColumn(), loadFortran(), PLearn::operator+(), product(), resize(), PLearn::RowMapSparseMatrix< real >::RowMapSparseMatrix(), saveFortran(), SparseMatrix(), and toMat().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:23:55 2004 for PLearn by doxygen 1.3.7