ACADO Toolkit
1.2.0beta
Toolkit for Automatic Control and Dynamic Optimization
|
Implements a very rudimentary block sparse matrix class. More...
#include <block_matrix.hpp>
Public Member Functions | |
BlockMatrix () | |
Default constructor. | |
BlockMatrix (uint _nRows, uint _nCols) | |
Constructor which takes dimensions of the block matrix. | |
BlockMatrix (const Matrix &value) | |
Constructor which takes ... | |
BlockMatrix (const BlockMatrix &rhs) | |
Copy constructor (deep copy). | |
virtual | ~BlockMatrix () |
Destructor. | |
returnValue | init (uint _nRows, uint _nCols) |
Initializer. | |
BlockMatrix & | operator= (const BlockMatrix &rhs) |
Assignment operator (deep copy). | |
returnValue | setDense (uint rowIdx, uint colIdx, const Matrix &value) |
Set method that defines the value of a certain component. | |
returnValue | addDense (uint rowIdx, uint colIdx, const Matrix &value) |
Add method that adds a matrix to a certain component. | |
returnValue | getSubBlock (uint rowIdx, uint colIdx, Matrix &value) const |
Access method that returns the value of a certain component. | |
returnValue | getSubBlock (uint rowIdx, uint colIdx, Matrix &value, uint nR, uint nC) const |
Access method that returns the value of a certain component and requiring a given dimension. | |
BlockMatrix | operator+ (const BlockMatrix &arg) const |
Adds (element-wise) two matrices to a temporary object. | |
BlockMatrix & | operator+= (const BlockMatrix &arg) |
Adds (element-wise) a matrix to object. | |
BlockMatrix | operator- (const BlockMatrix &arg) const |
Subtracts (element-wise) a matrix from the object and and stores the result to a temporary object. | |
BlockMatrix | operator*= (double scalar) |
Subtracts (element-wise) a matrix from the object. | |
BlockMatrix | operator* (const BlockMatrix &arg) const |
Multiplies a matrix from the right to the matrix object and stores the result to a temporary object. | |
BlockMatrix | operator^ (const BlockMatrix &arg) const |
Multiplies a matrix from the right to the transposed matrix object and stores the result to a temporary object. | |
uint | getNumRows () const |
Returns number of block rows of the block matrix object. | |
uint | getNumCols () const |
Returns number of block columns of the block matrix object. | |
uint | getNumRows (uint rowIdx, uint colIdx) const |
Returns the number of rows of a specified sub-matrix. | |
uint | getNumCols (uint rowIdx, uint colIdx) const |
Returns number of block columns of a specified sub-matrix. | |
returnValue | setIdentity (uint rowIdx, uint colIdx, uint dim) |
Sets a specified sub block to the (dim x dim)-identity matrix. | |
returnValue | setZero (uint rowIdx, uint colIdx) |
Sets a specified sub block to the be a zero matrix. | |
BooleanType | isEmpty () const |
Returns whether the block matrix element is empty. | |
returnValue | setZero () |
Sets everyting to zero. | |
returnValue | addRegularisation (uint rowIdx, uint colIdx, double eps) |
Sets all values to a given constant. | |
BlockMatrix | addRegularisation (double eps) |
Sets everyting to zero. | |
BlockMatrix | transpose () const |
Returns the transpose of the object. | |
BooleanType | isSquare () const |
Tests if object is a block-square matrix. | |
BooleanType | isSquare (uint rowIdx, uint colIdx) const |
Tests if a specified sub-matrix is a square matrix. | |
BlockMatrix | getAbsolute () const |
Returns the a block matrix whose components are the absolute values of the components of this object. | |
BlockMatrix | getPositive () const |
Returns the a block matrix whose components are equal to the components of this object, if they are positive or zero, but zero otherwise. | |
BlockMatrix | getNegative () const |
Returns the a block matrix whose components are equal to the components of this object, if they are negative or zero, but zero otherwise. | |
returnValue | print () const |
Prints object to standard ouput stream. | |
Protected Attributes | |
uint | nRows |
Number of rows. | |
uint | nCols |
Number of columns. | |
Matrix ** | elements |
SubBlockMatrixType ** | types |
The class BlockMatrix is a very rudimentary block sparse matrix class. It is only intended to provide a convenient way to deal with linear algebra objects and to provide a wrapper for more efficient implementations. It should not be used for efficiency-critical operations.
BlockMatrix::BlockMatrix | ( | uint | _nRows, |
uint | _nCols | ||
) |
BlockMatrix::BlockMatrix | ( | const Matrix & | value | ) |
References elements, nCols, nRows, setDense(), and types.
BlockMatrix::BlockMatrix | ( | const BlockMatrix & | rhs | ) |
BlockMatrix::~BlockMatrix | ( | ) | [virtual] |
returnValue BlockMatrix::addDense | ( | uint | rowIdx, |
uint | colIdx, | ||
const Matrix & | value | ||
) |
rowIdx | Row index of the component. |
colIdx | Column index of the component. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ONE, setDense(), SUCCESSFUL_RETURN, and types.
Referenced by SCPevaluation::evaluateLagrangeGradient(), BoundaryConstraint::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), ShootingMethod::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), and LSQEndTerm::evaluateSensitivitiesGN().
returnValue BlockMatrix::addRegularisation | ( | uint | rowIdx, |
uint | colIdx, | ||
double | eps | ||
) | [inline] |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_ZERO, VectorspaceElement::setAll(), SUCCESSFUL_RETURN, and types.
Referenced by addRegularisation().
BlockMatrix BlockMatrix::addRegularisation | ( | double | eps | ) | [inline] |
References addRegularisation(), getNumCols(), getNumRows(), and uint.
BlockMatrix BlockMatrix::getAbsolute | ( | ) | const |
References elements, getNumRows(), nCols, nRows, SBMT_DENSE, SBMT_ONE, setDense(), setIdentity(), types, and uint.
Referenced by SCPmeritFunction::evaluate(), and SCPevaluation::getKKTtolerance().
BlockMatrix BlockMatrix::getNegative | ( | ) | const |
References elements, nCols, nRows, SBMT_DENSE, setDense(), types, and uint.
Referenced by SCPmeritFunction::evaluate(), and SCPevaluation::getKKTtolerance().
uint BlockMatrix::getNumCols | ( | ) | const [inline] |
References nCols.
Referenced by addDense(), addRegularisation(), getNumCols(), getNumRows(), getSubBlock(), isEmpty(), isSquare(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator^(), print(), setDense(), setIdentity(), setZero(), and transpose().
uint BlockMatrix::getNumCols | ( | uint | rowIdx, |
uint | colIdx | ||
) | const [inline] |
References ASSERT, elements, getNumCols(), Matrix::getNumCols(), and getNumRows().
uint BlockMatrix::getNumRows | ( | ) | const [inline] |
References nRows.
Referenced by addDense(), addRegularisation(), CondensingBasedCPsolver::condense(), BoundaryConstraint::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), CondensingBasedCPsolver::expand(), getAbsolute(), SCPmethod::getAnySensitivities(), getNumCols(), getNumRows(), getPositive(), getSubBlock(), isEmpty(), isSquare(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator^(), print(), setDense(), setIdentity(), setZero(), and transpose().
uint BlockMatrix::getNumRows | ( | uint | rowIdx, |
uint | colIdx | ||
) | const [inline] |
References ASSERT, elements, getNumCols(), getNumRows(), and Matrix::getNumRows().
BlockMatrix BlockMatrix::getPositive | ( | ) | const |
References elements, getNumRows(), nCols, nRows, SBMT_DENSE, SBMT_ONE, setDense(), setIdentity(), types, and uint.
Referenced by SCPmeritFunction::evaluate(), and SCPevaluation::getKKTtolerance().
BEGIN_NAMESPACE_ACADO returnValue BlockMatrix::getSubBlock | ( | uint | rowIdx, |
uint | colIdx, | ||
Matrix & | value | ||
) | const [inline] |
rowIdx | Row index of the component. |
colIdx | Column index of the component. |
References ASSERT, elements, getNumCols(), getNumRows(), and SUCCESSFUL_RETURN.
Referenced by OCPiterate::applyStep(), CondensingBasedCPsolver::computeCondensingOperator(), CondensingBasedCPsolver::condense(), SCPevaluation::evaluateLagrangeGradient(), BoundaryConstraint::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), ShootingMethod::evaluateSensitivities(), Constraint::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), ShootingMethod::evaluateSensitivitiesLifted(), CondensingBasedCPsolver::expand(), CondensingBasedCPsolver::generateBoundVectors(), CondensingBasedCPsolver::generateConstraintBlockLine(), CondensingBasedCPsolver::generateConstraintVectors(), CondensingBasedCPsolver::generateHessianBlockLine(), CondensingBasedCPsolver::generateObjectiveGradient(), CondensingBasedCPsolver::generateStateBoundBlockLine(), CondensingBasedCPsolver::generateStateBoundVectors(), SCPmethod::getAnySensitivities(), IntegrationAlgorithm::getBackwardSensitivities(), Constraint::getBackwardSensitivities(), Constraint::getConstraintResiduum(), IntegrationAlgorithm::getForwardSensitivities(), Constraint::getForwardSensitivities(), BFGSupdate::getSubBlockLine(), and BFGSupdate::setSubBlockLine().
returnValue BlockMatrix::getSubBlock | ( | uint | rowIdx, |
uint | colIdx, | ||
Matrix & | value, | ||
uint | nR, | ||
uint | nC | ||
) | const |
rowIdx | Row index of the component. |
colIdx | Column index of the component. |
References ASSERT, elements, getNumCols(), getNumRows(), Matrix::init(), SBMT_ZERO, VectorspaceElement::setZero(), SUCCESSFUL_RETURN, and types.
returnValue BlockMatrix::init | ( | uint | _nRows, |
uint | _nCols | ||
) |
References elements, nCols, nRows, SBMT_ZERO, SUCCESSFUL_RETURN, types, and uint.
Referenced by BoundaryConstraint::evaluate(), PointConstraint::evaluate(), CoupledPathConstraint::evaluate(), PathConstraint::evaluate(), AlgebraicConsistencyConstraint::evaluate(), BoundaryConstraint::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), ShootingMethod::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), ShootingMethod::evaluateSensitivitiesLifted(), CondensingBasedCPsolver::expand(), SCPmethod::getAnySensitivities(), Constraint::getBackwardSensitivities(), Constraint::getBoundResiduum(), Constraint::getConstraintResiduum(), Constraint::getForwardSensitivities(), DynamicDiscretization::getResiduum(), CondensingBasedCPsolver::initializeCondensingOperator(), and SCPmethod::setup().
BooleanType BlockMatrix::isEmpty | ( | ) | const [inline] |
BooleanType BlockMatrix::isSquare | ( | ) | const [inline] |
References BT_FALSE, BT_TRUE, getNumCols(), and getNumRows().
BooleanType BlockMatrix::isSquare | ( | uint | rowIdx, |
uint | colIdx | ||
) | const [inline] |
References ASSERT, elements, getNumCols(), getNumRows(), and Matrix::isSquare().
BlockMatrix BlockMatrix::operator* | ( | const BlockMatrix & | arg | ) | const |
arg | Block Matrix Factor. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ONE, SBMT_ZERO, types, and uint.
BlockMatrix BlockMatrix::operator*= | ( | double | scalar | ) |
scalar | Scalar factor. |
References elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ZERO, types, and uint.
BlockMatrix BlockMatrix::operator+ | ( | const BlockMatrix & | arg | ) | const |
arg | Second summand. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ZERO, types, and uint.
BlockMatrix & BlockMatrix::operator+= | ( | const BlockMatrix & | arg | ) |
arg | Second summand. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ZERO, types, and uint.
BlockMatrix BlockMatrix::operator- | ( | const BlockMatrix & | arg | ) | const |
arg | Subtrahend. |
References ASSERT, elements, getNumCols(), Matrix::getNumCols(), getNumRows(), Matrix::getNumRows(), SBMT_DENSE, SBMT_ZERO, VectorspaceElement::setZero(), types, and uint.
BlockMatrix & BlockMatrix::operator= | ( | const BlockMatrix & | rhs | ) |
BlockMatrix BlockMatrix::operator^ | ( | const BlockMatrix & | arg | ) | const |
arg | Block Matrix Factor. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SBMT_ONE, SBMT_ZERO, Matrix::transpose(), types, and uint.
returnValue BlockMatrix::print | ( | ) | const |
References acadoPrintf(), elements, getNumCols(), getNumRows(), VectorspaceElement::print(), SBMT_DENSE, SBMT_ONE, SBMT_ZERO, SUCCESSFUL_RETURN, types, and uint.
returnValue BlockMatrix::setDense | ( | uint | rowIdx, |
uint | colIdx, | ||
const Matrix & | value | ||
) |
rowIdx | Row index of the component. |
colIdx | Column index of the component. |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_DENSE, SUCCESSFUL_RETURN, and types.
Referenced by addDense(), BlockMatrix(), CondensingBasedCPsolver::computeCondensingOperator(), PointConstraint::computeForwardSensitivityBlock(), AlgebraicConsistencyConstraint::computeForwardSensitivityBlock(), CondensingBasedCPsolver::condense(), BoundaryConstraint::evaluate(), PointConstraint::evaluate(), CoupledPathConstraint::evaluate(), PathConstraint::evaluate(), AlgebraicConsistencyConstraint::evaluate(), SCPevaluation::evaluateLagrangeGradient(), BoundaryConstraint::evaluateSensitivities(), PointConstraint::evaluateSensitivities(), CoupledPathConstraint::evaluateSensitivities(), PathConstraint::evaluateSensitivities(), MayerTerm::evaluateSensitivities(), LSQTerm::evaluateSensitivities(), AlgebraicConsistencyConstraint::evaluateSensitivities(), ShootingMethod::evaluateSensitivities(), LSQTerm::evaluateSensitivitiesGN(), LSQEndTerm::evaluateSensitivitiesGN(), ShootingMethod::evaluateSensitivitiesLifted(), CondensingBasedCPsolver::expand(), getAbsolute(), SCPmethod::getAnySensitivities(), Constraint::getBackwardSensitivities(), Constraint::getBoundResiduum(), Constraint::getConstraintResiduum(), Constraint::getForwardSensitivities(), getNegative(), getPositive(), DynamicDiscretization::getResiduum(), BFGSupdate::getSubBlockLine(), and BFGSupdate::setSubBlockLine().
returnValue BlockMatrix::setIdentity | ( | uint | rowIdx, |
uint | colIdx, | ||
uint | dim | ||
) | [inline] |
rowIdx | row index of the sub block |
colIdx | column index of the sub block |
dim | dimension of the sub block |
References ASSERT, elements, getNumCols(), getNumRows(), Matrix::init(), SBMT_ONE, Matrix::setIdentity(), and types.
Referenced by getAbsolute(), getPositive(), ConstantHessian::initHessian(), ExactHessian::initHessian(), CondensingBasedCPsolver::initializeCondensingOperator(), DynamicDiscretization::setUnitBackwardSeed(), Objective::setUnitBackwardSeed(), Constraint::setUnitBackwardSeed(), ConstraintElement::setUnitForwardSeed(), and DynamicDiscretization::setUnitForwardSeed().
returnValue BlockMatrix::setZero | ( | uint | rowIdx, |
uint | colIdx | ||
) | [inline] |
References ASSERT, elements, getNumCols(), getNumRows(), SBMT_ZERO, VectorspaceElement::setZero(), and types.
Referenced by BFGSupdate::applyBlockDiagonalUpdate(), SCPevaluation::evaluate(), SCPevaluation::evaluateSensitivities(), Objective::evaluateSensitivitiesGN(), and CondensingBasedCPsolver::initializeCondensingOperator().
returnValue BlockMatrix::setZero | ( | ) | [inline] |
References getNumCols(), getNumRows(), SUCCESSFUL_RETURN, and uint.
BlockMatrix BlockMatrix::transpose | ( | ) | const |
References elements, getNumCols(), getNumRows(), Matrix::transpose(), types, and uint.
Referenced by BFGSupdate::applyUpdate(), and SCPevaluation::evaluateLagrangeGradient().
Matrix** BlockMatrix::elements [protected] |
Referenced by addDense(), addRegularisation(), BlockMatrix(), getAbsolute(), getNegative(), getNumCols(), getNumRows(), getPositive(), getSubBlock(), init(), isSquare(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator=(), operator^(), print(), setDense(), setIdentity(), setZero(), transpose(), and ~BlockMatrix().
uint BlockMatrix::nCols [protected] |
Referenced by BlockMatrix(), getAbsolute(), getNegative(), getNumCols(), getPositive(), init(), and operator=().
uint BlockMatrix::nRows [protected] |
Referenced by BlockMatrix(), getAbsolute(), getNegative(), getNumRows(), getPositive(), init(), operator=(), and ~BlockMatrix().
SubBlockMatrixType** BlockMatrix::types [protected] |
Referenced by addDense(), addRegularisation(), BlockMatrix(), getAbsolute(), getNegative(), getPositive(), getSubBlock(), init(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator=(), operator^(), print(), setDense(), setIdentity(), setZero(), transpose(), and ~BlockMatrix().