#include <usermatrix.h>
Inheritance diagram for SparseMatrix:
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) |
SparseMatrix & | operator+= (const UserMatrix &A_) |
Adds a UserMatrix to this SparseMatrix. | |
SparseMatrix & | operator+= (const ExtUserMatrix &A_) |
Adds a ExtUserMatrix to this SparseMatrix2. | |
SparseMatrix & | operator= (const double v) |
SparseMatrix & | operator *= (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_ |
Definition at line 1050 of file usermatrix.h.
SparseMatrix::SparseMatrix | ( | int | rows__, | |
int | cols__ | |||
) | [inline] |
Constructor for a given dimension.
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.
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.
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.
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.
References AddElement(), cols_, finish(), and rows_.
virtual SparseMatrix::~SparseMatrix | ( | ) | [inline, virtual] |
Destructor.
Deletes val, row_ind and col_ptr, if not NULL.
Definition at line 1123 of file usermatrix.h.
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.
References rows_.
Referenced by SparseMatrix2::SparseMatrix2().
int SparseMatrix::cols | ( | ) | const [inline] |
Definition at line 1135 of file usermatrix.h.
References cols_.
Referenced by SparseMatrix2::SparseMatrix2().
const int* SparseMatrix::GetRowInd | ( | ) | const [inline] |
const int* SparseMatrix::GetColPtr | ( | ) | const [inline] |
const double* SparseMatrix::GetVal | ( | ) | const [inline] |
double* SparseMatrix::GetVal | ( | ) | [inline] |
virtual double SparseMatrix::operator() | ( | int | row, | |
int | col | |||
) | const [inline, virtual] |
Reimplemented in SparseMatrix2.
Definition at line 1142 of file usermatrix.h.
References col_ptr, row_ind, and val.
Referenced by SparseMatrix2::operator()().
int SparseMatrix::nonzeros | ( | ) | const [inline] |
void SparseMatrix::AddElement | ( | int | row, | |
int | col, | |||
double | v, | |||
bool | check_zero = true | |||
) | [inline] |
Adds an element to the map.
row | The row. | |
col | The column. | |
v | The value. | |
check_zero | If set to true (default), and |v|<rtol, the element is not added. |
Definition at line 1163 of file usermatrix.h.
References cols_, rows_, rtol, val, and values.
Referenced by SparseMatrix().
void SparseMatrix::AddToElement | ( | int | row, | |
int | col, | |||
double | v, | |||
bool | check_zero = true | |||
) | [inline] |
Definition at line 1173 of file usermatrix.h.
References cols_, rows_, rtol, val, and values.
Referenced by operator+=().
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.
A_ | The UserMatrix to add. |
Reimplemented in SparseMatrix2.
Referenced by SparseMatrix2::operator+=().
SparseMatrix& SparseMatrix::operator+= | ( | const ExtUserMatrix & | A_ | ) | [inline] |
Adds a ExtUserMatrix to this SparseMatrix2.
This matrix needs to be unfinished to do this.
A_ | The ExtUserMatrix to add. |
Reimplemented in SparseMatrix2.
Definition at line 1199 of file usermatrix.h.
References AddToElement(), cols_, UserMatrix::dim(), and rows_.
SparseMatrix& SparseMatrix::operator= | ( | const double | v | ) |
SparseMatrix& SparseMatrix::operator *= | ( | const double | v | ) |
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.
Referenced by SparseMatrix().
virtual void SparseMatrix::MultV | ( | double * | y, | |
const double * | x | |||
) | const [inline, virtual] |
Multiplication with a double*.
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.
References col_ptr, cols_, row_ind, rows_, and val.
Referenced by SparseMatrix2::MultV(), and MultV().
Multiplication with a dvector.
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.
References cols_, DenseVector< Type >::dim(), MultV(), and rows_.
virtual void SparseMatrix::MultV | ( | UserVector< double > & | y, | |
const UserVector< double > & | x | |||
) | const [inline, virtual] |
Multiplication with a UserVector<double>.
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.
References col_ptr, cols_, UserVector< Type >::dim(), row_ind, rows_, and val.
virtual void SparseMatrix::MultV | ( | IntervalVector & | y, | |
const IntervalVector & | x | |||
) | const [inline, virtual] |
virtual interval<double> SparseMatrix::yAx | ( | const IntervalVector & | y, | |
const IntervalVector & | x | |||
) | const [inline, virtual] |
Definition at line 1284 of file usermatrix.h.
References col_ptr, cols_, row_ind, rows_, and val.
Referenced by xAx(), and SparseMatrix2::yAx().
virtual interval<double> SparseMatrix::xAx | ( | const IntervalVector & | x | ) | const [inline, virtual] |
Reimplemented in SparseMatrix2.
Definition at line 1302 of file usermatrix.h.
References col_ptr, cols_, row_ind, rows_, and val.
Referenced by SparseMatrix2::xAx().
virtual interval<double> SparseMatrix::xAx_2bx | ( | const IntervalVector & | x, | |
const UserVector< double > & | b | |||
) | const [virtual] |
virtual void SparseMatrix::MultV | ( | SparseVector< double > & | y, | |
const SparseVector< double > & | x | |||
) | const [inline, virtual] |
Multiplication with a SparseVector<double>.
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.
References col_ptr, cols_, SparseVector< Type >::dim(), SparseVector< Type >::head, row_ind, rows_, SparseVector< Type >::set(), and val.
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.
References col_ptr, cols_, UserVector< Type >::dim(), row_ind, rows_, and val.
Reimplemented in SparseMatrix2.
Definition at line 1364 of file usermatrix.h.
References col_ptr, cols_, DenseVector< Type >::dim(), row_ind, rows_, and val.
virtual double SparseMatrix::xAx | ( | const UserVector< double > & | x | ) | const [inline, virtual] |
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>.
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.
References col_ptr, cols_, UserVector< Type >::dim(), row_ind, rows_, and val.
Referenced by SparseMatrix2::AddMult().
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.
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.
Referenced by SparseMatrix2::print().
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.
Referenced by AddElement(), AddToElement(), and nonzeros().
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.
Referenced by nonzeros(), and SparseMatrix().
double* SparseMatrix::val [protected] |
The values of the matrix.
size=nz.
Definition at line 1064 of file usermatrix.h.
Referenced by AddElement(), AddMult(), AddToElement(), GetVal(), MultV(), operator()(), SparseMatrix(), xAx(), yAx(), and ~SparseMatrix().
int* SparseMatrix::row_ind [protected] |
The row indices of the values.
size=nz.
Definition at line 1068 of file usermatrix.h.
Referenced by AddMult(), GetRowInd(), MultV(), operator()(), SparseMatrix(), xAx(), yAx(), and ~SparseMatrix().
int* SparseMatrix::col_ptr [protected] |
The indices of the starting columns.
size=dim()+1.
Definition at line 1072 of file usermatrix.h.
Referenced by AddMult(), GetColPtr(), MultV(), operator()(), SparseMatrix(), xAx(), yAx(), and ~SparseMatrix().
int SparseMatrix::rows_ [protected] |
The number of rows and columns.
Definition at line 1076 of file usermatrix.h.
Referenced by AddElement(), AddMult(), AddToElement(), MultV(), operator+=(), rows(), SparseMatrix(), xAx(), and yAx().
int SparseMatrix::cols_ [protected] |
Definition at line 1076 of file usermatrix.h.
Referenced by AddElement(), AddMult(), AddToElement(), cols(), MultV(), operator+=(), SparseMatrix(), xAx(), and yAx().