qpOASES  3.0.1
Public Member Functions | Protected Attributes
SparseMatrixRow Class Reference

Interfaces matrix-vector operations tailored to general sparse matrices. More...

#include <Matrices.hpp>

Inheritance diagram for SparseMatrixRow:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 SparseMatrixRow ()
 SparseMatrixRow (int nr, int nc, sparse_int_t *r, sparse_int_t *c, real_t *v)
 SparseMatrixRow (int nr, int nc, int ld, const real_t *const v)
virtual ~SparseMatrixRow ()
virtual void free ()
virtual Matrixduplicate () const
virtual real_t diag (int i) const
virtual BooleanType isDiag () const
virtual real_t getNorm (int type=2) const
virtual real_t getRowNorm (int rNum, int type=2) const
virtual returnValue getRow (int rNum, const Indexlist *const icols, real_t alpha, real_t *row) const
virtual returnValue getCol (int cNum, const Indexlist *const irows, real_t alpha, real_t *col) const
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 transTimes (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 (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 returnValue addToDiag (real_t alpha)
sparse_int_tcreateDiagInfo ()
virtual real_tfull () const
virtual returnValue print (const char *name=0) const
BooleanType needToFreeMemory () const
void doFreeMemory ()
void doNotFreeMemory ()

Protected Attributes

int nRows
int nCols
sparse_int_tjr
sparse_int_tic
sparse_int_tjd
real_tval
BooleanType freeMemory

Detailed Description

Sparse matrix class (row compressed format).

Author:
Andreas Potschka, Christian Kirches, Hans Joachim Ferreau
Version:
3.0
Date:
2011-2014

Constructor & Destructor Documentation

Default constructor.

Referenced by duplicate().

SparseMatrixRow::SparseMatrixRow ( int  nr,
int  nc,
sparse_int_t r,
sparse_int_t c,
real_t v 
)

Constructor with arguments.

Parameters:
nrNumber of rows.
ncNumber of columns.
rIndices to first entry of rows (nRows+1).
cColumn indices (length).
vVector of entries (length).

References Matrix::doNotFreeMemory().

SparseMatrixRow::SparseMatrixRow ( int  nr,
int  nc,
int  ld,
const real_t *const  v 
)

Constructor from dense matrix.

Parameters:
nrNumber of rows.
ncNumber of columns.
ldLeading dimension.
vRow major stored matrix elements.

References BT_FALSE, Matrix::doFreeMemory(), ic, isZero(), jr, nCols, nRows, real_t, sparse_int_t, and val.

Destructor.

References BT_TRUE, free(), jd, and Matrix::needToFreeMemory().


Member Function Documentation

Adds given offset to diagonal of matrix.

Returns:
SUCCESSFUL_RETURN
RET_NO_DIAGONAL_AVAILABLE
Parameters:
alphaDiagonal offset.

Implements Matrix.

References BT_FALSE, ic, isZero(), jd, nCols, nRows, RET_DIAGONAL_NOT_INITIALISED, RET_NO_DIAGONAL_AVAILABLE, SUCCESSFUL_RETURN, THROWERROR, and val.

Create jd field from ir and jc.

Returns:
Pointer to jd.

References ic, jd, jr, nRows, and sparse_int_t.

real_t SparseMatrixRow::diag ( int  i) const [virtual]

Returns i-th diagonal entry.

Returns:
i-th diagonal entry (or INFTY if diagonal does not exist)
Parameters:
iIndex.

Implements Matrix.

References ic, INFTY, jd, jr, RET_DIAGONAL_NOT_INITIALISED, THROWERROR, and val.

void Matrix::doFreeMemory ( ) [inline, inherited]
void Matrix::doNotFreeMemory ( ) [inline, inherited]

Disables de-allocation of internal memory.

Referenced by SparseMatrix::free(), free(), Matrix::Matrix(), SparseMatrix::SparseMatrix(), and SparseMatrixRow().

Matrix * SparseMatrixRow::duplicate ( ) const [virtual]

Returns a deep-copy of the Matrix object.

Returns:
Deep-copy of Matrix object

Implements Matrix.

References Matrix::doFreeMemory(), ic, jd, jr, nCols, nRows, real_t, sparse_int_t, SparseMatrixRow(), and val.

void SparseMatrixRow::free ( ) [virtual]

Frees all internal memory.

Implements Matrix.

References Matrix::doNotFreeMemory(), ic, jr, and val.

Referenced by ~SparseMatrixRow().

real_t * SparseMatrixRow::full ( ) const [virtual]

Allocates and creates dense matrix array in row major format.

Note: Calling function has to free allocated memory!

Returns:
Pointer to matrix array.

Implements Matrix.

References ic, jr, nCols, nRows, real_t, and val.

Referenced by print().

returnValue SparseMatrixRow::getCol ( int  cNum,
const Indexlist *const  irows,
real_t  alpha,
real_t col 
) const [virtual]

Retrieve indexed entries of matrix column multiplied by alpha.

Parameters:
cNumColumn number.
irowsIndex list specifying rows.
alphaScalar factor.
colOutput column vector.

Implements Matrix.

References BT_TRUE, ic, isEqual(), Indexlist::iSort, jr, Indexlist::length, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.

real_t SparseMatrixRow::getNorm ( int  type = 2) const [virtual]

Get the N-norm of the matrix

Returns:
N-norm of the matrix
Parameters:
typeNorm type, 1: one-norm, 2: Euclidean norm.

Implements Matrix.

References jr, nRows, REFER_NAMESPACE_QPOASES, and val.

Referenced by getRowNorm().

returnValue SparseMatrixRow::getRow ( int  rNum,
const Indexlist *const  icols,
real_t  alpha,
real_t row 
) const [virtual]

Retrieve indexed entries of matrix row multiplied by alpha.

Parameters:
rNumRow number.
icolsIndex list specifying columns.
alphaScalar factor.
rowOutput row vector.

Implements Matrix.

References BT_TRUE, ic, isEqual(), Indexlist::iSort, jr, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.

real_t SparseMatrixRow::getRowNorm ( int  rNum,
int  type = 2 
) const [virtual]

Get the N-norm of a row

Returns:
N-norm of row rNum
Parameters:
rNumRow number.
typeNorm type, 1: one-norm, 2: Euclidean norm.

Implements Matrix.

References getNorm(), jr, REFER_NAMESPACE_QPOASES, and val.

BooleanType SparseMatrixRow::isDiag ( ) const [virtual]

Checks whether matrix is square and diagonal.

Returns:
BT_TRUE iff matrix is square and diagonal;
BT_FALSE otherwise.

Implements Matrix.

References BT_FALSE, BT_TRUE, ic, jr, nCols, and nRows.

BooleanType Matrix::needToFreeMemory ( ) const [inline, inherited]

Returns whether internal memory needs to be de-allocated.

Returns:
BT_TRUE iff internal memory needs to be de-allocated,
BT_FALSE otherwise

References Matrix::freeMemory.

Referenced by DenseMatrix::duplicate(), SymDenseMat::duplicateSym(), DenseMatrix::~DenseMatrix(), SparseMatrix::~SparseMatrix(), and ~SparseMatrixRow().

returnValue SparseMatrixRow::print ( const char *  name = 0) const [virtual]

Prints matrix to screen.

Returns:
SUCCESSFUL_RETURN
Parameters:
nameName of matrix.

Implements Matrix.

References full(), nCols, nRows, real_t, and REFER_NAMESPACE_QPOASES.

returnValue SparseMatrixRow::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.

Parameters:
xNNumber of vectors to multiply.
alphaScalar factor for matrix vector product.
xInput vector to be multiplied.
xLDLeading dimension of input x.
betaScalar factor for y.
yOutput vector of results.
yLDLeading dimension of output y.

Implements Matrix.

References BT_FALSE, BT_TRUE, ic, isEqual(), isZero(), jr, nRows, SUCCESSFUL_RETURN, and val.

returnValue SparseMatrixRow::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.

Parameters:
irowsIndex list specifying rows.
icolsIndex list specifying columns.
xNNumber of vectors to multiply.
alphaScalar factor for matrix vector product.
xInput vector to be multiplied.
xLDLeading dimension of input x.
betaScalar factor for y.
yOutput vector of results.
yLDLeading dimension of output y.
yComprCompressed storage for y.

Implements Matrix.

References BT_FALSE, BT_TRUE, ic, isEqual(), Indexlist::iSort, isZero(), jr, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and val.

returnValue SparseMatrixRow::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.

Parameters:
xNNumber of vectors to multiply.
alphaScalar factor for matrix vector product.
xInput vector to be multiplied.
xLDLeading dimension of input x.
betaScalar factor for y.
yOutput vector of results.
yLDLeading dimension of output y.

Implements Matrix.

References BT_FALSE, BT_TRUE, ic, isEqual(), isZero(), jr, nCols, nRows, SUCCESSFUL_RETURN, and val.

returnValue SparseMatrixRow::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.

Parameters:
irowsIndex list specifying rows.
icolsIndex list specifying columns.
xNNumber of vectors to multiply.
alphaScalar factor for matrix vector product.
xInput vector to be multiplied.
xLDLeading dimension of input x.
betaScalar factor for y.
yOutput vector of results.
yLDLeading dimension of output y.

Implements Matrix.

References BT_FALSE, BT_TRUE, ic, isEqual(), Indexlist::iSort, isZero(), jr, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and val.


Member Data Documentation

BooleanType Matrix::freeMemory [protected, inherited]

Indicating whether internal memory needs to be de-allocated.

Referenced by Matrix::doFreeMemory(), and Matrix::needToFreeMemory().

Indices to first entry of upper triangle (including diagonal) (nRows).

Referenced by addToDiag(), createDiagInfo(), diag(), duplicate(), and ~SparseMatrixRow().

Indices to first entry of row (nRows+1).

Referenced by createDiagInfo(), diag(), duplicate(), free(), full(), getCol(), getNorm(), getRow(), getRowNorm(), isDiag(), SparseMatrixRow(), times(), and transTimes().

int SparseMatrixRow::nCols [protected]
int SparseMatrixRow::nRows [protected]

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