qpOASES
3.2.1
An Implementation of the Online Active Set Strategy
|
Interfaces matrix-vector operations tailored to symmetric dense matrices. More...
#include <Matrices.hpp>
Public Member Functions | |
SymDenseMat () | |
SymDenseMat (int_t m, int_t n, int_t lD, real_t *v) | |
virtual | ~SymDenseMat () |
virtual Matrix * | duplicate () const |
virtual SymmetricMatrix * | duplicateSym () const |
virtual returnValue | bilinear (const Indexlist *const icols, int_t xN, const real_t *x, int_t xLD, real_t *y, int_t yLD) const |
virtual void | free () |
virtual real_t | diag (int_t i) const |
virtual BooleanType | isDiag () const |
virtual real_t | getNorm (int_t type=2) const |
virtual real_t | getRowNorm (int_t rNum, int_t type=2) const |
virtual returnValue | getRowNorm (real_t *norm, int_t type=2) const |
virtual returnValue | getRow (int_t rNum, const Indexlist *const icols, real_t alpha, real_t *row) const |
virtual returnValue | getCol (int_t cNum, const Indexlist *const irows, real_t alpha, real_t *col) const |
virtual returnValue | getSparseSubmatrix (int_t irowsLength, const int_t *const irowsNumber, int_t icolsLength, const int_t *const icolsNumber, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const |
virtual returnValue | getSparseSubmatrix (const Indexlist *const irows, const Indexlist *const icols, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const |
virtual returnValue | getSparseSubmatrix (const Indexlist *const irows, int_t idx_icol, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const |
virtual returnValue | getSparseSubmatrix (int_t idx_row, const Indexlist *const icols, int_t rowoffset, int_t coloffset, int_t &numNonzeros, int_t *irn, int_t *jcn, real_t *avals, BooleanType only_lower_triangular=BT_FALSE) const |
virtual returnValue | times (int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const |
virtual returnValue | times (const Indexlist *const irows, const Indexlist *const icols, int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD, BooleanType yCompr=BT_TRUE) const |
virtual returnValue | transTimes (int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const |
virtual returnValue | transTimes (const Indexlist *const irows, const Indexlist *const icols, int_t xN, real_t alpha, const real_t *x, int_t xLD, real_t beta, real_t *y, int_t yLD) const |
virtual returnValue | addToDiag (real_t alpha) |
virtual real_t * | full () const |
virtual returnValue | print (const char *name=0) const |
virtual returnValue | writeToFile (FILE *output_file, const char *prefix) const |
BooleanType | needToFreeMemory () const |
void | doFreeMemory () |
void | doNotFreeMemory () |
Protected Attributes | |
int_t | nRows |
int_t | nCols |
int_t | leaDim |
real_t * | val |
BooleanType | freeMemory |
Symmetric dense matrix class.
SymDenseMat::SymDenseMat | ( | ) | [inline] |
Default constructor.
Referenced by duplicateSym().
SymDenseMat::SymDenseMat | ( | int_t | m, |
int_t | n, | ||
int_t | lD, | ||
real_t * | v | ||
) | [inline] |
Constructor from vector of values.
m | Number of rows. |
n | Number of columns. |
lD | Leading dimension. |
v | Values. |
virtual SymDenseMat::~SymDenseMat | ( | ) | [inline, virtual] |
Destructor.
returnValue DenseMatrix::addToDiag | ( | real_t | alpha | ) | [virtual, inherited] |
Adds given offset to diagonal of matrix.
alpha | Diagonal offset. |
Implements Matrix.
References DenseMatrix::leaDim, DenseMatrix::nCols, DenseMatrix::nRows, SUCCESSFUL_RETURN, and DenseMatrix::val.
returnValue SymDenseMat::bilinear | ( | const Indexlist *const | icols, |
int_t | xN, | ||
const real_t * | x, | ||
int_t | xLD, | ||
real_t * | y, | ||
int_t | yLD | ||
) | const [virtual] |
Compute bilinear form y = x'*H*x using submatrix given by index list.
icols | Index list specifying columns of x. |
xN | Number of vectors to multiply. |
x | Input vector to be multiplied (uncompressed). |
xLD | Leading dimension of input x. |
y | Output vector of results (compressed). |
yLD | Leading dimension of output y. |
Implements SymmetricMatrix.
References DenseMatrix::leaDim, Indexlist::length, Indexlist::number, real_t, SUCCESSFUL_RETURN, and DenseMatrix::val.
real_t DenseMatrix::diag | ( | int_t | i | ) | const [virtual, inherited] |
Returns i-th diagonal entry.
i | Index. |
Implements Matrix.
References DenseMatrix::leaDim, and DenseMatrix::val.
void Matrix::doFreeMemory | ( | ) | [inline, inherited] |
Enables de-allocation of internal memory.
References BT_TRUE, and Matrix::freeMemory.
Referenced by QProblemB::createDiagSparseMat(), DenseMatrix::duplicate(), SparseMatrix::duplicate(), SparseMatrixRow::duplicate(), duplicateSym(), SymSparseMat::duplicateSym(), QProblemB::setupQPdataFromFile(), QProblem::setupQPdataFromFile(), solveOqpBenchmark(), SparseMatrix::SparseMatrix(), and SparseMatrixRow::SparseMatrixRow().
void Matrix::doNotFreeMemory | ( | ) | [inline, inherited] |
Disables de-allocation of internal memory.
Referenced by SparseMatrix::free(), SparseMatrixRow::free(), Matrix::Matrix(), SparseMatrix::SparseMatrix(), and SparseMatrixRow::SparseMatrixRow().
Matrix * SymDenseMat::duplicate | ( | ) | const [virtual] |
Returns a deep-copy of the Matrix object.
Reimplemented from DenseMatrix.
References duplicateSym().
SymmetricMatrix * SymDenseMat::duplicateSym | ( | ) | const [virtual] |
Returns a deep-copy of the SymmetricMatrix object.
Implements SymmetricMatrix.
References BT_TRUE, Matrix::doFreeMemory(), DenseMatrix::nCols, Matrix::needToFreeMemory(), DenseMatrix::nRows, real_t, SymDenseMat(), and DenseMatrix::val.
Referenced by duplicate().
void DenseMatrix::free | ( | ) | [virtual, inherited] |
Frees all internal memory.
Implements Matrix.
References DenseMatrix::val.
Referenced by DenseMatrix::~DenseMatrix().
real_t * DenseMatrix::full | ( | ) | const [virtual, inherited] |
Allocates and creates dense matrix array in row major format.
Note: Calling function has to free allocated memory!
Implements Matrix.
References DenseMatrix::nCols, DenseMatrix::nRows, real_t, and DenseMatrix::val.
returnValue DenseMatrix::getCol | ( | int_t | cNum, |
const Indexlist *const | irows, | ||
real_t | alpha, | ||
real_t * | col | ||
) | const [virtual, inherited] |
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, isEqual(), DenseMatrix::leaDim, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and DenseMatrix::val.
real_t DenseMatrix::getNorm | ( | int_t | type = 2 | ) | const [virtual, inherited] |
Get the N-norm of the matrix
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References DenseMatrix::nCols, DenseMatrix::nRows, REFER_NAMESPACE_QPOASES, and DenseMatrix::val.
Referenced by DenseMatrix::getRowNorm().
returnValue DenseMatrix::getRow | ( | int_t | rNum, |
const Indexlist *const | icols, | ||
real_t | alpha, | ||
real_t * | row | ||
) | const [virtual, inherited] |
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, isEqual(), DenseMatrix::leaDim, Indexlist::length, DenseMatrix::nCols, Indexlist::number, SUCCESSFUL_RETURN, and DenseMatrix::val.
real_t DenseMatrix::getRowNorm | ( | int_t | rNum, |
int_t | type = 2 |
||
) | const [virtual, inherited] |
Get the N-norm of a row
rNum | Row number. |
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References DenseMatrix::getNorm(), DenseMatrix::leaDim, DenseMatrix::nCols, REFER_NAMESPACE_QPOASES, and DenseMatrix::val.
returnValue DenseMatrix::getRowNorm | ( | real_t * | norm, |
int_t | type = 2 |
||
) | const [virtual, inherited] |
Get the N-norm of all rows
norm | Norm of each row. |
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References DenseMatrix::getNorm(), DenseMatrix::leaDim, DenseMatrix::nCols, DenseMatrix::nRows, REFER_NAMESPACE_QPOASES, SUCCESSFUL_RETURN, and DenseMatrix::val.
BEGIN_NAMESPACE_QPOASES returnValue Matrix::getSparseSubmatrix | ( | const Indexlist *const | irows, |
const Indexlist *const | icols, | ||
int_t | rowoffset, | ||
int_t | coloffset, | ||
int_t & | numNonzeros, | ||
int_t * | irn, | ||
int_t * | jcn, | ||
real_t * | avals, | ||
BooleanType | only_lower_triangular = BT_FALSE |
||
) | const [virtual, inherited] |
Retrieve entries of submatrix in Harwell-Boeing sparse format. If irn, jcn, and avals are null, this only counts the number of nonzeros. Otherwise, numNonzeros containts the size of irn, jcn, and avals on entry, and the written number of entries on return.
irows | Index list specifying rows. |
icols | Index list specifying columns. |
rowoffset | Offset for row entries. |
coloffset | Offset for row entries. |
numNonzeros | Number of nonzeros in submatrix. |
irn | Row position of entries (as position in irows) plus rowoffset. |
jcn | Column position of entries (as position in irows) plus coloffset. |
avals | Numerical values of the entries. |
only_lower_triangular | if true, only the lower triangular portion is returned. This can only be true for symmetric matrices and if irows==jcols. |
References Indexlist::getLength(), and Indexlist::getNumberArray().
Referenced by SQProblemSchur::addConstraint(), Matrix::getSparseSubmatrix(), SQProblemSchur::removeBound(), and SQProblemSchur::resetSchurComplement().
returnValue Matrix::getSparseSubmatrix | ( | const Indexlist *const | irows, |
int_t | idx_icol, | ||
int_t | rowoffset, | ||
int_t | coloffset, | ||
int_t & | numNonzeros, | ||
int_t * | irn, | ||
int_t * | jcn, | ||
real_t * | avals, | ||
BooleanType | only_lower_triangular = BT_FALSE |
||
) | const [virtual, inherited] |
Retrieve entries of submatrix in Harwell-Boeing sparse format. If irn, jcn, and avals are null, this only counts the number of nonzeros. Otherwise, numNonzeros containts the size of irn, jcn, and avals on entry, and the written number of entries on return. This version retrieves one column.
irows | Index list specifying rows. |
idx_icol | Index list specifying columns. |
rowoffset | Offset for row entries. |
coloffset | Offset for row entries. |
numNonzeros | Number of nonzeros in submatrix. |
irn | Row position of entries (as position in irows) plus rowoffset. |
jcn | Column position of entries (as position in irows) plus coloffset. |
avals | Numerical values of the entries. |
only_lower_triangular | if true, only the lower triangular portion is returned. This can only be true for symmetric matrices and if irows==jcols. |
References Indexlist::getLength(), Indexlist::getNumberArray(), and Matrix::getSparseSubmatrix().
returnValue Matrix::getSparseSubmatrix | ( | int_t | idx_row, |
const Indexlist *const | icols, | ||
int_t | rowoffset, | ||
int_t | coloffset, | ||
int_t & | numNonzeros, | ||
int_t * | irn, | ||
int_t * | jcn, | ||
real_t * | avals, | ||
BooleanType | only_lower_triangular = BT_FALSE |
||
) | const [virtual, inherited] |
Retrieve entries of submatrix in Harwell-Boeing sparse format. If irn, jcn, and avals are null, this only counts the number of nonzeros. Otherwise, numNonzeros containts the size of irn, jcn, and avals on entry, and the written number of entries on return. This version retrieves one row.
idx_row | Row number. |
icols | Index list specifying columns. |
rowoffset | Offset for row entries. |
coloffset | Offset for row entries. |
numNonzeros | Number of nonzeros in submatrix. |
irn | Row position of entries (as position in irows) plus rowoffset. |
jcn | Column position of entries (as position in irows) plus coloffset. |
avals | Numerical values of the entries. |
only_lower_triangular | if true, only the lower triangular portion is returned. This can only be true for symmetric matrices and if irows==jcols. |
References Indexlist::getLength(), Indexlist::getNumberArray(), and Matrix::getSparseSubmatrix().
returnValue DenseMatrix::getSparseSubmatrix | ( | int_t | irowsLength, |
const int_t *const | irowsNumber, | ||
int_t | icolsLength, | ||
const int_t *const | icolsNumber, | ||
int_t | rowoffset, | ||
int_t | coloffset, | ||
int_t & | numNonzeros, | ||
int_t * | irn, | ||
int_t * | jcn, | ||
real_t * | avals, | ||
BooleanType | only_lower_triangular = BT_FALSE |
||
) | const [virtual, inherited] |
Retrieve entries of submatrix in Harwell-Boeing sparse format. If irn, jcn, and avals are null, this only counts the number of nonzeros. Otherwise, numNonzeros containts the size of irn, jcn, and avals on entry, and the written number of entries on return.
irowsLength | Number of rows. |
irowsNumber | Array with row numbers. |
icolsLength | Number of columns. |
icolsNumber | Array with column numbers. |
rowoffset | Offset for row entries. |
coloffset | Offset for row entries. |
numNonzeros | Number of nonzeros in submatrix. |
irn | Row position of entries (as position in irows) plus rowoffset. |
jcn | Column position of entries (as position in irows) plus coloffset. |
avals | Numerical values of the entries. |
only_lower_triangular | if true, only the lower triangular portion is returned. This can only be true for symmetric matrices and if irows==jcols. |
Implements Matrix.
References BT_FALSE, isZero(), DenseMatrix::leaDim, real_t, RET_INVALID_ARGUMENTS, SUCCESSFUL_RETURN, THROWERROR, and DenseMatrix::val.
BooleanType DenseMatrix::isDiag | ( | ) | const [virtual, inherited] |
Checks whether matrix is square and diagonal.
Implements Matrix.
References BT_FALSE, BT_TRUE, EPS, getAbs(), DenseMatrix::leaDim, DenseMatrix::nCols, DenseMatrix::nRows, and DenseMatrix::val.
BooleanType Matrix::needToFreeMemory | ( | ) | const [inline, inherited] |
Returns whether internal memory needs to be de-allocated.
References Matrix::freeMemory.
Referenced by DenseMatrix::duplicate(), duplicateSym(), DenseMatrix::~DenseMatrix(), SparseMatrix::~SparseMatrix(), and SparseMatrixRow::~SparseMatrixRow().
returnValue DenseMatrix::print | ( | const char * | name = 0 | ) | const [virtual, inherited] |
Prints matrix to screen.
name | Name of matrix. |
Implements Matrix.
References DenseMatrix::nCols, DenseMatrix::nRows, REFER_NAMESPACE_QPOASES, and DenseMatrix::val.
returnValue DenseMatrix::times | ( | int_t | xN, |
real_t | alpha, | ||
const real_t * | x, | ||
int_t | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int_t | yLD | ||
) | const [virtual, inherited] |
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 GEMM, getMax(), DenseMatrix::nCols, DenseMatrix::nRows, SUCCESSFUL_RETURN, and DenseMatrix::val.
returnValue DenseMatrix::times | ( | const Indexlist *const | irows, |
const Indexlist *const | icols, | ||
int_t | xN, | ||
real_t | alpha, | ||
const real_t * | x, | ||
int_t | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int_t | yLD, | ||
BooleanType | yCompr = BT_TRUE |
||
) | const [virtual, inherited] |
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, isEqual(), Indexlist::iSort, isZero(), DenseMatrix::leaDim, Indexlist::length, DenseMatrix::nCols, Indexlist::number, SUCCESSFUL_RETURN, and DenseMatrix::val.
returnValue DenseMatrix::transTimes | ( | int_t | xN, |
real_t | alpha, | ||
const real_t * | x, | ||
int_t | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int_t | yLD | ||
) | const [virtual, inherited] |
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 GEMM, getMax(), DenseMatrix::nCols, DenseMatrix::nRows, SUCCESSFUL_RETURN, and DenseMatrix::val.
returnValue DenseMatrix::transTimes | ( | const Indexlist *const | irows, |
const Indexlist *const | icols, | ||
int_t | xN, | ||
real_t | alpha, | ||
const real_t * | x, | ||
int_t | xLD, | ||
real_t | beta, | ||
real_t * | y, | ||
int_t | yLD | ||
) | const [virtual, inherited] |
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, isEqual(), Indexlist::iSort, isZero(), DenseMatrix::leaDim, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and DenseMatrix::val.
returnValue DenseMatrix::writeToFile | ( | FILE * | output_file, |
const char * | prefix | ||
) | const [virtual, inherited] |
Write matrix to file.
Implements Matrix.
References RET_NOT_YET_IMPLEMENTED, and THROWERROR.
BooleanType Matrix::freeMemory [protected, inherited] |
Indicating whether internal memory needs to be de-allocated.
Referenced by Matrix::doFreeMemory(), and Matrix::needToFreeMemory().
int_t DenseMatrix::leaDim [protected, inherited] |
Leading dimension.
Referenced by DenseMatrix::addToDiag(), bilinear(), DenseMatrix::diag(), DenseMatrix::getCol(), DenseMatrix::getRow(), DenseMatrix::getRowNorm(), DenseMatrix::getSparseSubmatrix(), DenseMatrix::isDiag(), DenseMatrix::times(), and DenseMatrix::transTimes().
int_t DenseMatrix::nCols [protected, inherited] |
int_t DenseMatrix::nRows [protected, inherited] |
real_t* DenseMatrix::val [protected, inherited] |
Vector of entries.
Referenced by DenseMatrix::addToDiag(), bilinear(), DenseMatrix::diag(), DenseMatrix::duplicate(), duplicateSym(), DenseMatrix::free(), DenseMatrix::full(), DenseMatrix::getCol(), DenseMatrix::getNorm(), DenseMatrix::getRow(), DenseMatrix::getRowNorm(), DenseMatrix::getSparseSubmatrix(), DenseMatrix::isDiag(), DenseMatrix::print(), DenseMatrix::times(), and DenseMatrix::transTimes().