qpOASES
3.2.1
An Implementation of the Online Active Set Strategy
|
Interfaces matrix-vector operations tailored to general sparse matrices. More...
#include <Matrices.hpp>
Public Member Functions | |
SparseMatrixRow () | |
SparseMatrixRow (int_t nr, int_t nc, sparse_int_t *r, sparse_int_t *c, real_t *v) | |
SparseMatrixRow (int_t nr, int_t nc, int_t ld, const real_t *const v) | |
virtual | ~SparseMatrixRow () |
virtual void | free () |
virtual Matrix * | duplicate () const |
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 | 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 | 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 | 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 (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) |
sparse_int_t * | createDiagInfo () |
virtual real_t * | full () const |
virtual returnValue | print (const char *name=0) const |
virtual returnValue | writeToFile (FILE *output_file, const char *prefix) 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 |
BooleanType | needToFreeMemory () const |
void | doFreeMemory () |
void | doNotFreeMemory () |
Protected Attributes | |
int_t | nRows |
int_t | nCols |
sparse_int_t * | jr |
sparse_int_t * | ic |
sparse_int_t * | jd |
real_t * | val |
BooleanType | freeMemory |
Sparse matrix class (row compressed format).
Default constructor.
Referenced by duplicate().
SparseMatrixRow::SparseMatrixRow | ( | int_t | nr, |
int_t | nc, | ||
sparse_int_t * | r, | ||
sparse_int_t * | c, | ||
real_t * | v | ||
) |
Constructor with arguments.
nr | Number of rows. |
nc | Number of columns. |
r | Indices to first entry of rows (nRows+1). |
c | Column indices (length). |
v | Vector of entries (length). |
References Matrix::doNotFreeMemory().
SparseMatrixRow::SparseMatrixRow | ( | int_t | nr, |
int_t | nc, | ||
int_t | ld, | ||
const real_t *const | v | ||
) |
SparseMatrixRow::~SparseMatrixRow | ( | ) | [virtual] |
Destructor.
References BT_TRUE, free(), jd, and Matrix::needToFreeMemory().
returnValue SparseMatrixRow::addToDiag | ( | real_t | alpha | ) | [virtual] |
Adds given offset to diagonal of matrix.
alpha | Diagonal offset. |
Implements Matrix.
References BT_FALSE, ic, isZero(), jd, nCols, nRows, RET_DIAGONAL_NOT_INITIALISED, RET_NO_DIAGONAL_AVAILABLE, SUCCESSFUL_RETURN, THROWERROR, and val.
real_t SparseMatrixRow::diag | ( | int_t | i | ) | const [virtual] |
Returns i-th diagonal entry.
i | Index. |
Implements Matrix.
References ic, INFTY, jd, jr, 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(), SparseMatrix::duplicate(), duplicate(), SymDenseMat::duplicateSym(), SymSparseMat::duplicateSym(), QProblemB::setupQPdataFromFile(), QProblem::setupQPdataFromFile(), solveOqpBenchmark(), SparseMatrix::SparseMatrix(), and SparseMatrixRow().
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] |
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] |
returnValue SparseMatrixRow::getCol | ( | int_t | 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, ic, isEqual(), Indexlist::iSort, jr, Indexlist::length, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.
real_t SparseMatrixRow::getNorm | ( | int_t | type = 2 | ) | const [virtual] |
Get the N-norm of the matrix
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References jr, nRows, REFER_NAMESPACE_QPOASES, and val.
Referenced by getRowNorm().
returnValue SparseMatrixRow::getRow | ( | int_t | 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, ic, isEqual(), Indexlist::iSort, jr, nCols, Indexlist::number, SUCCESSFUL_RETURN, and val.
real_t SparseMatrixRow::getRowNorm | ( | int_t | rNum, |
int_t | 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 getNorm(), jr, REFER_NAMESPACE_QPOASES, and val.
returnValue SparseMatrixRow::getRowNorm | ( | real_t * | norm, |
int_t | type = 2 |
||
) | const [virtual] |
Get the N-norm of all rows
norm | Norm of each row. |
type | Norm type, 1: one-norm, 2: Euclidean norm. |
Implements Matrix.
References getNorm(), jr, nRows, REFER_NAMESPACE_QPOASES, SUCCESSFUL_RETURN, and 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 SparseMatrixRow::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] |
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 RET_NOT_YET_IMPLEMENTED, and THROWERROR.
BooleanType SparseMatrixRow::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::~SparseMatrix(), and ~SparseMatrixRow().
returnValue SparseMatrixRow::print | ( | const char * | name = 0 | ) | const [virtual] |
returnValue SparseMatrixRow::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] |
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, ic, isEqual(), isZero(), jr, nRows, SUCCESSFUL_RETURN, and val.
returnValue SparseMatrixRow::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] |
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, ic, isEqual(), Indexlist::iSort, isZero(), jr, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and val.
returnValue SparseMatrixRow::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] |
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, ic, isEqual(), isZero(), jr, nCols, nRows, SUCCESSFUL_RETURN, and val.
returnValue SparseMatrixRow::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] |
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, ic, isEqual(), Indexlist::iSort, isZero(), jr, Indexlist::length, Indexlist::number, SUCCESSFUL_RETURN, and val.
returnValue SparseMatrixRow::writeToFile | ( | FILE * | output_file, |
const char * | prefix | ||
) | const [virtual] |
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().
sparse_int_t* SparseMatrixRow::ic [protected] |
Column indices (length).
Referenced by addToDiag(), createDiagInfo(), diag(), duplicate(), free(), full(), getCol(), getRow(), isDiag(), SparseMatrixRow(), times(), and transTimes().
sparse_int_t* SparseMatrixRow::jd [protected] |
Indices to first entry of upper triangle (including diagonal) (nRows).
Referenced by addToDiag(), createDiagInfo(), diag(), duplicate(), and ~SparseMatrixRow().
sparse_int_t* SparseMatrixRow::jr [protected] |
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_t SparseMatrixRow::nCols [protected] |
Number of columns.
Referenced by addToDiag(), duplicate(), full(), getCol(), getRow(), isDiag(), print(), SparseMatrixRow(), and transTimes().
int_t SparseMatrixRow::nRows [protected] |
Number of rows.
Referenced by addToDiag(), createDiagInfo(), duplicate(), full(), getNorm(), getRowNorm(), isDiag(), print(), SparseMatrixRow(), times(), and transTimes().
real_t* SparseMatrixRow::val [protected] |
Vector of entries (length).
Referenced by addToDiag(), diag(), duplicate(), free(), full(), getCol(), getNorm(), getRow(), getRowNorm(), SparseMatrixRow(), times(), and transTimes().