Actin®  Version 5.2.0
Software for Robotics Simulation and Control
EcReArray Class Reference

Holds a class to describe real arrays. Includes operations such as addition, subtraction, and multiplication. More...

#include <ecReArray.h>

Inheritance diagram for EcReArray:
EcVelocityControlData

Public Member Functions

 EcReArray ()
 default constructor
 
 EcReArray (EcSizeT rows, EcSizeT columns)
 constructor with row and column sizes
 
 EcReArray (const EcRealVector &vector, EcBoolean isColumn)
 
virtual ~EcReArray ()
 destructor
 
 EcReArray (const EcReArray &orig)
 copy constructor
 
EcRealVectoroperator[] (EcSizeT index)
 Pass-through method to treat EcReArray as an STL vector.
 
const EcRealVectoroperator[] (EcSizeT index) const
 Pass-through method to treat EcReArray as an STL vector.
 
void assign (EcSizeT size, const EcRealVector &v)
 Pass-through method to treat EcReArray as an STL vector.
 
void clear ()
 Pass-through method to treat EcReArray as an STL vector.
 
void push_back (const EcRealVector &v)
 Pass-through method to treat EcReArray as an STL vector.
 
void reserve (EcSizeT size)
 Pass-through method to treat EcReArray as an STL vector.
 
void resize (EcSizeT newsize, EcRealVector v=EcRealVector())
 Pass-through method to treat EcReArray as an STL vector.
 
EcSizeT size () const
 Pass-through method to treat EcReArray as an STL vector.
 
 operator EcRealVectorVector & ()
 Provide implicit type conversion to an EcRealVectorVector.
 
EcReArrayoperator= (const EcReArray &orig)
 assignment operator
 
EcReArrayoperator= (const EcRealVector &vOrig)
 assignment from a vector representing a single column
 
EcBoolean operator== (const EcReArray &other) const
 equality operator
 
EcReArray operator+ (const EcReArray &other) const
 
EcReArrayoperator+= (const EcReArray &other)
 
EcReArray operator- (const EcReArray &other) const
 
EcReArrayoperator-= (const EcReArray &other)
 
EcReArray operator* (const EcReArray &other) const
 
EcRealVector operator* (const EcRealVector &vOther) const
 
EcVector operator* (const EcVector &vOther) const
 Multiplies a 3x3 array with a vector 3x1. More...
 
EcReArrayoperator*= (EcReal scalar)
 Multiplies every entry by the scalar. More...
 
EcReArray operator* (EcReal scalar) const
 Multiplies every entry by the scalar. More...
 
virtual EcReal trace () const
 
void setToDiagonal (const EcRealVector &vDiagTerms)
 
virtual void transform (const EcReArray &from, EcReArray &to) const
 
virtual void transform (const EcRealVector &vFrom, EcRealVector &vTo) const
 
virtual void transform (const EcRealVector &vFrom, EcReArray &to) const
 
virtual void transposeTransform (const EcRealVector &vFrom, EcRealVector &vTo) const
 
virtual void leftTransposeTransform (const EcReArray &from, EcReArray &to) const
 
virtual void leftTransposeTransform (const EcRealVector &vFrom, EcReArray &to) const
 
virtual EcReArrayleftMultiplyDiagonal (const EcRealVector &vDiagTerms)
 Left multiply with a diagonal matrix represented by a real vector. More...
 
virtual void elementInverse (EcReArray &result) const
 element-by-element inverse. More...
 
virtual void elementCosine (EcReArray &result) const
 element-by-element cosine. More...
 
virtual void elementSine (EcReArray &result) const
 element-by-element sine. More...
 
virtual void elementLog (EcReArray &result) const
 Returns the log (base e) of this EcReArray. More...
 
virtual void elementLogN (EcReArray &result, EcReal base) const
 Retuns element-by-element log (base n) of this EcReArray. More...
 
virtual void elementPow (EcReArray &result, EcReal exp) const
 element-by-element pow. More...
 
virtual EcReArray transpose () const
 Retuns transpose. Returns by copy.
 
virtual void transpose (EcReArray &out) const
 matrix transpose More...
 
virtual void addSelfOuterProduct (const EcRealVector &v)
 
virtual void addWeightedSelfOuterProduct (const EcRealVector &v, EcReal a)
 
virtual void qrDecomposition (EcReArray *pR=EcNULL)
 QR decomposition using modified Gram-Schmidt. More...
 
virtual EcBoolean choleskyDecomposition (EcReArray &choleskyL) const
 calculate the Cholesky decomposition of a symmetric, positive definite matrix
 
virtual EcBoolean choleskyBackSubstitution (const EcReArray &input, EcReArray &result) const
 
virtual EcBoolean choleskyBackSubstitutionOnTranspose (const EcReArray &input, EcReArray &result) const
 
virtual EcBoolean lowerTriangularForwardSubstitution (const EcReArray &input, EcReArray &result) const
 
virtual EcBoolean lowerTriangularForwardSubstitutionOnTranspose (const EcReArray &input, EcReArray &result) const
 
virtual EcBoolean underconstrainedNormal (EcReArray &squareResult) const
 
virtual EcBoolean overconstrainedNormal (EcReArray &squareResult) const
 
virtual EcBoolean approxEq (const EcReArray &other, EcReal tol) const
 tests that each element of this is within a tolerance of another More...
 
virtual EcReal infinityNorm () const
 calculates the maximum absolute row sum (or infinity norm)
 
virtual EcReal infinityNorm (const EcSizeT col) const
 calculates the infinity norm of a column
 
virtual EcReal columnNorm (EcSizeT col) const
 calculate the 2-norm of a column
 
virtual EcSizeT rows () const
 gets the number of rows
 
virtual EcSizeT columns () const
 gets the number of columns
 
virtual void setToZeros (EcSizeT rows, EcSizeT columns)
 set to an array of zeros
 
virtual void setToValue (EcSizeT rows, EcSizeT columns, EcReal value)
 set to an array of the given value
 
virtual void setToIdentity (EcSizeT rows, EcSizeT columns)
 set to all zeros with ones on the diagonal
 
virtual void resizeArray (EcSizeT rows, EcSizeT columns)
 resize array
 
virtual void copyEntriesOf (const EcReArray &other)
 copy the entries of another to within the current array
 
virtual EcBoolean LUDecomposition (EcSizeT nRows, EcU32Vector &vIndices)
 
virtual EcBoolean forwardAndBackSub (const EcU32Vector &indices, const EcRealVector &b, EcRealVector &x, EcReal &det) const
 
virtual EcBoolean solve (const EcRealVector &b, EcRealVector &x, EcReal *pDet=0)
 Solving the linear system Ax=b, content of A will be altered. More...
 
virtual EcBoolean invertSquareMatrix ()
 invert the matrix
 
virtual EcBoolean LUDecompositionSparse (EcSizeT nRows, EcU32Vector &vIndices, const EcU32Vector &vSparseInd, const EcU32Vector &vZeroStart)
 
virtual EcReal determinant ()
 
virtual EcBoolean nullSpace (EcReArray &nSpace, EcSizeT nRows, EcU32Vector &vIndices)
 calculate the null space. More...
 
virtual EcBoolean nullSpaceSparse (EcReArray &nSpace, EcSizeT nRows, EcU32Vector &vIndices, const EcU32Vector &vSparseInd, const EcU32Vector &vZeroStart)
 calculate the null space. More...
 
virtual EcBoolean calculateZeroStartIndices (EcU32Vector &vZeroStartIndices) const
 
virtual EcBoolean dump (const char *fileName) const
 dump the data into a file for debug purpose, with Matlab style matrix definition. More...
 
virtual EcBoolean dumpMath (const char *fileName) const
 dump the data into a file for debug purpose, with Mathematica style matrix definition. More...
 
virtual EcBoolean combineIndices (const EcU32Vector &vInd1, const EcU32Vector &vInd2, EcU32Vector &vIndResult) const
 combine swapping indices
 
virtual EcBoolean inv2 (EcReArray &M2) const
 calculate inverse of a 2x2 in closed form
 
virtual EcBoolean inv3 (EcReArray &M2) const
 calculate inverse of a 3x3 in closed form
 
virtual EcBoolean writeBin (const EcString &fname) const
 write out the data in binary format More...
 
virtual EcBoolean readBin (const EcString &fname)
 read in data in binary format. Set to this More...
 
virtual void getColumn (EcRealVector &vCol, const EcSizeT col) const
 return a column of this array
 
virtual void getRow (EcRealVector &vRow, const EcSizeT row) const
 return a row of this array
 
virtual void maximum (EcReal &val, EcSizeT &row, EcSizeT &col) const
 return max of this array and the indices
 
virtual void minimum (EcReal &val, EcSizeT &row, EcSizeT &col) const
 return min of this array and the indices
 
virtual EcReal sum () const
 return sum of this array
 
virtual EcBoolean kroneckerTensorProduct (const EcReArray &arrayB, EcReArray &arrayC) const
 

Static Public Member Functions

static EcReArray nullObject ()
 get an identity transformation
 

Detailed Description

Holds a class to describe real arrays. Includes operations such as addition, subtraction, and multiplication.

Definition at line 15 of file ecReArray.h.

Constructor & Destructor Documentation

EcReArray::EcReArray ( const EcRealVector vector,
EcBoolean  isColumn 
)

constructor from EcRealVector (default, a column vector.)

Parameters
[in]vectorsingle column or row of the matrix
[in]isColumntrue if column vector, false for row vector

Member Function Documentation

virtual void EcReArray::addSelfOuterProduct ( const EcRealVector v)
virtual

add the self-outer product of a vector to the matrix i.e. J = J + v.v^T, where J is this matrix.

Parameters
[in]vThe vector v in J = J + v.v^T.
virtual void EcReArray::addWeightedSelfOuterProduct ( const EcRealVector v,
EcReal  a 
)
virtual

add a weighted self-outer product of a vector to the matrix i.e. J = J + a*v.v^T, where J is this matrix.

Parameters
[in]vThe vector v in J = J + a*v.v^T.
[in]aThe weight a in J = J + a*v.v^T.
virtual EcBoolean EcReArray::approxEq ( const EcReArray other,
EcReal  tol 
) const
virtual

tests that each element of this is within a tolerance of another

Parameters
[in]otherThe other matrix to test against.
[in]tolThe specified tolerance.
Returns
True if this matrix is within a tolerance of other. False if the sizes of the two matrices don't match or if this at least one element of this matrix is not within a tolerance of other.
virtual EcBoolean EcReArray::calculateZeroStartIndices ( EcU32Vector vZeroStartIndices) const
virtual

calculate a set of zero-start indices for this matrix, unpivoted these are the starting locations of terminal zeros on each row, with the constraint that they are nondecreasing.

Parameters
[out]vZeroStartIndicesA set of zero-start indices for this matrix.
virtual EcBoolean EcReArray::choleskyBackSubstitution ( const EcReArray input,
EcReArray result 
) const
virtual

Perform a forward substitution with L, followed by a back substitution with L^T. If L is calculated using choleskyDecomposition() on matrix M, this finds x = M^-1 y.

virtual EcBoolean EcReArray::choleskyBackSubstitutionOnTranspose ( const EcReArray input,
EcReArray result 
) const
virtual

Perform a forward substitution with L, followed by a back substitution with L^T on the transpose of the input. If L is calculated using choleskyDecomposition() on matrix M, this finds x = M^-1 y^T.

virtual EcReal EcReArray::determinant ( )
virtual

calculate determinant of a square matrix by performing the LU decomposition of and return the product of the pivots (sign change by indices)

Warning
Calculating the determinant changes this matrix.
virtual EcBoolean EcReArray::dump ( const char *  fileName) const
virtual

dump the data into a file for debug purpose, with Matlab style matrix definition.

Parameters
[in]fileNameThe name of the file to dump the data to.
Returns
True if succeeded or false otherwise.
virtual EcBoolean EcReArray::dumpMath ( const char *  fileName) const
virtual

dump the data into a file for debug purpose, with Mathematica style matrix definition.

Parameters
[in]fileNameThe name of the file to dump the data to.
Returns
True if succeeded or false otherwise.
virtual void EcReArray::elementCosine ( EcReArray result) const
virtual

element-by-element cosine.

Parameters
[out]resultThe element-by-element cosine of this matrix.
virtual void EcReArray::elementInverse ( EcReArray result) const
virtual

element-by-element inverse.

Parameters
[out]resultThe element-by-element inverse of this matrix.
virtual void EcReArray::elementLog ( EcReArray result) const
virtual

Returns the log (base e) of this EcReArray.

Parameters
[out]resultThe element-by-element log (base e) of this EcReArray.
virtual void EcReArray::elementLogN ( EcReArray result,
EcReal  base 
) const
virtual

Retuns element-by-element log (base n) of this EcReArray.

Parameters
[out]resultThe element-by-element log (base n) of this EcReArray.
[in]baseThe base of log.
virtual void EcReArray::elementPow ( EcReArray result,
EcReal  exp 
) const
virtual

element-by-element pow.

Parameters
[out]resultThe element-by-element pow of this matrix.
[in]expThe exponential for pow.
virtual void EcReArray::elementSine ( EcReArray result) const
virtual

element-by-element sine.

Parameters
[out]resultThe element-by-element sine of this matrix.
virtual EcBoolean EcReArray::forwardAndBackSub ( const EcU32Vector indices,
const EcRealVector b,
EcRealVector x,
EcReal det 
) const
virtual

Perform forward and back substitution after a LU decomposition to solve Ax=b, where A=L*U.

Parameters
[in]indicesThe index vector produced by pivoting from LUDecomposition.
[in]bThe vector b in Ax=b.
[out]xThe solution vector in Ax=b.
[out]detThe determinant of A.
virtual EcBoolean EcReArray::kroneckerTensorProduct ( const EcReArray arrayB,
EcReArray arrayC 
) const
virtual

Perform Kronecker Tensor Product a matrix of size (m x n) Kron with a matrix of size (p x q) results in a matrix of ( m*p x n*q )

Parameters
[in]thesecond matrix.
[in]theresulting matrix
virtual EcReArray& EcReArray::leftMultiplyDiagonal ( const EcRealVector vDiagTerms)
virtual

Left multiply with a diagonal matrix represented by a real vector.

The function multiplies the minimum compatible subset of Diagonal(vDiagTerms) * this and stores the result in this.

Parameters
[in]vDiagTermsthe diagonal terms
virtual void EcReArray::leftTransposeTransform ( const EcReArray from,
EcReArray to 
) const
virtual

Multiplies the minimum compatible subset of the transpose of the first matrix (this) by the second matrix (from) to get the the result matrix (to). (This is matrix multiplication, not element-by-element multiplication.)

Parameters
[in]fromA matrix to be multiplied with the transpose of this matrix.
[out]toA matrix containing the result of the muliplication.
virtual void EcReArray::leftTransposeTransform ( const EcRealVector vFrom,
EcReArray to 
) const
virtual

Multiplies the minimum compatible subset of the transpose of the first matrix (this) by the second vector (from) to get the the result matrix (to). (This is matrix multiplication, not element-by-element multiplication.) The vector is treated as a column vector.

Parameters
[in]vFromA vector to be multiplied with the transpose of this matrix.
[out]toA matrix containing the result of the muliplication.
virtual EcBoolean EcReArray::lowerTriangularForwardSubstitution ( const EcReArray input,
EcReArray result 
) const
virtual

Perform a forward substitution with L. This finds finds x = L^-1 y for lower-triangular L.

virtual EcBoolean EcReArray::lowerTriangularForwardSubstitutionOnTranspose ( const EcReArray input,
EcReArray result 
) const
virtual

Perform a forward substitution with L. This finds finds x = L^-1 y^T for lower-triangular L.

virtual EcBoolean EcReArray::LUDecomposition ( EcSizeT  nRows,
EcU32Vector vIndices 
)
virtual

calculate the LU decomposition of the first mm rows and return the result into the original matrix

Parameters
[in]nRowsThe number of rows to work on (the first nRows rows). If 0, then all rows will be used.
[out]vIndicesThe pivot column index vector.
virtual EcBoolean EcReArray::LUDecompositionSparse ( EcSizeT  nRows,
EcU32Vector vIndices,
const EcU32Vector vSparseInd,
const EcU32Vector vZeroStart 
)
virtual

calculate the LU decomposition of the first n rows and return the result into the original sparse matrix

Parameters
[in]nRowsThe number of rows to work on (the first nRows rows). If 0, then all rows will be used.
[out]vIndicesThe pivot column index vector.
[in]vSparseIndThe sparse column index vector.
[in]vZeroStartThe zero start column index vector.
virtual EcBoolean EcReArray::nullSpace ( EcReArray nSpace,
EcSizeT  nRows,
EcU32Vector vIndices 
)
virtual

calculate the null space.

Warning
After this calculation, the entries of this matrix will be changed to its LU decomposition.
Parameters
[out]nSpaceThe matrix containing the null space output.
[in]nRowsThe number of rows to work on (the first nRows rows). If 0, then all rows will be used.
[out]vIndicesThe pivot column index vector.
virtual EcBoolean EcReArray::nullSpaceSparse ( EcReArray nSpace,
EcSizeT  nRows,
EcU32Vector vIndices,
const EcU32Vector vSparseInd,
const EcU32Vector vZeroStart 
)
virtual

calculate the null space.

Warning
After this calculation, the entries of this matrix will be changed to its LU decomposition.
Parameters
[out]nSpaceThe matrix containing the null space output.
[in]nRowsThe number of rows to work on (the first nRows rows). If 0, then all rows will be used.
[out]vIndicesThe pivot column index vector.
[in]vSparseIndThe sparse column index vector.
[in]vZeroStartThe zero start column index vector.
EcReArray EcReArray::operator* ( const EcReArray other) const

Multiplies the minimum compatible subset of the two matrices. (This is matrix multiplication, not element- by-element multiplication.)

EcRealVector EcReArray::operator* ( const EcRealVector vOther) const

Multiplies the minimum compatible subset of the matrix and the vector.

EcVector EcReArray::operator* ( const EcVector vOther) const

Multiplies a 3x3 array with a vector 3x1.

Parameters
[in]vOtherA 3x1 vector to be multiplied.
Returns
The 3x1 vector after multiplication. If this matrix has fewer than 3 rows or 3 columns, then the return vector will contain all zeros.
EcReArray EcReArray::operator* ( EcReal  scalar) const

Multiplies every entry by the scalar.

Parameters
[in]scalarThe scalar to be multiplied.
Returns
The result after multiplication.
EcReArray& EcReArray::operator*= ( EcReal  scalar)

Multiplies every entry by the scalar.

Parameters
[in]scalarThe scalar to be multiplied.
Returns
This matrix after multiplication.
EcReArray EcReArray::operator+ ( const EcReArray other) const

Adds the minimum compatible subset of the two matrices.

EcReArray& EcReArray::operator+= ( const EcReArray other)

Adds the minimum compatible subset of the two matrices and sets this to the result.

EcReArray EcReArray::operator- ( const EcReArray other) const

Subtracts the minimum compatible subset of the two matrices.

EcReArray& EcReArray::operator-= ( const EcReArray other)

Subtracts the minimum compatible subset of the two matrices and sets this to the result.

virtual EcBoolean EcReArray::overconstrainedNormal ( EcReArray squareResult) const
virtual

Finds the over-constrained normal equations. For input J, this gives J^T*J.

Parameters
[out]squareResultThe matrix J^T*J, where J is this matrix.
virtual void EcReArray::qrDecomposition ( EcReArray pR = EcNULL)
virtual

QR decomposition using modified Gram-Schmidt.

For a m*n (m >= n) matrix A, calculates A = QR and stores Q in this.

Parameters
[in]pRpointer to the R matrix.
virtual EcBoolean EcReArray::readBin ( const EcString fname)
virtual

read in data in binary format. Set to this

Parameters
[in]fnameThe name of the file to read the data from.
Returns
True if succeeded or false otherwise.
void EcReArray::setToDiagonal ( const EcRealVector vDiagTerms)

Set the matrix to a diagonal matrix with diagonal elements equal to the input and zeros elsewhere

Parameters
[in]vDiagTermsThe vector used to set the diagonal terms of the matrix.
virtual EcBoolean EcReArray::solve ( const EcRealVector b,
EcRealVector x,
EcReal pDet = 0 
)
virtual

Solving the linear system Ax=b, content of A will be altered.

Parameters
[in]bThe vector b in Ax=b.
[out]xThe solution vector x in Ax=b.
[out]pDetOptionally, the determinant of A.
virtual EcReal EcReArray::trace ( ) const
virtual

Returns the trace of a square matrix The trace is the sum of the diagonal terms. If the matrix is not square, zero is returned.

virtual void EcReArray::transform ( const EcReArray from,
EcReArray to 
) const
virtual

Multiplies the compatible subset of the first matrix to get the second. (This is matrix multiplication, not element-by-element multiplication.)

Parameters
[in]fromA matrix to be multiplied with this matrix.
[out]toA matrix containing the result of the muliplication.
virtual void EcReArray::transform ( const EcRealVector vFrom,
EcRealVector vTo 
) const
virtual

Multiplies the compatible subset of the first vector to get the second. (This is matrix multiplication, not element-by-element multiplication.)

Parameters
[in]vFromA vector to be multiplied with this matrix.
[out]vToA vector containing the result of the muliplication.
virtual void EcReArray::transform ( const EcRealVector vFrom,
EcReArray to 
) const
virtual

Multiplies the compatible subset of the first vector to get the matrix. (This is matrix multiplication, not element-by-element multiplication.) The vector is treated as a column vector.

Parameters
[in]vFromA vector to be multiplied with this matrix.
[out]toA matrix containing the result of the muliplication.
virtual void EcReArray::transpose ( EcReArray out) const
virtual

matrix transpose

Parameters
[out]outThe transpose of this matrix.
virtual void EcReArray::transposeTransform ( const EcRealVector vFrom,
EcRealVector vTo 
) const
virtual

Multiplies the compatible subset of the first vector by the transpose of this array to get the second. (This is matrix multiplication, not element-by-element multiplication.)

Parameters
[in]vFromA vector to be multiplied with the transpose of this matrix.
[out]vToA vector containing the result of the muliplication.
virtual EcBoolean EcReArray::underconstrainedNormal ( EcReArray squareResult) const
virtual

Finds the under-constrained normal equations. For input J, this gives J*J^T.

Parameters
[out]squareResultThe matrix J*J^T, where J is this matrix.
virtual EcBoolean EcReArray::writeBin ( const EcString fname) const
virtual

write out the data in binary format

Parameters
[in]fnameThe name of the file to write the data to.
Returns
True if succeeded or false otherwise.

The documentation for this class was generated from the following file:
Created by Energid Technologies www.energid.com
Copyright © 2016 Energid. All trademarks mentioned in this document are property of their respective owners.