Interfaces matrix-vector operations tailored to general sparse matrices. More...
#include <Matrices.hpp>
Public Member Functions | |
virtual returnValue | addToDiag (real_t alpha) |
long * | createDiagInfo () |
virtual real_t | diag (int i) const |
virtual Matrix * | duplicate () const |
virtual void | free () |
real_t * | full () const |
virtual returnValue | getCol (int cNum, const Indexlist *const irows, real_t alpha, real_t *col) const |
virtual returnValue | getRow (int rNum, const Indexlist *const icols, real_t alpha, real_t *row) const |
virtual BooleanType | isDiag () const |
virtual returnValue | print () const |
SparseMatrix () | |
SparseMatrix (long nr, long nc, long *r, long *c, real_t *v, long *d=0) | |
SparseMatrix (int nr, int nc, int ld, const real_t *const v) | |
virtual returnValue | times (int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const |
virtual returnValue | times (const Indexlist *const irows, const Indexlist *const icols, int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD, BooleanType yCompr=BT_TRUE) const |
virtual returnValue | transTimes (int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const |
virtual returnValue | transTimes (const Indexlist *const irows, const Indexlist *const icols, int xN, real_t alpha, const real_t *x, int xLD, real_t beta, real_t *y, int yLD) const |
virtual | ~SparseMatrix () |
Protected Attributes | |
long * | ir |
long * | jc |
long * | jd |
long | nCols |
long | nRows |
real_t * | val |
Interfaces matrix-vector operations tailored to general sparse matrices.
Sparse matrix class (column compressed format).
Definition at line 443 of file Matrices.hpp.
Default constructor.
Definition at line 485 of file Matrices.cpp.
SparseMatrix::SparseMatrix | ( | long | nr, |
long | nc, | ||
long * | r, | ||
long * | c, | ||
real_t * | v, | ||
long * | d = 0 |
||
) |
Constructor with arguments.
nr | Number of rows. |
nc | Number of columns. |
r | Row indices (length). |
c | Indices to first entry of columns (nCols+1). |
v | Vector of entries (length). |
d | Indices to first entry of lower triangle (including diagonal) (nCols). |
Definition at line 487 of file Matrices.cpp.
SparseMatrix::SparseMatrix | ( | int | nr, |
int | nc, | ||
int | ld, | ||
const real_t *const | v | ||
) |
Constructor from dense matrix.
nr | Number of rows. |
nc | Number of columns. |
ld | Leading dimension. |
v | Row major stored matrix elements. |
Definition at line 490 of file Matrices.cpp.
SparseMatrix::~SparseMatrix | ( | ) | [virtual] |
Destructor.
Definition at line 514 of file Matrices.cpp.
returnValue SparseMatrix::addToDiag | ( | real_t | alpha | ) | [virtual] |
Adds given offset to diagonal of matrix.
alpha | Diagonal offset. |
Implements Matrix.
Definition at line 1031 of file Matrices.cpp.
long * SparseMatrix::createDiagInfo | ( | ) |
Create jd field from ir and jc.
Definition at line 1045 of file Matrices.cpp.
real_t SparseMatrix::diag | ( | int | i | ) | const [virtual] |
Returns i-th diagonal entry.
i | Index. |
Implements Matrix.
Definition at line 555 of file Matrices.cpp.
Matrix * SparseMatrix::duplicate | ( | ) | const [virtual] |
Returns a deep-copy of the Matrix object.
Implements Matrix.
Reimplemented in SymSparseMat.
Definition at line 533 of file Matrices.cpp.
void SparseMatrix::free | ( | ) | [virtual] |
real_t * SparseMatrix::full | ( | ) | const |
Allocate and create dense matrix in row major format.
Definition at line 1062 of file Matrices.cpp.
returnValue SparseMatrix::getCol | ( | int | cNum, |
const Indexlist *const | irows, | ||
real_t | alpha, | ||
real_t * | col | ||
) | const [virtual] |
Retrieve indexed entries of matrix column multiplied by alpha.
cNum | Column number. |
irows | Index list specifying rows. |
alpha | Scalar factor. |
col | Output column vector. |
Implements Matrix.
Definition at line 618 of file Matrices.cpp.
returnValue SparseMatrix::getRow | ( | int | rNum, |
const Indexlist *const | icols, | ||
real_t | alpha, | ||
real_t * | row | ||
) | const [virtual] |
Retrieve indexed entries of matrix row multiplied by alpha.
rNum | Row number. |
icols | Index list specifying columns. |
alpha | Scalar factor. |
row | Output row vector. |
Implements Matrix.
Definition at line 566 of file Matrices.cpp.
BooleanType SparseMatrix::isDiag | ( | ) | const [virtual] |
Checks whether matrix is square and diagonal.
Implements Matrix.
Definition at line 561 of file Matrices.cpp.
returnValue SparseMatrix::print | ( | ) | const [virtual] |
Prints matrix to screen.
Implements Matrix.
Definition at line 1078 of file Matrices.cpp.
returnValue SparseMatrix::times | ( | int | xN, |
real_t | alpha, | ||
const real_t * | x, | ||
int | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int | yLD | ||
) | const [virtual] |
Evaluate Y=alpha*A*X + beta*Y.
xN | Number of vectors to multiply. |
alpha | Scalar factor for matrix vector product. |
x | Input vector to be multiplied. |
xLD | Leading dimension of input x. |
beta | Scalar factor for y. |
y | Output vector of results. |
yLD | Leading dimension of output y. |
Implements Matrix.
Definition at line 656 of file Matrices.cpp.
returnValue SparseMatrix::times | ( | const Indexlist *const | irows, |
const Indexlist *const | icols, | ||
int | xN, | ||
real_t | alpha, | ||
const real_t * | x, | ||
int | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int | yLD, | ||
BooleanType | yCompr = BT_TRUE |
||
) | const [virtual] |
Evaluate matrix vector product with submatrix given by Indexlist.
irows | Index list specifying rows. |
icols | Index list specifying columns. |
xN | Number of vectors to multiply. |
alpha | Scalar factor for matrix vector product. |
x | Input vector to be multiplied. |
xLD | Leading dimension of input x. |
beta | Scalar factor for y. |
y | Output vector of results. |
yLD | Leading dimension of output y. |
yCompr | Compressed storage for y. |
Implements Matrix.
Definition at line 730 of file Matrices.cpp.
returnValue SparseMatrix::transTimes | ( | int | xN, |
real_t | alpha, | ||
const real_t * | x, | ||
int | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int | yLD | ||
) | const [virtual] |
Evaluate Y=alpha*A'*X + beta*Y.
xN | Number of vectors to multiply. |
alpha | Scalar factor for matrix vector product. |
x | Input vector to be multiplied. |
xLD | Leading dimension of input x. |
beta | Scalar factor for y. |
y | Output vector of results. |
yLD | Leading dimension of output y. |
Implements Matrix.
Definition at line 693 of file Matrices.cpp.
returnValue SparseMatrix::transTimes | ( | const Indexlist *const | irows, |
const Indexlist *const | icols, | ||
int | xN, | ||
real_t | alpha, | ||
const real_t * | x, | ||
int | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int | yLD | ||
) | const [virtual] |
Evaluate matrix transpose vector product.
irows | Index list specifying rows. |
icols | Index list specifying columns. |
xN | Number of vectors to multiply. |
alpha | Scalar factor for matrix vector product. |
x | Input vector to be multiplied. |
xLD | Leading dimension of input x. |
beta | Scalar factor for y. |
y | Output vector of results. |
yLD | Leading dimension of output y. |
Implements Matrix.
Definition at line 961 of file Matrices.cpp.
long* SparseMatrix::ir [protected] |
Row indices (length).
Definition at line 570 of file Matrices.hpp.
long* SparseMatrix::jc [protected] |
Indices to first entry of columns (nCols+1).
Definition at line 571 of file Matrices.hpp.
long* SparseMatrix::jd [protected] |
Indices to first entry of lower triangle (including diagonal) (nCols).
Definition at line 572 of file Matrices.hpp.
long SparseMatrix::nCols [protected] |
Number of columns.
Definition at line 569 of file Matrices.hpp.
long SparseMatrix::nRows [protected] |
Number of rows.
Definition at line 568 of file Matrices.hpp.
real_t* SparseMatrix::val [protected] |
Vector of entries (length).
Definition at line 573 of file Matrices.hpp.