SparseMatrix Class Reference

#include <usermatrix.h>

Inheritance diagram for SparseMatrix:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 SparseMatrix (int rows__, int cols__)
 Constructor for a given dimension.
 SparseMatrix (const SparseMatrix &A_)
 Copy-Constructor for a SparseMatrix.
 SparseMatrix (const UserMatrix &A_, bool no_finish=false)
 Copy-Constructor for a UserMatrix.
 SparseMatrix (const ExtUserMatrix &A_, bool no_finish=false)
 Copy-Constructor for an ExtUserMatrix.
virtual ~SparseMatrix ()
 Destructor.
void resize (int rows__, int cols__)
 Resizes the matrix, if it is not finished already.
int rows () const
int cols () const
const int * GetRowInd () const
const int * GetColPtr () const
const double * GetVal () const
double * GetVal ()
virtual double operator() (int row, int col) const
int nonzeros () const
void AddElement (int row, int col, double v, bool check_zero=true)
 Adds an element to the map.
void AddToElement (int row, int col, double v, bool check_zero=true)
SparseMatrixoperator+= (const UserMatrix &A_)
 Adds a UserMatrix to this SparseMatrix.
SparseMatrixoperator+= (const ExtUserMatrix &A_)
 Adds a ExtUserMatrix to this SparseMatrix2.
SparseMatrixoperator= (const double v)
SparseMatrixoperator*= (const double v)
void set_block (const SparseMatrix &A, const ivector &indices)
void finish ()
 Finish the matrix.
virtual void MultV (double *y, const double *x) const
 Multiplication with a double*.
virtual void MultV (dvector &y, const dvector &x) const
 Multiplication with a dvector.
virtual void MultV (UserVector< double > &y, const UserVector< double > &x) const
 Multiplication with a UserVector<double>.
virtual void MultV (IntervalVector &y, const IntervalVector &x) const
virtual interval< double > yAx (const IntervalVector &y, const IntervalVector &x) const
virtual interval< double > xAx (const IntervalVector &x) const
virtual interval< double > xAx_2bx (const IntervalVector &x, const UserVector< double > &b) const
virtual void MultV (SparseVector< double > &y, const SparseVector< double > &x) const
 Multiplication with a SparseVector<double>.
virtual double yAx (const UserVector< double > &y, const UserVector< double > &x) const
virtual double yAx (const dvector &y, const dvector &x) const
virtual double xAx (const UserVector< double > &x) const
virtual void AddMult (UserVector< double > &y, const UserVector< double > &x, const double alpha) const
 Adds to a UserVector<double> the product of a double value and this matrix, multiplied with a UserVector<double>.
void plot (char *filename) const
 Plots the edges of the sparsity pattern to a file, which can be read by gnuplot.
virtual void print (ostream &out) const
 Prints the matrix.

Protected Attributes

map< pair< int, int >, double > values
 A map to construct the matrix.
int nz
 Number of nonzero-elements.
double * val
 The values of the matrix.
int * row_ind
 The row indices of the values.
int * col_ptr
 The indices of the starting columns.
int rows_
 The number of rows and columns.
int cols_

Detailed Description

Definition at line 1050 of file usermatrix.h.


Constructor & Destructor Documentation

SparseMatrix::SparseMatrix ( int  rows__,
int  cols__ 
) [inline]

Constructor for a given dimension.

Parameters:
rows__ The number of rows_.
cols__ The number of columns.

Definition at line 1083 of file usermatrix.h.

SparseMatrix::SparseMatrix ( const SparseMatrix A_  )  [inline]

Copy-Constructor for a SparseMatrix.

Parameters:
A_ The SparseMatrix to copy.

Definition at line 1090 of file usermatrix.h.

SparseMatrix::SparseMatrix ( const UserMatrix A_,
bool  no_finish = false 
)

Copy-Constructor for a UserMatrix.

Parameters:
A_ The UserMatrix to copy.
no_finish Indicates, whether this SparseMatrix shouldn't be finished after copying A_.
SparseMatrix::SparseMatrix ( const ExtUserMatrix A_,
bool  no_finish = false 
) [inline]

Copy-Constructor for an ExtUserMatrix.

Parameters:
A_ The UserMatrix to copy.
no_finish Indicates, whether this SparseMatrix shouldn't be finished after copying A_.

Definition at line 1112 of file usermatrix.h.

virtual SparseMatrix::~SparseMatrix (  )  [inline, virtual]

Destructor.

Deletes val, row_ind and col_ptr, if not NULL.

Definition at line 1123 of file usermatrix.h.


Member Function Documentation

void SparseMatrix::resize ( int  rows__,
int  cols__ 
)

Resizes the matrix, if it is not finished already.

Elements with indices outside the dimension are removed.

int SparseMatrix::rows (  )  const [inline]

Definition at line 1134 of file usermatrix.h.

int SparseMatrix::cols (  )  const [inline]

Definition at line 1135 of file usermatrix.h.

const int* SparseMatrix::GetRowInd (  )  const [inline]

Definition at line 1137 of file usermatrix.h.

const int* SparseMatrix::GetColPtr (  )  const [inline]

Definition at line 1138 of file usermatrix.h.

const double* SparseMatrix::GetVal (  )  const [inline]

Definition at line 1139 of file usermatrix.h.

double* SparseMatrix::GetVal (  )  [inline]

Definition at line 1140 of file usermatrix.h.

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

Reimplemented in SparseMatrix2.

Definition at line 1142 of file usermatrix.h.

int SparseMatrix::nonzeros (  )  const [inline]

Definition at line 1151 of file usermatrix.h.

void SparseMatrix::AddElement ( int  row,
int  col,
double  v,
bool  check_zero = true 
) [inline]

Adds an element to the map.

Parameters:
row The row.
col The column.
v The value.
check_zero If set to true (default), and |v|<rtol, the element is not added.
See also:
values

Definition at line 1163 of file usermatrix.h.

void SparseMatrix::AddToElement ( int  row,
int  col,
double  v,
bool  check_zero = true 
) [inline]

Definition at line 1173 of file usermatrix.h.

SparseMatrix& SparseMatrix::operator+= ( const UserMatrix A_  ) 

Adds a UserMatrix to this SparseMatrix.

Computes the elements by multiplication with unit vectors. This matrix needs to be unfinished to do this.

Parameters:
A_ The UserMatrix to add.
Returns:
This matrix.

Reimplemented in SparseMatrix2.

SparseMatrix& SparseMatrix::operator+= ( const ExtUserMatrix A_  )  [inline]

Adds a ExtUserMatrix to this SparseMatrix2.

This matrix needs to be unfinished to do this.

Parameters:
A_ The ExtUserMatrix to add.
Returns:
This matrix.

Reimplemented in SparseMatrix2.

Definition at line 1199 of file usermatrix.h.

SparseMatrix& SparseMatrix::operator= ( const double  v  ) 

Reimplemented in SparseMatrix2.

SparseMatrix& SparseMatrix::operator*= ( const double  v  ) 

Reimplemented in SparseMatrix2.

void SparseMatrix::set_block ( const SparseMatrix A,
const ivector indices 
)
void SparseMatrix::finish (  ) 

Finish the matrix.

Constructs the arrays val, row_ind and col_ptr, using the map. Clears values.

virtual void SparseMatrix::MultV ( double *  y,
const double *  x 
) const [inline, virtual]

Multiplication with a double*.

Parameters:
y The double* to store the result in.
x The double* to multipliy with.

Reimplemented in SparseMatrix2.

Definition at line 1226 of file usermatrix.h.

virtual void SparseMatrix::MultV ( dvector y,
const dvector x 
) const [inline, virtual]

Multiplication with a dvector.

Parameters:
y The dvector to store the result in.
x The dvector to multipliy with.

Reimplemented in SparseMatrix2.

Definition at line 1241 of file usermatrix.h.

virtual void SparseMatrix::MultV ( UserVector< double > &  y,
const UserVector< double > &  x 
) const [inline, virtual]

Multiplication with a UserVector<double>.

Parameters:
y The UserVector<double> to store the result in.
x The UserVector<double> to multipliy with.

Reimplemented in SparseMatrix2.

Definition at line 1253 of file usermatrix.h.

virtual void SparseMatrix::MultV ( IntervalVector y,
const IntervalVector x 
) const [inline, virtual]

Reimplemented in SparseMatrix2.

Definition at line 1269 of file usermatrix.h.

virtual interval<double> SparseMatrix::yAx ( const IntervalVector y,
const IntervalVector x 
) const [inline, virtual]

Definition at line 1284 of file usermatrix.h.

virtual interval<double> SparseMatrix::xAx ( const IntervalVector x  )  const [inline, virtual]

Reimplemented in SparseMatrix2.

Definition at line 1302 of file usermatrix.h.

virtual interval<double> SparseMatrix::xAx_2bx ( const IntervalVector x,
const UserVector< double > &  b 
) const [virtual]

Reimplemented in SparseMatrix2.

virtual void SparseMatrix::MultV ( SparseVector< double > &  y,
const SparseVector< double > &  x 
) const [inline, virtual]

Multiplication with a SparseVector<double>.

Parameters:
y The SparseVector<double> to store the result in.
x The SparseVector<double> to multipliy with.

Reimplemented in SparseMatrix2.

Definition at line 1328 of file usermatrix.h.

virtual double SparseMatrix::yAx ( const UserVector< double > &  y,
const UserVector< double > &  x 
) const [inline, virtual]

Reimplemented in SparseMatrix2.

Definition at line 1346 of file usermatrix.h.

virtual double SparseMatrix::yAx ( const dvector y,
const dvector x 
) const [inline, virtual]

Reimplemented in SparseMatrix2.

Definition at line 1364 of file usermatrix.h.

virtual double SparseMatrix::xAx ( const UserVector< double > &  x  )  const [inline, virtual]

Reimplemented in SparseMatrix2.

Definition at line 1382 of file usermatrix.h.

virtual void SparseMatrix::AddMult ( UserVector< double > &  y,
const UserVector< double > &  x,
const double  alpha 
) const [inline, virtual]

Adds to a UserVector<double> the product of a double value and this matrix, multiplied with a UserVector<double>.

Parameters:
y The UserVector<double> to store the result in: y + alpha * A * x
x The UserVector<double> to multiply this matrix with.
alpha The double to multiply with.

Reimplemented in SparseMatrix2.

Definition at line 1389 of file usermatrix.h.

void SparseMatrix::plot ( char *  filename  )  const

Plots the edges of the sparsity pattern to a file, which can be read by gnuplot.

For each entry (i,j) in the matrix, it prints the i and j in one line.

Parameters:
filename The name of the file to print to.
virtual void SparseMatrix::print ( ostream &  out  )  const [virtual]

Prints the matrix.

Prints the row, column and value for each non-zero entry in this SparseMatrix2.

Reimplemented in SparseMatrix2.


Member Data Documentation

map<pair<int,int>, double> SparseMatrix::values [protected]

A map to construct the matrix.

Maps (col, row) to values.

Definition at line 1055 of file usermatrix.h.

int SparseMatrix::nz [protected]

Number of nonzero-elements.

If the matrix is not defined, this is -1.

Definition at line 1060 of file usermatrix.h.

double* SparseMatrix::val [protected]

The values of the matrix.

size=nz.

Definition at line 1064 of file usermatrix.h.

int* SparseMatrix::row_ind [protected]

The row indices of the values.

size=nz.

Definition at line 1068 of file usermatrix.h.

int* SparseMatrix::col_ptr [protected]

The indices of the starting columns.

size=dim()+1.

Definition at line 1072 of file usermatrix.h.

int SparseMatrix::rows_ [protected]

The number of rows and columns.

Definition at line 1076 of file usermatrix.h.

int SparseMatrix::cols_ [protected]

Definition at line 1076 of file usermatrix.h.


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

Generated on 10 Mar 2013 for LaGO by  doxygen 1.6.1