qpOASES  3.0.1
Public Member Functions | Protected Attributes
SymSparseMat Class Reference

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

#include <Matrices.hpp>

Inheritance diagram for SymSparseMat:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Protected Attributes

BooleanType freeMemory
int nRows
int nCols
sparse_int_tir
sparse_int_tjc
sparse_int_tjd
real_tval

Detailed Description

Symmetric sparse matrix class (column compressed format).

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

Constructor & Destructor Documentation

Default constructor.

Referenced by duplicateSym().

SymSparseMat::SymSparseMat ( int  nr,
int  nc,
sparse_int_t r,
sparse_int_t c,
real_t v 
) [inline]

Constructor with arguments.

Parameters:
nrNumber of rows.
ncNumber of columns.
rRow indices (length).
cIndices to first entry of columns (nCols+1).
vVector of entries (length).
SymSparseMat::SymSparseMat ( int  nr,
int  nc,
int  ld,
const real_t *const  v 
) [inline]

Constructor from dense matrix.

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

Member Function Documentation

virtual returnValue Matrix::addToDiag ( real_t  alpha) [pure virtual, inherited]

Adds given offset to diagonal of matrix.

Returns:
SUCCESSFUL_RETURN
RET_NO_DIAGONAL_AVAILABLE
Parameters:
alphaDiagonal offset.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblemB::regulariseHessian().

returnValue SparseMatrix::addToDiag ( real_t  alpha) [virtual, inherited]

Adds given offset to diagonal of matrix.

Returns:
SUCCESSFUL_RETURN
RET_NO_DIAGONAL_AVAILABLE
Parameters:
alphaDiagonal offset.

Implements Matrix.

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

returnValue SymSparseMat::bilinear ( const Indexlist *const  icols,
int  xN,
const real_t x,
int  xLD,
real_t y,
int  yLD 
) const [virtual]

Compute bilinear form y = x'*H*x using submatrix given by index list.

Returns:
SUCCESSFUL_RETURN
Parameters:
icolsIndex list specifying columns of x.
xNNumber of vectors to multiply.
xInput vector to be multiplied (uncompressed).
xLDLeading dimension of input x.
yOutput vector of results (compressed).
yLDLeading dimension of output y.

Implements SymmetricMatrix.

References SparseMatrix::ir, Indexlist::iSort, SparseMatrix::jc, SparseMatrix::jd, Indexlist::length, Indexlist::number, RET_DIAGONAL_NOT_INITIALISED, SUCCESSFUL_RETURN, THROWERROR, and SparseMatrix::val.

Referenced by QProblem::computeProjectedCholesky().

Create jd field from ir and jc.

Returns:
Pointer to jd.

References SparseMatrix::ir, SparseMatrix::jc, SparseMatrix::jd, SparseMatrix::nCols, and sparse_int_t.

Referenced by QProblemB::createDiagSparseMat(), main(), and solveOQPbenchmark().

virtual real_t Matrix::diag ( int  i) const [pure virtual, inherited]

Returns i-th diagonal entry.

Returns:
i-th diagonal entry
Parameters:
iIndex.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblemB::determineHessianType(), QProblem::removeBound(), and QProblemB::removeBound().

real_t SparseMatrix::diag ( int  i) const [virtual, inherited]

Returns i-th diagonal entry.

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

Implements Matrix.

References INFTY, SparseMatrix::ir, SparseMatrix::jc, SparseMatrix::jd, RET_DIAGONAL_NOT_INITIALISED, THROWERROR, and SparseMatrix::val.

void Matrix::doFreeMemory ( ) [inline, inherited]
void Matrix::doNotFreeMemory ( ) [inline, inherited]
Matrix * SymSparseMat::duplicate ( ) const [virtual]

Returns a deep-copy of the Matrix object.

Returns:
Deep-copy of Matrix object

Reimplemented from SparseMatrix.

References duplicateSym().

virtual void Matrix::free ( ) [pure virtual, inherited]

Frees all internal memory.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

void SparseMatrix::free ( ) [virtual, inherited]

Frees all internal memory.

Implements Matrix.

References Matrix::doNotFreeMemory(), SparseMatrix::ir, SparseMatrix::jc, and SparseMatrix::val.

Referenced by SparseMatrix::~SparseMatrix().

virtual real_t* Matrix::full ( ) const [pure virtual, inherited]

Allocates and creates dense matrix array in row major format.

Note: Calling function has to free allocated memory!

Returns:
Pointer to matrix array.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblem::writeQpDataIntoMatFile().

real_t * SparseMatrix::full ( ) const [virtual, inherited]

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 SparseMatrix::ir, SparseMatrix::jc, SparseMatrix::nCols, SparseMatrix::nRows, real_t, and SparseMatrix::val.

Referenced by main(), and SparseMatrix::print().

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

Retrieve indexed entries of matrix column multiplied by alpha.

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

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblemB::computeCholesky(), QProblem::computeProjectedCholesky(), and QProblem::removeBound().

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

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, SparseMatrix::ir, isEqual(), Indexlist::iSort, SparseMatrix::jc, Indexlist::number, SUCCESSFUL_RETURN, and SparseMatrix::val.

virtual real_t Matrix::getNorm ( int  type = 2) const [pure virtual, inherited]

Get the N-norm of the matrix

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

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblemB::regulariseHessian().

real_t SparseMatrix::getNorm ( int  type = 2) const [virtual, inherited]

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 SparseMatrix::jc, SparseMatrix::nCols, REFER_NAMESPACE_QPOASES, and SparseMatrix::val.

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

Retrieve indexed entries of matrix row multiplied by alpha.

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

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblem::addConstraint(), QProblem::addConstraint_checkLI(), QProblem::addConstraint_ensureLI(), and QProblemB::removeBound().

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

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, SparseMatrix::ir, isEqual(), Indexlist::iSort, SparseMatrix::jc, Indexlist::length, SparseMatrix::nCols, Indexlist::number, SUCCESSFUL_RETURN, and SparseMatrix::val.

virtual real_t Matrix::getRowNorm ( int  rNum,
int  type = 2 
) const [pure virtual, inherited]

Get the N-norm of a row

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

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblem::setA().

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

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 getAbs(), getSqrt(), INFTY, SparseMatrix::ir, SparseMatrix::jc, SparseMatrix::nCols, real_t, REFER_NAMESPACE_QPOASES, RET_INVALID_ARGUMENTS, THROWERROR, and SparseMatrix::val.

virtual BooleanType Matrix::isDiag ( ) const [pure virtual, inherited]

Checks whether matrix is square and diagonal.

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

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblemB::determineHessianType().

BooleanType SparseMatrix::isDiag ( ) const [virtual, inherited]

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, SparseMatrix::ir, SparseMatrix::jc, SparseMatrix::nCols, and SparseMatrix::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::~SparseMatrixRow().

virtual returnValue Matrix::print ( const char *  name = 0) const [pure virtual, inherited]

Prints matrix to screen.

Returns:
SUCCESSFUL_RETURN
Parameters:
nameName of matrix.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

returnValue SparseMatrix::print ( const char *  name = 0) const [virtual, inherited]

Prints matrix to screen.

Returns:
SUCCESSFUL_RETURN
Parameters:
nameName of matrix.

Implements Matrix.

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

virtual returnValue Matrix::times ( int  xN,
real_t  alpha,
const real_t x,
int  xLD,
real_t  beta,
real_t y,
int  yLD 
) const [pure virtual, inherited]

Evaluate Y=alpha*A*X + beta*Y.

Returns:
SUCCESSFUL_RETURN
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.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblem::determineStepDirection(), QProblemB::determineStepDirection(), QProblem::ensureNonzeroCurvature(), SolutionAnalysis::getMaxKKTviolation(), QProblemB::getObjVal(), QProblem::performStep(), QProblemB::printIteration(), QProblem::printIteration(), QProblem::removeBound(), QProblem::removeConstraint(), QProblem::setA(), QProblem::setupAuxiliaryQP(), QProblem::setupAuxiliaryQPgradient(), QProblemB::setupAuxiliaryQPgradient(), and QProblem::setupAuxiliaryQPsolution().

virtual returnValue Matrix::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 [pure virtual, inherited]

Evaluate matrix vector product with submatrix given by Indexlist.

Returns:
SUCCESSFUL_RETURN
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.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

returnValue SparseMatrix::times ( int  xN,
real_t  alpha,
const real_t x,
int  xLD,
real_t  beta,
real_t y,
int  yLD 
) const [virtual, inherited]

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, SparseMatrix::ir, isEqual(), isZero(), SparseMatrix::jc, SparseMatrix::nCols, SparseMatrix::nRows, SUCCESSFUL_RETURN, and SparseMatrix::val.

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, inherited]

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, SparseMatrix::ir, isEqual(), Indexlist::iSort, isZero(), SparseMatrix::jc, Indexlist::length, SparseMatrix::nCols, Indexlist::number, SUCCESSFUL_RETURN, and SparseMatrix::val.

virtual returnValue Matrix::transTimes ( int  xN,
real_t  alpha,
const real_t x,
int  xLD,
real_t  beta,
real_t y,
int  yLD 
) const [pure virtual, inherited]

Evaluate Y=alpha*A'*X + beta*Y.

Returns:
SUCCESSFUL_RETURN
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.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

Referenced by QProblem::addBound_ensureLI(), QProblem::addConstraint_ensureLI(), QProblem::determineStepDirection(), SolutionAnalysis::getMaxKKTviolation(), QProblem::printIteration(), and QProblem::setupAuxiliaryQPgradient().

virtual returnValue Matrix::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 [pure virtual, inherited]

Evaluate matrix transpose vector product.

Returns:
SUCCESSFUL_RETURN
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.

Implemented in SparseMatrixRow, SparseMatrix, and DenseMatrix.

returnValue SparseMatrix::transTimes ( int  xN,
real_t  alpha,
const real_t x,
int  xLD,
real_t  beta,
real_t y,
int  yLD 
) const [virtual, inherited]

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, SparseMatrix::ir, isEqual(), isZero(), SparseMatrix::jc, SparseMatrix::nCols, SUCCESSFUL_RETURN, and SparseMatrix::val.

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, inherited]

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, SparseMatrix::ir, isEqual(), Indexlist::iSort, isZero(), SparseMatrix::jc, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and SparseMatrix::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().

sparse_int_t* SparseMatrix::ir [protected, inherited]
sparse_int_t* SparseMatrix::jc [protected, inherited]
sparse_int_t* SparseMatrix::jd [protected, inherited]

Indices to first entry of lower triangle (including diagonal) (nCols).

Referenced by SparseMatrix::addToDiag(), bilinear(), SparseMatrix::createDiagInfo(), SparseMatrix::diag(), SparseMatrix::duplicate(), duplicateSym(), and SparseMatrix::~SparseMatrix().

int SparseMatrix::nCols [protected, inherited]
int SparseMatrix::nRows [protected, inherited]
real_t* SparseMatrix::val [protected, inherited]

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