qpOASES
3.1.1
|
Interfaces matrix-vector operations tailored to general sparse matrices. More...
#include <Matrices.hpp>
Public Member Functions | |
SparseMatrix () | |
SparseMatrix (int nr, int nc, sparse_int_t *r, sparse_int_t *c, real_t *v) | |
SparseMatrix (int nr, int nc, int ld, const real_t *const v) | |
virtual | ~SparseMatrix () |
virtual void | free () |
virtual Matrix * | duplicate () 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_t * | createDiagInfo () |
virtual real_t * | full () const |
virtual returnValue | print (const char *name=0) const |
BooleanType | needToFreeMemory () const |
void | doFreeMemory () |
void | doNotFreeMemory () |
Protected Attributes | |
int | nRows |
int | nCols |
sparse_int_t * | ir |
sparse_int_t * | jc |
sparse_int_t * | jd |
real_t * | val |
BooleanType | freeMemory |
Sparse matrix class (col compressed format).
Default constructor.
Referenced by duplicate().
SparseMatrix::SparseMatrix | ( | int | nr, |
int | nc, | ||
sparse_int_t * | r, | ||
sparse_int_t * | c, | ||
real_t * | v | ||
) |
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). |
References Matrix::doNotFreeMemory().
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. |
References BT_FALSE, Matrix::doFreeMemory(), ir, isZero(), jc, nCols, nRows, real_t, sparse_int_t, and val.
SparseMatrix::~SparseMatrix | ( | ) | [virtual] |
Destructor.
References BT_TRUE, free(), jd, and Matrix::needToFreeMemory().
returnValue SparseMatrix::addToDiag | ( | real_t | alpha | ) | [virtual] |
Adds given offset to diagonal of matrix.
alpha | Diagonal offset. |
Implements Matrix.
References BT_FALSE, ir, isZero(), jd, nCols, nRows, RET_DIAGONAL_NOT_INITIALISED, RET_NO_DIAGONAL_AVAILABLE, SUCCESSFUL_RETURN, THROWERROR, and val.
Create jd field from ir and jc.
References ir, jc, jd, nCols, and sparse_int_t.
Referenced by QProblemB::createDiagSparseMat(), main(), and solveOQPbenchmark().
real_t SparseMatrix::diag | ( | int | i | ) | const [virtual] |
Returns i-th diagonal entry.
i | Index. |
Implements Matrix.
References INFTY, ir, jc, jd, RET_DIAGONAL_NOT_INITIALISED, THROWERROR, and val.
void Matrix::doFreeMemory | ( | ) | [inline, inherited] |
Enables de-allocation of internal memory.
References BT_TRUE, and Matrix::freeMemory.
Referenced by QProblemB::createDiagSparseMat(), DenseMatrix::duplicate(), duplicate(), SparseMatrixRow::duplicate(), SymDenseMat::duplicateSym(), SymSparseMat::duplicateSym(), QProblemB::setupQPdataFromFile(), QProblem::setupQPdataFromFile(), solveOQPbenchmark(), SparseMatrix(), and SparseMatrixRow::SparseMatrixRow().
void Matrix::doNotFreeMemory | ( | ) | [inline, inherited] |
Disables de-allocation of internal memory.
Referenced by free(), SparseMatrixRow::free(), Matrix::Matrix(), SparseMatrix(), and SparseMatrixRow::SparseMatrixRow().
Matrix * SparseMatrix::duplicate | ( | ) | const [virtual] |
Returns a deep-copy of the Matrix object.
Implements Matrix.
Reimplemented in SymSparseMat.
References Matrix::doFreeMemory(), ir, jc, jd, nCols, nRows, real_t, sparse_int_t, SparseMatrix(), and val.
void SparseMatrix::free | ( | ) | [virtual] |
Frees all internal memory.
Implements Matrix.
References Matrix::doNotFreeMemory(), ir, jc, and val.
Referenced by ~SparseMatrix().
real_t * SparseMatrix::full | ( | ) | const [virtual] |
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.
References BT_TRUE, ir, isEqual(), Indexlist::iSort, jc, Indexlist::number, SUCCESSFUL_RETURN, and val.
real_t SparseMatrix::getNorm | ( | int | type = 2 | ) | const [virtual] |
Get the N-norm of the matrix
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References jc, nCols, REFER_NAMESPACE_QPOASES, and val.
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.
References BT_TRUE, ir, isEqual(), Indexlist::iSort, jc, Indexlist::length, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.
real_t SparseMatrix::getRowNorm | ( | int | rNum, |
int | type = 2 |
||
) | const [virtual] |
Get the N-norm of a row
rNum | Row number. |
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References getAbs(), getSqrt(), INFTY, ir, jc, nCols, real_t, REFER_NAMESPACE_QPOASES, RET_INVALID_ARGUMENTS, THROWERROR, and val.
BooleanType SparseMatrix::isDiag | ( | ) | const [virtual] |
BooleanType Matrix::needToFreeMemory | ( | ) | const [inline, inherited] |
Returns whether internal memory needs to be de-allocated.
References Matrix::freeMemory.
Referenced by DenseMatrix::duplicate(), SymDenseMat::duplicateSym(), DenseMatrix::~DenseMatrix(), ~SparseMatrix(), and SparseMatrixRow::~SparseMatrixRow().
returnValue SparseMatrix::print | ( | const char * | name = 0 | ) | const [virtual] |
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.
References BT_FALSE, BT_TRUE, ir, isEqual(), isZero(), jc, nCols, nRows, SUCCESSFUL_RETURN, and 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] |
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.
References BT_FALSE, BT_TRUE, ir, isEqual(), Indexlist::iSort, isZero(), jc, Indexlist::length, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.
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.
References BT_FALSE, BT_TRUE, ir, isEqual(), isZero(), jc, nCols, SUCCESSFUL_RETURN, and 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] |
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.
References BT_FALSE, BT_TRUE, ir, isEqual(), Indexlist::iSort, isZero(), jc, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and val.
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] |
Row indices (length).
Referenced by addToDiag(), SymSparseMat::bilinear(), createDiagInfo(), diag(), duplicate(), SymSparseMat::duplicateSym(), free(), full(), getCol(), getRow(), getRowNorm(), isDiag(), SparseMatrix(), times(), and transTimes().
sparse_int_t* SparseMatrix::jc [protected] |
Indices to first entry of columns (nCols+1).
Referenced by SymSparseMat::bilinear(), createDiagInfo(), diag(), duplicate(), SymSparseMat::duplicateSym(), free(), full(), getCol(), getNorm(), getRow(), getRowNorm(), isDiag(), SparseMatrix(), times(), and transTimes().
sparse_int_t* SparseMatrix::jd [protected] |
Indices to first entry of lower triangle (including diagonal) (nCols).
Referenced by addToDiag(), SymSparseMat::bilinear(), createDiagInfo(), diag(), duplicate(), SymSparseMat::duplicateSym(), and ~SparseMatrix().
int SparseMatrix::nCols [protected] |
Number of columns.
Referenced by addToDiag(), createDiagInfo(), duplicate(), SymSparseMat::duplicateSym(), full(), getNorm(), getRow(), getRowNorm(), isDiag(), print(), SparseMatrix(), times(), and transTimes().
int SparseMatrix::nRows [protected] |
Number of rows.
Referenced by addToDiag(), duplicate(), SymSparseMat::duplicateSym(), full(), isDiag(), print(), SparseMatrix(), and times().
real_t* SparseMatrix::val [protected] |
Vector of entries (length).
Referenced by addToDiag(), SymSparseMat::bilinear(), diag(), duplicate(), SymSparseMat::duplicateSym(), free(), full(), getCol(), getNorm(), getRow(), getRowNorm(), SparseMatrix(), times(), and transTimes().