Simbody  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SimTK::MatrixBase< ELT > Class Template Reference

This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large, variable-sized vectors and matrices. More...

+ Inheritance diagram for SimTK::MatrixBase< ELT >:

Classes

struct  EltResult
 

Public Types

enum  {
  NScalarsPerElement = CNT<E>::NActualScalars,
  CppNScalarsPerElement = sizeof(E) / sizeof(Scalar)
}
 
typedef ELT E
 
typedef CNT< E >::TNeg ENeg
 
typedef CNT< E >::TWithoutNegator EWithoutNegator
 
typedef CNT< E >::TReal EReal
 
typedef CNT< E >::TImag EImag
 
typedef CNT< E >::TComplex EComplex
 
typedef CNT< E >::THerm EHerm
 
typedef CNT< E >::TPosTrans EPosTrans
 
typedef CNT< E >::TAbs EAbs
 
typedef CNT< E >::TStandard EStandard
 
typedef CNT< E >::TInvert EInvert
 
typedef CNT< E >::TNormalize ENormalize
 
typedef CNT< E >::TSqHermT ESqHermT
 
typedef CNT< E >::TSqTHerm ESqTHerm
 
typedef CNT< E >::Scalar EScalar
 
typedef CNT< E >::Number ENumber
 
typedef CNT< E >::StdNumber EStdNumber
 
typedef CNT< E >::Precision EPrecision
 
typedef CNT< E >::ScalarNormSq EScalarNormSq
 
typedef EScalar Scalar
 
typedef ENumber Number
 
typedef EStdNumber StdNumber
 
typedef EPrecision Precision
 
typedef EScalarNormSq ScalarNormSq
 
typedef MatrixBase< ET
 
typedef MatrixBase< ENegTNeg
 
typedef MatrixBase
< EWithoutNegator
TWithoutNegator
 
typedef MatrixBase< ERealTReal
 
typedef MatrixBase< EImagTImag
 
typedef MatrixBase< EComplexTComplex
 
typedef MatrixBase< EHermTHerm
 
typedef MatrixBase< ETPosTrans
 
typedef MatrixBase< EAbsTAbs
 
typedef MatrixBase< EStandardTStandard
 
typedef MatrixBase< EInvertTInvert
 
typedef MatrixBase< ENormalizeTNormalize
 
typedef MatrixBase< ESqHermTTSqHermT
 
typedef MatrixBase< ESqTHermTSqTHerm
 

Public Member Functions

const MatrixCommitmentgetCharacterCommitment () const
 
const MatrixCharactergetMatrixCharacter () const
 
void commitTo (const MatrixCommitment &mc)
 Change the handle commitment for this matrix handle; only allowed if the handle is currently clear. More...
 
int nrow () const
 Return the number of rows m in the logical shape of this matrix. More...
 
int ncol () const
 Return the number of columns n in the logical shape of this matrix. More...
 
ptrdiff_t nelt () const
 Return the number of elements in the logical shape of this matrix. More...
 
bool isResizeable () const
 Return true if either dimension of this Matrix is resizable. More...
 
 MatrixBase ()
 The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars there are in one of our elements but is otherwise uncommitted. More...
 
 MatrixBase (int m, int n)
 This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions. More...
 
 MatrixBase (const MatrixCommitment &commitment)
 This constructor takes a handle commitment and allocates the default matrix for that kind of commitment. More...
 
 MatrixBase (const MatrixCommitment &commitment, int m, int n)
 This constructor takes a handle commitment and allocates the default matrix for that kind of commitment given particular initial minimum dimensions, which cannot be larger than those permitted by the commitment. More...
 
 MatrixBase (const MatrixBase &b)
 Copy constructor is a deep copy (not appropriate for views!). More...
 
 MatrixBase (const TNeg &b)
 Implicit conversion from matrix with negated elements (otherwise this is just like the copy constructor. More...
 
MatrixBasecopyAssign (const MatrixBase &b)
 Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match. More...
 
MatrixBaseoperator= (const MatrixBase &b)
 
MatrixBaseviewAssign (const MatrixBase &src)
 View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to refer to (destructing as necessary), then make it a new view for the data descriptor referenced by the source. More...
 
 MatrixBase (const MatrixCommitment &commitment, int m, int n, const ELT &initialValue)
 Initializing constructor with all of the initially-allocated elements initialized to the same value. More...
 
 MatrixBase (const MatrixCommitment &commitment, int m, int n, const ELT *cppInitialValuesByRow)
 Initializing constructor with the initially-allocated elements initialized from a C++ array of elements, which is provided in row major order. More...
 
 MatrixBase (const MatrixCommitment &commitment, MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
 
 MatrixBase (const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::ShallowCopy &shallow)
 
 MatrixBase (const MatrixCommitment &commitment, const MatrixHelper< Scalar > &source, const typename MatrixHelper< Scalar >::DeepCopy &deep)
 
void clear ()
 This restores the MatrixBase to the state it would be in had it been constructed specifying only its handle commitment. More...
 
MatrixBaseoperator*= (const StdNumber &t)
 
MatrixBaseoperator/= (const StdNumber &t)
 
MatrixBaseoperator+= (const MatrixBase &r)
 
MatrixBaseoperator-= (const MatrixBase &r)
 
template<class EE >
 MatrixBase (const MatrixBase< EE > &b)
 
template<class EE >
MatrixBaseoperator= (const MatrixBase< EE > &b)
 
template<class EE >
MatrixBaseoperator+= (const MatrixBase< EE > &b)
 
template<class EE >
MatrixBaseoperator-= (const MatrixBase< EE > &b)
 
MatrixBaseoperator= (const ELT &t)
 Matrix assignment to an element sets only the *diagonal* elements to the indicated value; everything else is set to zero. More...
 
template<class S >
MatrixBasescalarAssign (const S &s)
 Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero. More...
 
template<class S >
MatrixBasescalarAddInPlace (const S &s)
 Add a scalar to M's diagonal. More...
 
template<class S >
MatrixBasescalarSubtractInPlace (const S &s)
 Subtract a scalar from M's diagonal. More...
 
template<class S >
MatrixBasescalarSubtractFromLeftInPlace (const S &s)
 Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j. More...
 
template<class S >
MatrixBasescalarMultiplyInPlace (const S &)
 Set M(i,j) = M(i,j)*S for some "scalar" S. More...
 
template<class S >
MatrixBasescalarMultiplyFromLeftInPlace (const S &)
 Set M(i,j) = S * M(i,j) for some "scalar" S. More...
 
template<class S >
MatrixBasescalarDivideInPlace (const S &)
 Set M(i,j) = M(i,j)/S for some "scalar" S. More...
 
template<class S >
MatrixBasescalarDivideFromLeftInPlace (const S &)
 Set M(i,j) = S/M(i,j) for some "scalar" S. More...
 
template<class EE >
MatrixBaserowScaleInPlace (const VectorBase< EE > &)
 M = diag(r) * M; r must have nrow() elements. More...
 
template<class EE >
void rowScale (const VectorBase< EE > &r, typename EltResult< EE >::Mul &out) const
 Return type is a new matrix which will have the same dimensions as 'this' but will have element types appropriate for the elementwise multiply being performed. More...
 
template<class EE >
EltResult< EE >::Mul rowScale (const VectorBase< EE > &r) const
 
template<class EE >
MatrixBasecolScaleInPlace (const VectorBase< EE > &)
 M = M * diag(c); c must have ncol() elements. More...
 
template<class EE >
void colScale (const VectorBase< EE > &c, typename EltResult< EE >::Mul &out) const
 
template<class EE >
EltResult< EE >::Mul colScale (const VectorBase< EE > &c) const
 
template<class ER , class EC >
MatrixBaserowAndColScaleInPlace (const VectorBase< ER > &r, const VectorBase< EC > &c)
 M = diag(r) * M * diag(c); r must have nrow() elements; must have ncol() elements. More...
 
template<class ER , class EC >
void rowAndColScale (const VectorBase< ER > &r, const VectorBase< EC > &c, typename EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul &out) const
 
template<class ER , class EC >
EltResult< typename VectorBase
< ER >::template EltResult< EC >
::Mul >::Mul 
rowAndColScale (const VectorBase< ER > &r, const VectorBase< EC > &c) const
 
template<class S >
MatrixBaseelementwiseAssign (const S &s)
 Set M(i,j)=s for every element of M and some value s. More...
 
MatrixBaseelementwiseAssign (int s)
 Overloaded to allow an integer argument, which is converted to Real. More...
 
MatrixBaseelementwiseInvertInPlace ()
 Set M(i,j) = M(i,j)^-1. More...
 
void elementwiseInvert (MatrixBase< typename CNT< E >::TInvert > &out) const
 
MatrixBase< typename CNT< E >
::TInvert
elementwiseInvert () const
 
template<class S >
MatrixBaseelementwiseAddScalarInPlace (const S &s)
 Set M(i,j)+=s for every element of M and some value s. More...
 
template<class S >
void elementwiseAddScalar (const S &s, typename EltResult< S >::Add &) const
 
template<class S >
EltResult< S >::Add elementwiseAddScalar (const S &s) const
 
template<class S >
MatrixBaseelementwiseSubtractScalarInPlace (const S &s)
 Set M(i,j)-=s for every element of M and some value s. More...
 
template<class S >
void elementwiseSubtractScalar (const S &s, typename EltResult< S >::Sub &) const
 
template<class S >
EltResult< S >::Sub elementwiseSubtractScalar (const S &s) const
 
template<class S >
MatrixBaseelementwiseSubtractFromScalarInPlace (const S &s)
 Set M(i,j) = s - M(i,j) for every element of M and some value s. More...
 
template<class S >
void elementwiseSubtractFromScalar (const S &, typename MatrixBase< S >::template EltResult< E >::Sub &) const
 
template<class S >
MatrixBase< S >::template
EltResult< E >::Sub 
elementwiseSubtractFromScalar (const S &s) const
 
template<class EE >
MatrixBaseelementwiseMultiplyInPlace (const MatrixBase< EE > &)
 M(i,j) *= R(i,j); R must have same dimensions as this. More...
 
template<class EE >
void elementwiseMultiply (const MatrixBase< EE > &, typename EltResult< EE >::Mul &) const
 
template<class EE >
EltResult< EE >::Mul elementwiseMultiply (const MatrixBase< EE > &m) const
 
template<class EE >
MatrixBaseelementwiseMultiplyFromLeftInPlace (const MatrixBase< EE > &)
 M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this. More...
 
template<class EE >
void elementwiseMultiplyFromLeft (const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Mul &) const
 
template<class EE >
MatrixBase< EE >::template
EltResult< E >::Mul 
elementwiseMultiplyFromLeft (const MatrixBase< EE > &m) const
 
template<class EE >
MatrixBaseelementwiseDivideInPlace (const MatrixBase< EE > &)
 M(i,j) /= R(i,j); R must have same dimensions as this. More...
 
template<class EE >
void elementwiseDivide (const MatrixBase< EE > &, typename EltResult< EE >::Dvd &) const
 
template<class EE >
EltResult< EE >::Dvd elementwiseDivide (const MatrixBase< EE > &m) const
 
template<class EE >
MatrixBaseelementwiseDivideFromLeftInPlace (const MatrixBase< EE > &)
 M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this. More...
 
template<class EE >
void elementwiseDivideFromLeft (const MatrixBase< EE > &, typename MatrixBase< EE >::template EltResult< E >::Dvd &) const
 
template<class EE >
MatrixBase< EE >::template
EltResult< EE >::Dvd 
elementwiseDivideFromLeft (const MatrixBase< EE > &m) const
 
MatrixBasesetTo (const ELT &t)
 Fill every element in current allocation with given element (or NaN or 0). More...
 
MatrixBasesetToNaN ()
 
MatrixBasesetToZero ()
 
RowVectorView_< ELT > row (int i) const
 
RowVectorView_< ELT > updRow (int i)
 
VectorView_< ELT > col (int j) const
 
VectorView_< ELT > updCol (int j)
 
RowVectorView_< ELT > operator[] (int i) const
 
RowVectorView_< ELT > operator[] (int i)
 
VectorView_< ELT > operator() (int j) const
 
VectorView_< ELT > operator() (int j)
 
MatrixView_< ELT > block (int i, int j, int m, int n) const
 
MatrixView_< ELT > updBlock (int i, int j, int m, int n)
 
MatrixView_< ELT > operator() (int i, int j, int m, int n) const
 
MatrixView_< ELT > operator() (int i, int j, int m, int n)
 
MatrixView_< EHermtranspose () const
 
MatrixView_< EHermupdTranspose ()
 
MatrixView_< EHermoperator~ () const
 
MatrixView_< EHermoperator~ ()
 
VectorView_< ELT > diag () const
 Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of the diagonal elements of this Matrix. More...
 
VectorView_< ELT > updDiag ()
 Select main diagonal (of largest leading square if rectangular) and return it as a writable view of the diagonal elements of this Matrix. More...
 
VectorView_< ELT > diag ()
 This non-const version of diag() is an alternate name for updDiag() available for historical reasons. More...
 
TInvert invert () const
 
void invertInPlace ()
 
void dump (const char *msg=0) const
 Matlab-compatible debug output. More...
 
const ELT & getElt (int i, int j) const
 Element selection for stored elements. More...
 
ELT & updElt (int i, int j)
 
const ELT & operator() (int i, int j) const
 
ELT & operator() (int i, int j)
 
void getAnyElt (int i, int j, ELT &value) const
 This returns a copy of the element value for any position in the logical matrix, regardless of whether it is stored in memory. More...
 
ELT getAnyElt (int i, int j) const
 
ScalarNormSq scalarNormSqr () const
 Scalar norm square is sum( squares of all scalars ). More...
 
void abs (TAbs &mabs) const
 abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix but with each element replaced by whatever it thinks its absolute value is. More...
 
TAbs abs () const
 abs() with the result as a function return. More...
 
TStandard standardize () const
 Return a Matrix of the same shape and contents as this one but with the element type converted to one based on the standard C++ scalar types: float, double, complex<float>, complex<double>. More...
 
ScalarNormSq normSqr () const
 This is the scalar Frobenius norm, and its square. More...
 
CNT< ScalarNormSq >::TSqrt norm () const
 
CNT< ScalarNormSq >::TSqrt normRMS () const
 We only allow RMS norm if the elements are scalars. More...
 
RowVector_< ELT > colSum () const
 Form the column sums of this matrix, returned as a RowVector. More...
 
RowVector_< ELT > sum () const
 Alternate name for colSum(); behaves like the Matlab function sum(). More...
 
Vector_< ELT > rowSum () const
 Form the row sums of this matrix, returned as a Vector. More...
 
const MatrixBaseoperator+ () const
 
const TNegnegate () const
 
TNegupdNegate ()
 
const TNegoperator- () const
 
TNegoperator- ()
 
MatrixBasenegateInPlace ()
 
MatrixBaseresize (int m, int n)
 Change the size of this matrix. More...
 
MatrixBaseresizeKeep (int m, int n)
 Change the size of this matrix, retaining as much of the old data as will fit. More...
 
void lockShape ()
 
void unlockShape ()
 
const MatrixView_< ELT > & getAsMatrixView () const
 
MatrixView_< ELT > & updAsMatrixView ()
 
const Matrix_< ELT > & getAsMatrix () const
 
Matrix_< ELT > & updAsMatrix ()
 
const VectorView_< ELT > & getAsVectorView () const
 
VectorView_< ELT > & updAsVectorView ()
 
const Vector_< ELT > & getAsVector () const
 
Vector_< ELT > & updAsVector ()
 
const VectorBase< ELT > & getAsVectorBase () const
 
VectorBase< ELT > & updAsVectorBase ()
 
const RowVectorView_< ELT > & getAsRowVectorView () const
 
RowVectorView_< ELT > & updAsRowVectorView ()
 
const RowVector_< ELT > & getAsRowVector () const
 
RowVector_< ELT > & updAsRowVector ()
 
const RowVectorBase< ELT > & getAsRowVectorBase () const
 
RowVectorBase< ELT > & updAsRowVectorBase ()
 
int getNScalarsPerElement () const
 This is the number of consecutive scalars used to represent one element of type ELT. More...
 
int getPackedSizeofElement () const
 This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be fewer than what C++ would use. More...
 
bool hasContiguousData () const
 
ptrdiff_t getContiguousScalarDataLength () const
 
const ScalargetContiguousScalarData () const
 
ScalarupdContiguousScalarData ()
 
void replaceContiguousScalarData (Scalar *newData, ptrdiff_t length, bool takeOwnership)
 
void replaceContiguousScalarData (const Scalar *newData, ptrdiff_t length)
 
void swapOwnedContiguousScalarData (Scalar *newData, ptrdiff_t length, Scalar *&oldData)
 
 MatrixBase (MatrixHelperRep< Scalar > *hrep)
 Helper rep-stealing constructor. More...
 
template<class EE >
MatrixBase< ELT > & rowScaleInPlace (const VectorBase< EE > &v)
 
template<class EE >
void rowScale (const VectorBase< EE > &v, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const
 
template<class EE >
MatrixBase< ELT > & colScaleInPlace (const VectorBase< EE > &v)
 
template<class EE >
void colScale (const VectorBase< EE > &v, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const
 
template<class ER , class EC >
MatrixBase< ELT > & rowAndColScaleInPlace (const VectorBase< ER > &r, const VectorBase< EC > &c)
 
template<class S >
MatrixBase< ELT > & elementwiseAssign (const S &s)
 
template<class S >
MatrixBase< ELT > & elementwiseAddScalarInPlace (const S &s)
 
template<class S >
void elementwiseAddScalar (const S &s, typename MatrixBase< ELT >::template EltResult< S >::Add &out) const
 
template<class S >
MatrixBase< ELT > & elementwiseSubtractScalarInPlace (const S &s)
 
template<class S >
void elementwiseSubtractScalar (const S &s, typename MatrixBase< ELT >::template EltResult< S >::Sub &out) const
 
template<class S >
MatrixBase< ELT > & elementwiseSubtractFromScalarInPlace (const S &s)
 
template<class EE >
MatrixBase< ELT > & elementwiseMultiplyInPlace (const MatrixBase< EE > &r)
 
template<class EE >
void elementwiseMultiply (const MatrixBase< EE > &r, typename MatrixBase< ELT >::template EltResult< EE >::Mul &out) const
 
template<class EE >
MatrixBase< ELT > & elementwiseMultiplyFromLeftInPlace (const MatrixBase< EE > &r)
 
template<class EE >
MatrixBase< ELT > & elementwiseDivideInPlace (const MatrixBase< EE > &r)
 
template<class EE >
void elementwiseDivide (const MatrixBase< EE > &r, typename MatrixBase< ELT >::template EltResult< EE >::Dvd &out) const
 
template<class EE >
MatrixBase< ELT > & elementwiseDivideFromLeftInPlace (const MatrixBase< EE > &r)
 
Matrix view of pre-exising data

Non-resizeable view of someone else's already-allocated memory of a size and storage type indicated by the supplied MatrixCharacter.

The spacing argument has different interpretations depending on the storage format. Typically it is the leading dimension for Lapack-style full storage or stride for a vector. Spacing is in units like "number of scalars between elements" or "number of scalars between columns" so it can be used to deal with C++ packing vs. Simmatrix packing if necessary.

 MatrixBase (const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, const Scalar *data)
 Construct a read-only view of pre-existing data. More...
 
 MatrixBase (const MatrixCommitment &commitment, const MatrixCharacter &character, int spacing, Scalar *data)
 Construct a writable view of pre-existing data. More...
 

Protected Member Functions

const MatrixHelper< Scalar > & getHelper () const
 
MatrixHelper< Scalar > & updHelper ()
 

Friends

template<class EE >
class MatrixBase
 

Related Functions

(Note that these are not member functions.)

Matrix_<T> serialization and I/O

These methods are at namespace scope but are logically part of the Vector classes.

These deal with reading and writing Vectors from and to streams, which places an additional requirement on the element type T: the element must support the same operation you are trying to do on the Vector as a whole.

template<class E >
void writeUnformatted (std::ostream &o, const MatrixBase< E > &v)
 Specialize for MatrixBase<E> delegating to RowVectorBase<E> with newlines separating the rows, but no final newline. More...
 

Detailed Description

template<class ELT>
class SimTK::MatrixBase< ELT >

This is the common base class for Simbody's Vector_ and Matrix_ classes for handling large, variable-sized vectors and matrices.

MatrixBase does not normally appear in user programs. Instead classes Vector_ and Matrix_ are used, or more commonly the typedefs Vector and Matrix which are abbreviations for Vector_<Real> and Matrix_<Real>.

Matrix base is a variable-size 2d matrix of Composite Numerical Type (CNT) elements. This is a container of such elements, it is NOT a Composite Numerical Type itself.

Implementation

MatrixBase<ELT> uses MatrixHelper<S> for implementation, where S is ELT::Scalar, that is, the underlying float, double, long double, complex<float>, negator<conjugate<double>>, etc. from which ELT is constructed. This is a finite set of which all members are explicitly instantiated in the implementation code, so clients don't have to know how anything is implemented.

MatrixBase is the only class in the Matrix/Vector family which has any data members (it has exactly one MatrixHelper, which itself consists only of a single pointer to an opaque class). Thus all other objects in this family (that is, derived from MatrixBase) are exactly the same size in memory and may be "reinterpreted" as appropriate. For example, a Vector may be reinterpreted as a Matrix or vice versa, provided runtime requirements are met (e.g., exactly 1 column).

Unlike the small matrix classes, very little is encoded in the type. Only the element type, and matrix vs. vector vs. row are in the type; everything else like shape, storage layout, and writability are handled at run time.

Member Typedef Documentation

template<class ELT>
typedef ELT SimTK::MatrixBase< ELT >::E
template<class ELT>
typedef CNT<E>::TNeg SimTK::MatrixBase< ELT >::ENeg
template<class ELT>
typedef CNT<E>::TWithoutNegator SimTK::MatrixBase< ELT >::EWithoutNegator
template<class ELT>
typedef CNT<E>::TReal SimTK::MatrixBase< ELT >::EReal
template<class ELT>
typedef CNT<E>::TImag SimTK::MatrixBase< ELT >::EImag
template<class ELT>
typedef CNT<E>::TComplex SimTK::MatrixBase< ELT >::EComplex
template<class ELT>
typedef CNT<E>::THerm SimTK::MatrixBase< ELT >::EHerm
template<class ELT>
typedef CNT<E>::TPosTrans SimTK::MatrixBase< ELT >::EPosTrans
template<class ELT>
typedef CNT<E>::TAbs SimTK::MatrixBase< ELT >::EAbs
template<class ELT>
typedef CNT<E>::TStandard SimTK::MatrixBase< ELT >::EStandard
template<class ELT>
typedef CNT<E>::TInvert SimTK::MatrixBase< ELT >::EInvert
template<class ELT>
typedef CNT<E>::TNormalize SimTK::MatrixBase< ELT >::ENormalize
template<class ELT>
typedef CNT<E>::TSqHermT SimTK::MatrixBase< ELT >::ESqHermT
template<class ELT>
typedef CNT<E>::TSqTHerm SimTK::MatrixBase< ELT >::ESqTHerm
template<class ELT>
typedef CNT<E>::Scalar SimTK::MatrixBase< ELT >::EScalar
template<class ELT>
typedef CNT<E>::Number SimTK::MatrixBase< ELT >::ENumber
template<class ELT>
typedef CNT<E>::StdNumber SimTK::MatrixBase< ELT >::EStdNumber
template<class ELT>
typedef CNT<E>::Precision SimTK::MatrixBase< ELT >::EPrecision
template<class ELT>
typedef CNT<E>::ScalarNormSq SimTK::MatrixBase< ELT >::EScalarNormSq
template<class ELT>
typedef EScalar SimTK::MatrixBase< ELT >::Scalar
template<class ELT>
typedef ENumber SimTK::MatrixBase< ELT >::Number
template<class ELT>
typedef EStdNumber SimTK::MatrixBase< ELT >::StdNumber
template<class ELT>
typedef EPrecision SimTK::MatrixBase< ELT >::Precision
template<class ELT>
typedef EScalarNormSq SimTK::MatrixBase< ELT >::ScalarNormSq
template<class ELT>
typedef MatrixBase<E> SimTK::MatrixBase< ELT >::T
template<class ELT>
typedef MatrixBase<ENeg> SimTK::MatrixBase< ELT >::TNeg
template<class ELT>
typedef MatrixBase<EWithoutNegator> SimTK::MatrixBase< ELT >::TWithoutNegator
template<class ELT>
typedef MatrixBase<EReal> SimTK::MatrixBase< ELT >::TReal
template<class ELT>
typedef MatrixBase<EImag> SimTK::MatrixBase< ELT >::TImag
template<class ELT>
typedef MatrixBase<EComplex> SimTK::MatrixBase< ELT >::TComplex
template<class ELT>
typedef MatrixBase<EHerm> SimTK::MatrixBase< ELT >::THerm
template<class ELT>
typedef MatrixBase<E> SimTK::MatrixBase< ELT >::TPosTrans
template<class ELT>
typedef MatrixBase<EAbs> SimTK::MatrixBase< ELT >::TAbs
template<class ELT>
typedef MatrixBase<EStandard> SimTK::MatrixBase< ELT >::TStandard
template<class ELT>
typedef MatrixBase<EInvert> SimTK::MatrixBase< ELT >::TInvert
template<class ELT>
typedef MatrixBase<ENormalize> SimTK::MatrixBase< ELT >::TNormalize
template<class ELT>
typedef MatrixBase<ESqHermT> SimTK::MatrixBase< ELT >::TSqHermT
template<class ELT>
typedef MatrixBase<ESqTHerm> SimTK::MatrixBase< ELT >::TSqTHerm

Member Enumeration Documentation

template<class ELT>
anonymous enum
Enumerator
NScalarsPerElement 
CppNScalarsPerElement 

Constructor & Destructor Documentation

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( )
inline

The default constructor builds a 0x0 matrix managed by a helper that understands how many scalars there are in one of our elements but is otherwise uncommitted.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( int  m,
int  n 
)
inline

This constructor allocates the default matrix a completely uncommitted matrix commitment, given particular initial dimensions.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment)
inlineexplicit

This constructor takes a handle commitment and allocates the default matrix for that kind of commitment.

If a dimension is set to a particular (unchangeable) value in the commitment then the initial allocation will use that value. Unlocked dimensions are given the smallest value consistent with other committed attributes, typically 0.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
int  m,
int  n 
)
inline

This constructor takes a handle commitment and allocates the default matrix for that kind of commitment given particular initial minimum dimensions, which cannot be larger than those permitted by the commitment.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixBase< ELT > &  b)
inline

Copy constructor is a deep copy (not appropriate for views!).

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const TNeg b)
inline

Implicit conversion from matrix with negated elements (otherwise this is just like the copy constructor.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
int  m,
int  n,
const ELT &  initialValue 
)
inline

Initializing constructor with all of the initially-allocated elements initialized to the same value.

The given dimensions are treated as minimum dimensions in case the commitment requires more. So it is always permissible to set them both to 0 in which case you'll get the smallest matrix that satisfies the commitment, with each of its elements (if any) set to the given initial value.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
int  m,
int  n,
const ELT *  cppInitialValuesByRow 
)
inline

Initializing constructor with the initially-allocated elements initialized from a C++ array of elements, which is provided in row major order.

The given dimensions are treated as minimum dimensions in case the commitment requires more. The array is presumed to be long enough to supply a value for each element. Note that C++ packing for elements may be different than Simmatrix packing of the same elements (Simmatrix packs them more tightly in some cases). So you should not use this constructor to copy elements from one Simmatrix matrix to another; this is exclusively for initializing a Simmatrix from a C++ array.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
const MatrixCharacter character,
int  spacing,
const Scalar data 
)
inline

Construct a read-only view of pre-existing data.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
const MatrixCharacter character,
int  spacing,
Scalar data 
)
inline

Construct a writable view of pre-existing data.

template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
MatrixHelper< Scalar > &  source,
const typename MatrixHelper< Scalar >::ShallowCopy &  shallow 
)
inline
template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
const MatrixHelper< Scalar > &  source,
const typename MatrixHelper< Scalar >::ShallowCopy &  shallow 
)
inline
template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixCommitment commitment,
const MatrixHelper< Scalar > &  source,
const typename MatrixHelper< Scalar >::DeepCopy &  deep 
)
inline
template<class ELT>
template<class EE >
SimTK::MatrixBase< ELT >::MatrixBase ( const MatrixBase< EE > &  b)
inline
template<class ELT>
SimTK::MatrixBase< ELT >::MatrixBase ( MatrixHelperRep< Scalar > *  hrep)
inlineexplicit

Helper rep-stealing constructor.

We take over ownership of this rep here. Note that this defines the handle commitment for this handle. This is intended for internal use only – don't call this constructor unless you really know what you're doing.

Member Function Documentation

template<class ELT>
const MatrixCommitment& SimTK::MatrixBase< ELT >::getCharacterCommitment ( ) const
inline
template<class ELT>
const MatrixCharacter& SimTK::MatrixBase< ELT >::getMatrixCharacter ( ) const
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::commitTo ( const MatrixCommitment mc)
inline

Change the handle commitment for this matrix handle; only allowed if the handle is currently clear.

template<class ELT>
int SimTK::MatrixBase< ELT >::nrow ( ) const
inline

Return the number of rows m in the logical shape of this matrix.

template<class ELT>
int SimTK::MatrixBase< ELT >::ncol ( ) const
inline

Return the number of columns n in the logical shape of this matrix.

template<class ELT>
ptrdiff_t SimTK::MatrixBase< ELT >::nelt ( ) const
inline

Return the number of elements in the logical shape of this matrix.

This has nothing to do with how many elements are actually stored; it is simply the product of the logical number of rows and columns, that is, nrow()*ncol(). Note that although each dimension is limited to a 32 bit size, the product of those dimensions may be > 32 bits on a 64 bit machine so the return type may be larger than that of nrow() and ncol().

template<class ELT>
bool SimTK::MatrixBase< ELT >::isResizeable ( ) const
inline

Return true if either dimension of this Matrix is resizable.

template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::copyAssign ( const MatrixBase< ELT > &  b)
inline

Copy assignment is a deep copy but behavior depends on type of lhs: if view, rhs must match.

If owner, we reallocate and copy rhs.

template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator= ( const MatrixBase< ELT > &  b)
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::viewAssign ( const MatrixBase< ELT > &  src)
inline

View assignment is a shallow copy, meaning that we disconnect the MatrixBase from whatever it used to refer to (destructing as necessary), then make it a new view for the data descriptor referenced by the source.

CAUTION: we always take the source as const, but that is ignored in determining whether the resulting view is writable. Instead, that is inherited from the writability status of the source. We have to do this in order to allow temporary view objects to be writable – the compiler creates temporaries like m(i,j,m,n) as const.

template<class ELT>
void SimTK::MatrixBase< ELT >::clear ( )
inline

This restores the MatrixBase to the state it would be in had it been constructed specifying only its handle commitment.

The size will have been reduced to the smallest size consistent with the commitment.

template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator*= ( const StdNumber t)
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator/= ( const StdNumber t)
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator+= ( const MatrixBase< ELT > &  r)
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator-= ( const MatrixBase< ELT > &  r)
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::operator= ( const MatrixBase< EE > &  b)
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::operator+= ( const MatrixBase< EE > &  b)
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::operator-= ( const MatrixBase< EE > &  b)
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::operator= ( const ELT &  t)
inline

Matrix assignment to an element sets only the *diagonal* elements to the indicated value; everything else is set to zero.

This is particularly useful for setting a Matrix to zero or to the identity; for other values it creates a Matrix which acts like the scalar. That is, if the scalar is s and we do M=s, then multiplying another Matrix B by the resulting diagonal matrix M gives the same result as multiplying B by s. That is (M=s)*B == s*B.

NOTE: this must be overridden for Vector and RowVector since then scalar assignment is defined to copy the scalar to every element.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarAssign ( const S &  s)
inline

Set M's diagonal elements to a "scalar" value S, and all off-diagonal elements to zero.

S can be any type which is assignable to an element of type E. This is the same as the Matrix assignment operator M=S for a scalar type S. It is overriden for Vector and Row types to behave as elementwiseScalarAssign.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarAddInPlace ( const S &  s)
inline

Add a scalar to M's diagonal.

This is the same as the Matrix += operator. This is overridden for Vector and Row types to behave as elementwiseAddScalarInPlace.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarSubtractInPlace ( const S &  s)
inline

Subtract a scalar from M's diagonal.

This is the same as the Matrix -= operator. This is overridden for Vector and Row types to behave as elementwiseSubtractScalarInPlace.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarSubtractFromLeftInPlace ( const S &  s)
inline

Set M(i,i) = S - M(i,i), M(i,j) = -M(i,j) for i!=j.

This is overridden for Vector and Row types to behave as elementwiseSubtractFromScalarInPlace.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarMultiplyInPlace ( const S &  )
inline

Set M(i,j) = M(i,j)*S for some "scalar" S.

Actually S can be any type for which E = E*S makes sense. That is, S must be conformant with E and it must be possible to store the result back in an E. This is the *= operator for M *= S and behaves the same way for Matrix, Vector, and RowVector: every element gets multiplied in place on the right by S.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarMultiplyFromLeftInPlace ( const S &  )
inline

Set M(i,j) = S * M(i,j) for some "scalar" S.

This is the same as the above routine if S really is a scalar, but for S a more complicated CNT it will be different.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarDivideInPlace ( const S &  )
inline

Set M(i,j) = M(i,j)/S for some "scalar" S.

Actually S can be any type for which E = E/S makes sense. That is, S^-1 must be conformant with E and it must be possible to store the result back in an E. This is the /= operator for M /= S and behaves the same way for Matrix, Vector, and RowVector: every element gets divided in place on the right by S.

template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::scalarDivideFromLeftInPlace ( const S &  )
inline

Set M(i,j) = S/M(i,j) for some "scalar" S.

Actually S can be any type for which E = S/E makes sense. That is, S must be conformant with E^-1 and it must be possible to store the result back in an E.

template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::rowScaleInPlace ( const VectorBase< EE > &  )
inline

M = diag(r) * M; r must have nrow() elements.

That is, M[i] *= r[i].

template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::rowScale ( const VectorBase< EE > &  r,
typename EltResult< EE >::Mul &  out 
) const
inline

Return type is a new matrix which will have the same dimensions as 'this' but will have element types appropriate for the elementwise multiply being performed.

template<class ELT>
template<class EE >
EltResult<EE>::Mul SimTK::MatrixBase< ELT >::rowScale ( const VectorBase< EE > &  r) const
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::colScaleInPlace ( const VectorBase< EE > &  )
inline

M = M * diag(c); c must have ncol() elements.

That is, M(j) *= c[j].

template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::colScale ( const VectorBase< EE > &  c,
typename EltResult< EE >::Mul &  out 
) const
inline
template<class ELT>
template<class EE >
EltResult<EE>::Mul SimTK::MatrixBase< ELT >::colScale ( const VectorBase< EE > &  c) const
inline
template<class ELT>
template<class ER , class EC >
MatrixBase& SimTK::MatrixBase< ELT >::rowAndColScaleInPlace ( const VectorBase< ER > &  r,
const VectorBase< EC > &  c 
)
inline

M = diag(r) * M * diag(c); r must have nrow() elements; must have ncol() elements.

That is, M(i,j) *= r[i]*c[j]. Having a combined row & column scaling operator means we can go through the matrix memory once instead of twice.

template<class ELT >
template<class ER , class EC >
void SimTK::MatrixBase< ELT >::rowAndColScale ( const VectorBase< ER > &  r,
const VectorBase< EC > &  c,
typename EltResult< typename VectorBase< ER >::template EltResult< EC >::Mul >::Mul &  out 
) const
inline
template<class ELT>
template<class ER , class EC >
EltResult<typename VectorBase<ER>::template EltResult<EC>::Mul>::Mul SimTK::MatrixBase< ELT >::rowAndColScale ( const VectorBase< ER > &  r,
const VectorBase< EC > &  c 
) const
inline
template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseAssign ( const S &  s)
inline

Set M(i,j)=s for every element of M and some value s.

This requires only that s be assignment compatible with M's elements; s doesn't actually have to be a scalar. Note that for Matrix types this behavior is different than scalar assignment, which puts the scalar only on M's diagonal and sets the rest of M to zero. For Vector and RowVector types, this operator is identical to the normal assignment operator and scalarAssignInPlace() method which also assign the scalar to every element.

template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseAssign ( int  s)
inline

Overloaded to allow an integer argument, which is converted to Real.

template<class ELT >
MatrixBase< ELT > & SimTK::MatrixBase< ELT >::elementwiseInvertInPlace ( )
inline

Set M(i,j) = M(i,j)^-1.

template<class ELT >
void SimTK::MatrixBase< ELT >::elementwiseInvert ( MatrixBase< typename CNT< E >::TInvert > &  out) const
inline
template<class ELT>
MatrixBase<typename CNT<E>::TInvert> SimTK::MatrixBase< ELT >::elementwiseInvert ( ) const
inline
template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseAddScalarInPlace ( const S &  s)
inline

Set M(i,j)+=s for every element of M and some value s.

This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the normal += or scalarAddInPlace() operators, which add the scalar only to the Matrix diagonal. For Vector and RowVector, this operator is identical to += and scalarAddInPlace() which also add the scalar to every element.

template<class ELT>
template<class S >
void SimTK::MatrixBase< ELT >::elementwiseAddScalar ( const S &  s,
typename EltResult< S >::Add &   
) const
inline
template<class ELT>
template<class S >
EltResult<S>::Add SimTK::MatrixBase< ELT >::elementwiseAddScalar ( const S &  s) const
inline
template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseSubtractScalarInPlace ( const S &  s)
inline

Set M(i,j)-=s for every element of M and some value s.

This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the normal -= or scalarSubtractInPlace() operators, which subtract the scalar only from the Matrix diagonal. For Vector and RowVector, this operator is identical to -= and scalarSubtractInPlace() which also subtract the scalar from every element.

template<class ELT>
template<class S >
void SimTK::MatrixBase< ELT >::elementwiseSubtractScalar ( const S &  s,
typename EltResult< S >::Sub &   
) const
inline
template<class ELT>
template<class S >
EltResult<S>::Sub SimTK::MatrixBase< ELT >::elementwiseSubtractScalar ( const S &  s) const
inline
template<class ELT>
template<class S >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseSubtractFromScalarInPlace ( const S &  s)
inline

Set M(i,j) = s - M(i,j) for every element of M and some value s.

This requires that s be conformant with M's elements (of type E) and that the result can be stored in an E. For Matrix types this behavior is different than the scalarSubtractFromLeftInPlace() operator, which subtracts only the diagonal elements of M from s, while simply negating the off diagonal elements. For Vector and RowVector, this operator is identical to scalarSubtractFromLeftInPlace() which also subtracts every element of M from the scalar.

template<class ELT >
template<class S >
void SimTK::MatrixBase< ELT >::elementwiseSubtractFromScalar ( const S &  s,
typename MatrixBase< S >::template EltResult< E >::Sub &  out 
) const
inline
template<class ELT>
template<class S >
MatrixBase<S>::template EltResult<E>::Sub SimTK::MatrixBase< ELT >::elementwiseSubtractFromScalar ( const S &  s) const
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseMultiplyInPlace ( const MatrixBase< EE > &  )
inline

M(i,j) *= R(i,j); R must have same dimensions as this.

template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseMultiply ( const MatrixBase< EE > &  ,
typename EltResult< EE >::Mul &   
) const
inline
template<class ELT>
template<class EE >
EltResult<EE>::Mul SimTK::MatrixBase< ELT >::elementwiseMultiply ( const MatrixBase< EE > &  m) const
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseMultiplyFromLeftInPlace ( const MatrixBase< EE > &  )
inline

M(i,j) = R(i,j) * M(i,j); R must have same dimensions as this.

template<class ELT >
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseMultiplyFromLeft ( const MatrixBase< EE > &  r,
typename MatrixBase< EE >::template EltResult< E >::Mul &  out 
) const
inline
template<class ELT>
template<class EE >
MatrixBase<EE>::template EltResult<E>::Mul SimTK::MatrixBase< ELT >::elementwiseMultiplyFromLeft ( const MatrixBase< EE > &  m) const
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseDivideInPlace ( const MatrixBase< EE > &  )
inline

M(i,j) /= R(i,j); R must have same dimensions as this.

template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseDivide ( const MatrixBase< EE > &  ,
typename EltResult< EE >::Dvd &   
) const
inline
template<class ELT>
template<class EE >
EltResult<EE>::Dvd SimTK::MatrixBase< ELT >::elementwiseDivide ( const MatrixBase< EE > &  m) const
inline
template<class ELT>
template<class EE >
MatrixBase& SimTK::MatrixBase< ELT >::elementwiseDivideFromLeftInPlace ( const MatrixBase< EE > &  )
inline

M(i,j) = R(i,j) / M(i,j); R must have same dimensions as this.

template<class ELT >
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseDivideFromLeft ( const MatrixBase< EE > &  r,
typename MatrixBase< EE >::template EltResult< E >::Dvd &  out 
) const
inline
template<class ELT>
template<class EE >
MatrixBase<EE>::template EltResult<EE>::Dvd SimTK::MatrixBase< ELT >::elementwiseDivideFromLeft ( const MatrixBase< EE > &  m) const
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::setTo ( const ELT &  t)
inline

Fill every element in current allocation with given element (or NaN or 0).

template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::setToNaN ( )
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::setToZero ( )
inline
template<class ELT >
RowVectorView_< ELT > SimTK::MatrixBase< ELT >::row ( int  i) const
inline
template<class ELT >
RowVectorView_< ELT > SimTK::MatrixBase< ELT >::updRow ( int  i)
inline
template<class ELT >
VectorView_< ELT > SimTK::MatrixBase< ELT >::col ( int  j) const
inline
template<class ELT >
VectorView_< ELT > SimTK::MatrixBase< ELT >::updCol ( int  j)
inline
template<class ELT>
RowVectorView_<ELT> SimTK::MatrixBase< ELT >::operator[] ( int  i) const
inline
template<class ELT>
RowVectorView_<ELT> SimTK::MatrixBase< ELT >::operator[] ( int  i)
inline
template<class ELT>
VectorView_<ELT> SimTK::MatrixBase< ELT >::operator() ( int  j) const
inline
template<class ELT>
VectorView_<ELT> SimTK::MatrixBase< ELT >::operator() ( int  j)
inline
template<class ELT >
MatrixView_< ELT > SimTK::MatrixBase< ELT >::block ( int  i,
int  j,
int  m,
int  n 
) const
inline
template<class ELT >
MatrixView_< ELT > SimTK::MatrixBase< ELT >::updBlock ( int  i,
int  j,
int  m,
int  n 
)
inline
template<class ELT>
MatrixView_<ELT> SimTK::MatrixBase< ELT >::operator() ( int  i,
int  j,
int  m,
int  n 
) const
inline
template<class ELT>
MatrixView_<ELT> SimTK::MatrixBase< ELT >::operator() ( int  i,
int  j,
int  m,
int  n 
)
inline
template<class E >
MatrixView_< typename CNT< E >::THerm > SimTK::MatrixBase< E >::transpose ( ) const
inline
template<class E >
MatrixView_< typename CNT< E >::THerm > SimTK::MatrixBase< E >::updTranspose ( )
inline
template<class ELT>
MatrixView_<EHerm> SimTK::MatrixBase< ELT >::operator~ ( ) const
inline
template<class ELT>
MatrixView_<EHerm> SimTK::MatrixBase< ELT >::operator~ ( )
inline
template<class E >
VectorView_< E > SimTK::MatrixBase< E >::diag ( ) const
inline

Select main diagonal (of largest leading square if rectangular) and return it as a read-only view of the diagonal elements of this Matrix.

template<class E >
VectorView_< E > SimTK::MatrixBase< E >::updDiag ( )
inline

Select main diagonal (of largest leading square if rectangular) and return it as a writable view of the diagonal elements of this Matrix.

template<class ELT>
VectorView_<ELT> SimTK::MatrixBase< ELT >::diag ( )
inline

This non-const version of diag() is an alternate name for updDiag() available for historical reasons.

template<class ELT>
TInvert SimTK::MatrixBase< ELT >::invert ( ) const
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::invertInPlace ( )
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::dump ( const char *  msg = 0) const
inline

Matlab-compatible debug output.

template<class ELT>
const ELT& SimTK::MatrixBase< ELT >::getElt ( int  i,
int  j 
) const
inline

Element selection for stored elements.

These are the fastest element access methods but may not be able to access all elements of the logical matrix when some of its elements are not stored in memory. For example, a Hermitian matrix stores only half its elements and other ones have to be calculated by conjugation if they are to be returned as type ELT. (You can get them for free by recasting the matrix so that the elements are reinterpreted as conjugates.) If you want to guarantee that you can access the value of every element of a matrix, stored or not, use getAnyElt() instead.

template<class ELT>
ELT& SimTK::MatrixBase< ELT >::updElt ( int  i,
int  j 
)
inline
template<class ELT>
const ELT& SimTK::MatrixBase< ELT >::operator() ( int  i,
int  j 
) const
inline
template<class ELT>
ELT& SimTK::MatrixBase< ELT >::operator() ( int  i,
int  j 
)
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::getAnyElt ( int  i,
int  j,
ELT &  value 
) const
inline

This returns a copy of the element value for any position in the logical matrix, regardless of whether it is stored in memory.

If necessary the element's value is calculated. This is much slower than getElt() but less restrictive.

See also
getElt()
template<class ELT>
ELT SimTK::MatrixBase< ELT >::getAnyElt ( int  i,
int  j 
) const
inline
template<class ELT>
ScalarNormSq SimTK::MatrixBase< ELT >::scalarNormSqr ( ) const
inline

Scalar norm square is sum( squares of all scalars ).

Note that this is not very useful unless the elements are themselves scalars.

template<class ELT>
void SimTK::MatrixBase< ELT >::abs ( TAbs mabs) const
inline

abs() is elementwise absolute value; that is, the return value has the same dimension as this Matrix but with each element replaced by whatever it thinks its absolute value is.

template<class ELT>
TAbs SimTK::MatrixBase< ELT >::abs ( ) const
inline

abs() with the result as a function return.

More convenient than the other abs() member function, but may involve an additional copy of the matrix.

template<class ELT>
TStandard SimTK::MatrixBase< ELT >::standardize ( ) const
inline

Return a Matrix of the same shape and contents as this one but with the element type converted to one based on the standard C++ scalar types: float, double, complex<float>, complex<double>.

That is, negator<> and conjugate<> are eliminated from the element type by performing any needed negations computationally. Note that this is actually producing a new matrix with new data; you can also do this for free by reinterpreting the current matrix as a different type, if you don't mind looking at shared data.

template<class ELT>
ScalarNormSq SimTK::MatrixBase< ELT >::normSqr ( ) const
inline

This is the scalar Frobenius norm, and its square.

Note: if this is a Matrix then the Frobenius norm is NOT the same as the 2-norm, although they are equivalent for Vectors.

template<class ELT>
CNT<ScalarNormSq>::TSqrt SimTK::MatrixBase< ELT >::norm ( ) const
inline
template<class ELT>
CNT<ScalarNormSq>::TSqrt SimTK::MatrixBase< ELT >::normRMS ( ) const
inline

We only allow RMS norm if the elements are scalars.

If there are no elements in this Matrix, we'll define its RMS norm to be 0, although NaN might be a better choice.

template<class ELT>
RowVector_<ELT> SimTK::MatrixBase< ELT >::colSum ( ) const
inline

Form the column sums of this matrix, returned as a RowVector.

template<class ELT>
RowVector_<ELT> SimTK::MatrixBase< ELT >::sum ( ) const
inline

Alternate name for colSum(); behaves like the Matlab function sum().

template<class ELT>
Vector_<ELT> SimTK::MatrixBase< ELT >::rowSum ( ) const
inline

Form the row sums of this matrix, returned as a Vector.

template<class ELT>
const MatrixBase& SimTK::MatrixBase< ELT >::operator+ ( ) const
inline
template<class ELT>
const TNeg& SimTK::MatrixBase< ELT >::negate ( ) const
inline
template<class ELT>
TNeg& SimTK::MatrixBase< ELT >::updNegate ( )
inline
template<class ELT>
const TNeg& SimTK::MatrixBase< ELT >::operator- ( ) const
inline
template<class ELT>
TNeg& SimTK::MatrixBase< ELT >::operator- ( )
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::negateInPlace ( )
inline
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::resize ( int  m,
int  n 
)
inline

Change the size of this matrix.

This is only allowed for owner matrices. The current storage format is retained, but all the data is lost. If you want to keep the old data, use resizeKeep().

See also
resizeKeep()
template<class ELT>
MatrixBase& SimTK::MatrixBase< ELT >::resizeKeep ( int  m,
int  n 
)
inline

Change the size of this matrix, retaining as much of the old data as will fit.

This is only allowed for owner matrices. The current storage format is retained, and the existing data is copied into the new memory to the extent that it will fit.

See also
resize()
template<class ELT>
void SimTK::MatrixBase< ELT >::lockShape ( )
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::unlockShape ( )
inline
template<class ELT>
const MatrixView_<ELT>& SimTK::MatrixBase< ELT >::getAsMatrixView ( ) const
inline
template<class ELT>
MatrixView_<ELT>& SimTK::MatrixBase< ELT >::updAsMatrixView ( )
inline
template<class ELT>
const Matrix_<ELT>& SimTK::MatrixBase< ELT >::getAsMatrix ( ) const
inline
template<class ELT>
Matrix_<ELT>& SimTK::MatrixBase< ELT >::updAsMatrix ( )
inline
template<class ELT>
const VectorView_<ELT>& SimTK::MatrixBase< ELT >::getAsVectorView ( ) const
inline
template<class ELT>
VectorView_<ELT>& SimTK::MatrixBase< ELT >::updAsVectorView ( )
inline
template<class ELT>
const Vector_<ELT>& SimTK::MatrixBase< ELT >::getAsVector ( ) const
inline
template<class ELT>
Vector_<ELT>& SimTK::MatrixBase< ELT >::updAsVector ( )
inline
template<class ELT>
const VectorBase<ELT>& SimTK::MatrixBase< ELT >::getAsVectorBase ( ) const
inline
template<class ELT>
VectorBase<ELT>& SimTK::MatrixBase< ELT >::updAsVectorBase ( )
inline
template<class ELT>
const RowVectorView_<ELT>& SimTK::MatrixBase< ELT >::getAsRowVectorView ( ) const
inline
template<class ELT>
RowVectorView_<ELT>& SimTK::MatrixBase< ELT >::updAsRowVectorView ( )
inline
template<class ELT>
const RowVector_<ELT>& SimTK::MatrixBase< ELT >::getAsRowVector ( ) const
inline
template<class ELT>
RowVector_<ELT>& SimTK::MatrixBase< ELT >::updAsRowVector ( )
inline
template<class ELT>
const RowVectorBase<ELT>& SimTK::MatrixBase< ELT >::getAsRowVectorBase ( ) const
inline
template<class ELT>
RowVectorBase<ELT>& SimTK::MatrixBase< ELT >::updAsRowVectorBase ( )
inline
template<class ELT>
int SimTK::MatrixBase< ELT >::getNScalarsPerElement ( ) const
inline

This is the number of consecutive scalars used to represent one element of type ELT.

This may be fewer than C++ would use for the element, since it may introduce some padding.

template<class ELT>
int SimTK::MatrixBase< ELT >::getPackedSizeofElement ( ) const
inline

This is like sizeof(ELT), but returning the number of bytes we use to store the element which may be fewer than what C++ would use.

We store these packed elements adjacent to one another in memory.

template<class ELT>
bool SimTK::MatrixBase< ELT >::hasContiguousData ( ) const
inline
template<class ELT>
ptrdiff_t SimTK::MatrixBase< ELT >::getContiguousScalarDataLength ( ) const
inline
template<class ELT>
const Scalar* SimTK::MatrixBase< ELT >::getContiguousScalarData ( ) const
inline
template<class ELT>
Scalar* SimTK::MatrixBase< ELT >::updContiguousScalarData ( )
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::replaceContiguousScalarData ( Scalar newData,
ptrdiff_t  length,
bool  takeOwnership 
)
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::replaceContiguousScalarData ( const Scalar newData,
ptrdiff_t  length 
)
inline
template<class ELT>
void SimTK::MatrixBase< ELT >::swapOwnedContiguousScalarData ( Scalar newData,
ptrdiff_t  length,
Scalar *&  oldData 
)
inline
template<class ELT>
const MatrixHelper<Scalar>& SimTK::MatrixBase< ELT >::getHelper ( ) const
inlineprotected
template<class ELT>
MatrixHelper<Scalar>& SimTK::MatrixBase< ELT >::updHelper ( )
inlineprotected
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::rowScaleInPlace ( const VectorBase< EE > &  v)
inline
template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::rowScale ( const VectorBase< EE > &  v,
typename MatrixBase< ELT >::template EltResult< EE >::Mul &  out 
) const
inline
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::colScaleInPlace ( const VectorBase< EE > &  v)
inline
template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::colScale ( const VectorBase< EE > &  v,
typename MatrixBase< ELT >::template EltResult< EE >::Mul &  out 
) const
inline
template<class ELT>
template<class ER , class EC >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::rowAndColScaleInPlace ( const VectorBase< ER > &  r,
const VectorBase< EC > &  c 
)
inline
template<class ELT>
template<class S >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseAssign ( const S &  s)
inline
template<class ELT>
template<class S >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseAddScalarInPlace ( const S &  s)
inline
template<class ELT>
template<class S >
void SimTK::MatrixBase< ELT >::elementwiseAddScalar ( const S &  s,
typename MatrixBase< ELT >::template EltResult< S >::Add &  out 
) const
inline
template<class ELT>
template<class S >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseSubtractScalarInPlace ( const S &  s)
inline
template<class ELT>
template<class S >
void SimTK::MatrixBase< ELT >::elementwiseSubtractScalar ( const S &  s,
typename MatrixBase< ELT >::template EltResult< S >::Sub &  out 
) const
inline
template<class ELT>
template<class S >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseSubtractFromScalarInPlace ( const S &  s)
inline
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseMultiplyInPlace ( const MatrixBase< EE > &  r)
inline
template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseMultiply ( const MatrixBase< EE > &  r,
typename MatrixBase< ELT >::template EltResult< EE >::Mul &  out 
) const
inline
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseMultiplyFromLeftInPlace ( const MatrixBase< EE > &  r)
inline
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseDivideInPlace ( const MatrixBase< EE > &  r)
inline
template<class ELT>
template<class EE >
void SimTK::MatrixBase< ELT >::elementwiseDivide ( const MatrixBase< EE > &  r,
typename MatrixBase< ELT >::template EltResult< EE >::Dvd &  out 
) const
inline
template<class ELT>
template<class EE >
MatrixBase<ELT>& SimTK::MatrixBase< ELT >::elementwiseDivideFromLeftInPlace ( const MatrixBase< EE > &  r)
inline

Friends And Related Function Documentation

template<class ELT>
template<class EE >
friend class MatrixBase
friend
template<class E >
void writeUnformatted ( std::ostream &  o,
const MatrixBase< E > &  v 
)
related

Specialize for MatrixBase<E> delegating to RowVectorBase<E> with newlines separating the rows, but no final newline.


The documentation for this class was generated from the following files: