Simbody  3.7
SimTK::SymMat< M, ELT, RS > Class Template Reference

This is a small, fixed-size symmetric or Hermitian matrix designed for no-overhead inline computation. More...

Classes

struct  EltResult
 
struct  Result
 
struct  Substitute
 

Public Types

enum  {
  NRows = M,
  NCols = M,
  NDiagElements = M,
  NLowerElements = (M*(M-1))/2,
  NPackedElements = NDiagElements+NLowerElements,
  NActualElements = RS * NPackedElements,
  NActualScalars = CNT<E>::NActualScalars * NActualElements,
  RowSpacing = RS,
  ColSpacing = NActualElements,
  ImagOffset = NTraits<ENumber>::ImagOffset,
  RealStrideFactor = 1,
  ArgDepth,
  IsScalar = 0,
  IsULessScalar = 0,
  IsNumber = 0,
  IsStdNumber = 0,
  IsPrecision = 0,
  SignInterpretation = CNT<E>::SignInterpretation
}
 
typedef SymMat< M, E, RS > T
 
typedef SymMat< M, ENeg, RS > TNeg
 
typedef SymMat< M, EWithoutNegator, RS > TWithoutNegator
 
typedef SymMat< M, EReal, RS *CNT< E >::RealStrideFactorTReal
 
typedef SymMat< M, EImag, RS *CNT< E >::RealStrideFactorTImag
 
typedef SymMat< M, EComplex, RS > TComplex
 
typedef T THerm
 
typedef SymMat< M, EHerm, RS > TPosTrans
 
typedef E TElement
 
typedef Vec< M, E, RS > TDiag
 
typedef Vec<(M *(M-1))/2, E, RS > TLower
 
typedef Vec<(M *(M-1))/2, EHerm, RS > TUpper
 
typedef Vec<(M *(M+1))/2, E, RS > TAsVec
 
typedef Row< M, E, 1 > TRow
 
typedef Vec< M, E, 1 > TCol
 
typedef SymMat< M, ESqrt, 1 > TSqrt
 
typedef SymMat< M, EAbs, 1 > TAbs
 
typedef SymMat< M, EStandard, 1 > TStandard
 
typedef SymMat< M, EInvert, 1 > TInvert
 
typedef SymMat< M, ENormalize, 1 > TNormalize
 
typedef SymMat< M, ESqHermT, 1 > TSqHermT
 
typedef SymMat< M, ESqTHerm, 1 > TSqTHerm
 
typedef SymMat< M, E, 1 > TPacked
 
typedef EScalar Scalar
 
typedef EULessScalar ULessScalar
 
typedef ENumber Number
 
typedef EStdNumber StdNumber
 
typedef EPrecision Precision
 
typedef EScalarNormSq ScalarNormSq
 

Public Member Functions

ScalarNormSq scalarNormSqr () const
 
TSqrt sqrt () const
 
TAbs abs () const
 
TStandard standardize () const
 
EStandard trace () const
 
 SymMat ()
 Default construction initializes to NaN when debugging but is left uninitialized otherwise. More...
 
 SymMat (const SymMat &src)
 Copy constructor. More...
 
SymMatoperator= (const SymMat &src)
 Copy assignment; no harm if source and this are the same matrix. More...
 
template<class EE , int CSS, int RSS>
 SymMat (const Mat< M, M, EE, CSS, RSS > &m)
 This is an explicit conversion from square Mat of right size, assuming that the source matrix is symmetric to within a reasonable numerical tolerance. More...
 
template<class EE , int CSS, int RSS>
SymMatsetFromLower (const Mat< M, M, EE, CSS, RSS > &m)
 Create a new SymMat of this type from a square Mat of the right size, looking only at lower elements and the real part of the diagonal. More...
 
template<class EE , int CSS, int RSS>
SymMatsetFromUpper (const Mat< M, M, EE, CSS, RSS > &m)
 Create a new SymMat of this type from a square Mat of the right size, looking only at upper elements and the real part of the diagonal. More...
 
template<class EE , int CSS, int RSS>
SymMatsetFromSymmetric (const Mat< M, M, EE, CSS, RSS > &m)
 Create a new SymMat of this type from a square Mat of the right size, that is expected to be symmetric (hermitian) to within a tolerance. More...
 
template<int RSS>
 SymMat (const SymMat< M, E, RSS > &src)
 This is an implicit conversion from a SymMat of the same length and element type but with different spacing. More...
 
template<int RSS>
 SymMat (const SymMat< M, ENeg, RSS > &src)
 This is an implicit conversion from a SymMat of the same length and negated element type, possibly with different spacing. More...
 
template<class EE , int RSS>
 SymMat (const SymMat< M, EE, RSS > &src)
 Construct a SymMat from a SymMat of the same dimensions, with any element type and spacing. More...
 
 SymMat (const E &e)
 
 SymMat (const ENeg &e)
 
 SymMat (int i)
 
 SymMat (const E &e0, const E &e1, const E &e2)
 A bevy of constructors from individual exact-match elements IN ROW ORDER, giving the LOWER TRIANGLE, like this: More...
 
 SymMat (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
 
 SymMat (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7, const E &e8, const E &e9)
 
 SymMat (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7, const E &e8, const E &e9, const E &e10, const E &e11, const E &e12, const E &e13, const E &e14)
 
 SymMat (const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7, const E &e8, const E &e9, const E &e10, const E &e11, const E &e12, const E &e13, const E &e14, const E &e15, const E &e16, const E &e17, const E &e18, const E &e19, const E &e20)
 
template<class EE >
 SymMat (const EE *p)
 
template<class EE >
SymMatoperator= (const EE *p)
 
template<class EE , int RSS>
SymMatoperator= (const SymMat< M, EE, RSS > &mm)
 
template<class EE , int RSS>
SymMatoperator+= (const SymMat< M, EE, RSS > &mm)
 
template<class EE , int RSS>
SymMatoperator+= (const SymMat< M, negator< EE >, RSS > &mm)
 
template<class EE , int RSS>
SymMatoperator-= (const SymMat< M, EE, RSS > &mm)
 
template<class EE , int RSS>
SymMatoperator-= (const SymMat< M, negator< EE >, RSS > &mm)
 
template<class EE , int RSS>
SymMatoperator*= (const SymMat< M, EE, RSS > &mm)
 
template<class E2 , int RS2>
Result< SymMat< M, E2, RS2 > >::Add conformingAdd (const SymMat< M, E2, RS2 > &r) const
 
template<class E2 , int RS2>
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract (const SymMat< M, E2, RS2 > &r) const
 
template<class E2 , int RS2>
Result< SymMat< M, E2, RS2 > >::Mul conformingMultiply (const SymMat< M, E2, RS2 > &s) const
 
template<class E2 , int RS2>
EltResult< E2 >::Mul elementwiseMultiply (const SymMat< M, E2, RS2 > &r) const
 
template<class E2 , int RS2>
EltResult< E2 >::Dvd elementwiseDivide (const SymMat< M, E2, RS2 > &r) const
 
const E & operator() (int i, int j) const
 
E & operator() (int i, int j)
 
TRow operator[] (int i) const
 
TCol operator() (int j) const
 
ScalarNormSq normSqr () const
 
CNT< ScalarNormSq >::TSqrt norm () const
 
TNormalize normalize () const
 There is no conventional meaning for normalize() applied to a matrix. More...
 
TInvert invert () const
 
const SymMatoperator+ () const
 
const TNegoperator- () const
 
TNegoperator- ()
 
const THermoperator~ () const
 
THermoperator~ ()
 
const TNegnegate () const
 
TNegupdNegate ()
 
const THermtranspose () const
 
THermupdTranspose ()
 
const TPosTranspositionalTranspose () const
 
TPosTransupdPositionalTranspose ()
 
const TRealreal () const
 
TRealreal ()
 
const TImagimag () const
 
TImagimag ()
 
const TWithoutNegatorcastAwayNegatorIfAny () const
 
TWithoutNegatorupdCastAwayNegatorIfAny ()
 
template<class EE >
SymMat< M, typename CNT< E >::template Result< EE >::Mul > scalarMultiply (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< E >::template Result< EE >::Dvd > scalarDivide (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< E >::template Result< EE >::Add > scalarAdd (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< E >::template Result< EE >::Sub > scalarSubtract (const EE &e) const
 
template<class EE >
SymMat< M, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft (const EE &e) const
 
template<class EE >
SymMatoperator= (const EE &e)
 
template<class EE >
SymMatoperator+= (const EE &e)
 
template<class EE >
SymMatoperator-= (const EE &e)
 
template<class EE >
SymMatoperator*= (const EE &e)
 
template<class EE >
SymMatoperator/= (const EE &e)
 
template<class EE >
SymMatscalarEq (const EE &ee)
 
template<class EE >
SymMatscalarPlusEq (const EE &ee)
 
template<class EE >
SymMatscalarMinusEq (const EE &ee)
 
template<class EE >
SymMatscalarMinusEqFromLeft (const EE &ee)
 
template<class EE >
SymMatscalarTimesEq (const EE &ee)
 
template<class EE >
SymMatscalarTimesEqFromLeft (const EE &ee)
 
template<class EE >
SymMatscalarDivideEq (const EE &ee)
 
template<class EE >
SymMatscalarDivideEqFromLeft (const EE &ee)
 
void setToNaN ()
 
void setToZero ()
 
bool isNaN () const
 Return true if any element of this SymMat contains a NaN anywhere. More...
 
bool isInf () const
 Return true if any element of this SymMat contains a +Inf or -Inf somewhere but no element contains a NaN anywhere. More...
 
bool isFinite () const
 Return true if no element contains an Infinity or a NaN. More...
 
template<class E2 , int RS2>
bool isNumericallyEqual (const SymMat< M, E2, RS2 > &m, double tol) const
 Test whether this matrix is numerically equal to some other matrix with the same shape, using a specified tolerance. More...
 
template<class E2 , int RS2>
bool isNumericallyEqual (const SymMat< M, E2, RS2 > &m) const
 Test whether this matrix is numerically equal to some other matrix with the same shape, using a default tolerance which is the looser of the default tolerances of the two objects being compared. More...
 
bool isNumericallyEqual (const ELT &e, double tol=getDefaultTolerance()) const
 Test whether this is numerically a "scalar" matrix, meaning that it is a diagonal matrix in which each diagonal element is numerically equal to the same scalar, using either a specified tolerance or the matrix's default tolerance (which is always the same or looser than the default tolerance for one of its elements). More...
 
TRow row (int i) const
 
TCol col (int j) const
 
elt (int i, int j) const
 Return a value for any element of a symmetric matrix, even those in the upper triangle which aren't actually stored anywhere. More...
 
const TDiaggetDiag () const
 
TDiagupdDiag ()
 
const TDiagdiag () const
 
TDiagdiag ()
 
const TLowergetLower () const
 
TLowerupdLower ()
 
const TUppergetUpper () const
 
TUpperupdUpper ()
 
const TAsVecgetAsVec () const
 
TAsVecupdAsVec ()
 
const E & getEltDiag (int i) const
 
E & updEltDiag (int i)
 
const E & getEltLower (int i, int j) const
 
E & updEltLower (int i, int j)
 
const EHerm & getEltUpper (int i, int j) const
 
EHerm & updEltUpper (int i, int j)
 
TRow colSum () const
 Returns a row vector (Row) containing the column sums of this matrix. More...
 
TRow sum () const
 This is an alternate name for colSum(); behaves like the Matlab function of the same name. More...
 
TCol rowSum () const
 Returns a column vector (Vec) containing the row sums of this matrix. More...
 

Static Public Member Functions

static int size ()
 
static int nrow ()
 
static int ncol ()
 
static const SymMatgetAs (const ELT *p)
 
static SymMatupdAs (ELT *p)
 
static TPacked getNaN ()
 
static double getDefaultTolerance ()
 For approximate comparisons, the default tolerance to use for a matrix is its shortest dimension times its elements' default tolerance. More...
 

Friends

template<int MM, class EE , int RSS>
class SymMat
 

Related Functions

(Note that these are not member functions.)

template<int M, class E , int RS>
void writeUnformatted (std::ostream &o, const SymMat< M, E, RS > &v)
 Specialize for SymMat<M,E,RS> delegating to Row<M,E,RS> with newlines separating the rows, but no final newline. More...
 
template<int M, class E , int RS>
bool readUnformatted (std::istream &in, SymMat< M, E, RS > &v)
 Specialize for SymMat<M,E,RS>. More...
 

Detailed Description

template<int M, class ELT, int RS>
class SimTK::SymMat< M, ELT, RS >

This is a small, fixed-size symmetric or Hermitian matrix designed for no-overhead inline computation.

Template Parameters
MThe dimension of this square matrix.
ELTThe element type. Must be a composite numerical type (CNT). The default is ELT=Real.
RSThe spacing from one element to the next in memory, as an integer number of elements of type ELT. The default is RS=1.

This is logically a square MxM Hermitian matrix, but only the diagonal and lower triangle are stored. Elements above the diagonal are the Hermitan transpose of their mirrored elements below the diagonal.

The storage is packed by column, with an optional stride RS when going element- to-element. We use an unconventional storage scheme here which provides substantial conveniences and some performance advantage over the conventional (LAPACK) scheme which stores the matrix in packed columns. Instead, we store the diagonal first, as a Vec<M> and then store the lower triangle separately in the conventional columnwise form. This allows easy handling of the diagonal elements separately, which is very common in a symmetric matrix. The diagonals are "special"; for example they must be "self-Hermitian" meaning their imaginary parts must be zero. We could just store real elements for the diagonals, but we don't for a number of good reasons which I'll leave as an exercise for the reader. However, we will ensure that their imaginary parts are zero, although a determined user could screw this up.

Here is an example. Imagine a full 4x4 Hermitian matrix with complex elements. We'll use a' to mean conjugate(a). Then the elements are

    w  a' b' c'
    a  x  d' e'
    b  d  y  f'
    c  e  f  z

Note that it must be the case that w=w', x=x', y=y', and z=z' so the diagonal elements must be real. Here's how we store that as a SymMat:

    w x y z a b c d e f

These are stored in consecutive memory locations (possibly separated by meaningless elements as indicated by the row spacing RS). Mere recasting allows us to view this as a 4x4 matrix, or a 4-element diagonal and 6-element "lower" vector, or as these vectors apparently containing the Hermitian types (i.e. one may cast the "lower" portion into what looks like the "upper" portion).

This is a Composite Numerical Type (CNT).

Member Typedef Documentation

◆ T

template<int M, class ELT, int RS>
typedef SymMat<M,E,RS> SimTK::SymMat< M, ELT, RS >::T

◆ TNeg

template<int M, class ELT, int RS>
typedef SymMat<M,ENeg,RS> SimTK::SymMat< M, ELT, RS >::TNeg

◆ TWithoutNegator

template<int M, class ELT, int RS>
typedef SymMat<M,EWithoutNegator,RS> SimTK::SymMat< M, ELT, RS >::TWithoutNegator

◆ TReal

template<int M, class ELT, int RS>
typedef SymMat<M,EReal,RS*CNT<E>::RealStrideFactor> SimTK::SymMat< M, ELT, RS >::TReal

◆ TImag

template<int M, class ELT, int RS>
typedef SymMat<M,EImag,RS*CNT<E>::RealStrideFactor> SimTK::SymMat< M, ELT, RS >::TImag

◆ TComplex

template<int M, class ELT, int RS>
typedef SymMat<M,EComplex,RS> SimTK::SymMat< M, ELT, RS >::TComplex

◆ THerm

template<int M, class ELT, int RS>
typedef T SimTK::SymMat< M, ELT, RS >::THerm

◆ TPosTrans

template<int M, class ELT, int RS>
typedef SymMat<M,EHerm,RS> SimTK::SymMat< M, ELT, RS >::TPosTrans

◆ TElement

template<int M, class ELT, int RS>
typedef E SimTK::SymMat< M, ELT, RS >::TElement

◆ TDiag

template<int M, class ELT, int RS>
typedef Vec<M,E,RS> SimTK::SymMat< M, ELT, RS >::TDiag

◆ TLower

template<int M, class ELT, int RS>
typedef Vec<(M*(M-1))/2,E,RS> SimTK::SymMat< M, ELT, RS >::TLower

◆ TUpper

template<int M, class ELT, int RS>
typedef Vec<(M*(M-1))/2,EHerm,RS> SimTK::SymMat< M, ELT, RS >::TUpper

◆ TAsVec

template<int M, class ELT, int RS>
typedef Vec<(M*(M+1))/2,E,RS> SimTK::SymMat< M, ELT, RS >::TAsVec

◆ TRow

template<int M, class ELT, int RS>
typedef Row<M,E,1> SimTK::SymMat< M, ELT, RS >::TRow

◆ TCol

template<int M, class ELT, int RS>
typedef Vec<M,E,1> SimTK::SymMat< M, ELT, RS >::TCol

◆ TSqrt

template<int M, class ELT, int RS>
typedef SymMat<M,ESqrt,1> SimTK::SymMat< M, ELT, RS >::TSqrt

◆ TAbs

template<int M, class ELT, int RS>
typedef SymMat<M,EAbs,1> SimTK::SymMat< M, ELT, RS >::TAbs

◆ TStandard

template<int M, class ELT, int RS>
typedef SymMat<M,EStandard,1> SimTK::SymMat< M, ELT, RS >::TStandard

◆ TInvert

template<int M, class ELT, int RS>
typedef SymMat<M,EInvert,1> SimTK::SymMat< M, ELT, RS >::TInvert

◆ TNormalize

template<int M, class ELT, int RS>
typedef SymMat<M,ENormalize,1> SimTK::SymMat< M, ELT, RS >::TNormalize

◆ TSqHermT

template<int M, class ELT, int RS>
typedef SymMat<M,ESqHermT,1> SimTK::SymMat< M, ELT, RS >::TSqHermT

◆ TSqTHerm

template<int M, class ELT, int RS>
typedef SymMat<M,ESqTHerm,1> SimTK::SymMat< M, ELT, RS >::TSqTHerm

◆ TPacked

template<int M, class ELT, int RS>
typedef SymMat<M,E,1> SimTK::SymMat< M, ELT, RS >::TPacked

◆ Scalar

template<int M, class ELT, int RS>
typedef EScalar SimTK::SymMat< M, ELT, RS >::Scalar

◆ ULessScalar

template<int M, class ELT, int RS>
typedef EULessScalar SimTK::SymMat< M, ELT, RS >::ULessScalar

◆ Number

template<int M, class ELT, int RS>
typedef ENumber SimTK::SymMat< M, ELT, RS >::Number

◆ StdNumber

template<int M, class ELT, int RS>
typedef EStdNumber SimTK::SymMat< M, ELT, RS >::StdNumber

◆ Precision

template<int M, class ELT, int RS>
typedef EPrecision SimTK::SymMat< M, ELT, RS >::Precision

◆ ScalarNormSq

template<int M, class ELT, int RS>
typedef EScalarNormSq SimTK::SymMat< M, ELT, RS >::ScalarNormSq

Member Enumeration Documentation

◆ anonymous enum

template<int M, class ELT, int RS>
anonymous enum
Enumerator
NRows 
NCols 
NDiagElements 
NLowerElements 
NPackedElements 
NActualElements 
NActualScalars 
RowSpacing 
ColSpacing 
ImagOffset 
RealStrideFactor 
ArgDepth 
IsScalar 
IsULessScalar 
IsNumber 
IsStdNumber 
IsPrecision 
SignInterpretation 

Constructor & Destructor Documentation

◆ SymMat() [1/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( )
inline

Default construction initializes to NaN when debugging but is left uninitialized otherwise.

◆ SymMat() [2/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const SymMat< M, ELT, RS > &  src)
inline

Copy constructor.

◆ SymMat() [3/15]

template<int M, class ELT, int RS>
template<class EE , int CSS, int RSS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const Mat< M, M, EE, CSS, RSS > &  m)
inlineexplicit

This is an explicit conversion from square Mat of right size, assuming that the source matrix is symmetric to within a reasonable numerical tolerance.

In Debug mode we'll test that assumption and throw an exception if it is wrong. In Release mode you're on your own. All the elements of the source Mat are used; off-diagonal elements (i,j) are averaged with their corresponding element (j,i); the imaginary part of the diagonal is set exactly to zero. If you don't want to spend the flops to average the off-diagonals, and you're sure the source is symmetric, use either setFromLower() or setFromUpper() which will just copy the elements.

See also
setFromLower(), setFromUpper()

◆ SymMat() [4/15]

template<int M, class ELT, int RS>
template<int RSS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const SymMat< M, E, RSS > &  src)
inline

This is an implicit conversion from a SymMat of the same length and element type but with different spacing.

◆ SymMat() [5/15]

template<int M, class ELT, int RS>
template<int RSS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const SymMat< M, ENeg, RSS > &  src)
inline

This is an implicit conversion from a SymMat of the same length and negated element type, possibly with different spacing.

◆ SymMat() [6/15]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const SymMat< M, EE, RSS > &  src)
inlineexplicit

Construct a SymMat from a SymMat of the same dimensions, with any element type and spacing.

Works as long as the element types are assignment compatible.

◆ SymMat() [7/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e)
inlineexplicit

◆ SymMat() [8/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const ENeg &  e)
inlineexplicit

◆ SymMat() [9/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( int  i)
inlineexplicit

◆ SymMat() [10/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e0,
const E &  e1,
const E &  e2 
)
inline

A bevy of constructors from individual exact-match elements IN ROW ORDER, giving the LOWER TRIANGLE, like this:

    a
    b c
    d e f
    g h i j

Note that this will be mapped to our diagonal/lower layout, which in the above example would be:

    [a c f j][b d g e h i]

◆ SymMat() [11/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e0,
const E &  e1,
const E &  e2,
const E &  e3,
const E &  e4,
const E &  e5 
)
inline

◆ SymMat() [12/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e0,
const E &  e1,
const E &  e2,
const E &  e3,
const E &  e4,
const E &  e5,
const E &  e6,
const E &  e7,
const E &  e8,
const E &  e9 
)
inline

◆ SymMat() [13/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e0,
const E &  e1,
const E &  e2,
const E &  e3,
const E &  e4,
const E &  e5,
const E &  e6,
const E &  e7,
const E &  e8,
const E &  e9,
const E &  e10,
const E &  e11,
const E &  e12,
const E &  e13,
const E &  e14 
)
inline

◆ SymMat() [14/15]

template<int M, class ELT, int RS>
SimTK::SymMat< M, ELT, RS >::SymMat ( const E &  e0,
const E &  e1,
const E &  e2,
const E &  e3,
const E &  e4,
const E &  e5,
const E &  e6,
const E &  e7,
const E &  e8,
const E &  e9,
const E &  e10,
const E &  e11,
const E &  e12,
const E &  e13,
const E &  e14,
const E &  e15,
const E &  e16,
const E &  e17,
const E &  e18,
const E &  e19,
const E &  e20 
)
inline

◆ SymMat() [15/15]

template<int M, class ELT, int RS>
template<class EE >
SimTK::SymMat< M, ELT, RS >::SymMat ( const EE *  p)
inlineexplicit

Member Function Documentation

◆ size()

template<int M, class ELT, int RS>
static int SimTK::SymMat< M, ELT, RS >::size ( )
inlinestatic

◆ nrow()

template<int M, class ELT, int RS>
static int SimTK::SymMat< M, ELT, RS >::nrow ( )
inlinestatic

◆ ncol()

template<int M, class ELT, int RS>
static int SimTK::SymMat< M, ELT, RS >::ncol ( )
inlinestatic

◆ scalarNormSqr()

template<int M, class ELT, int RS>
ScalarNormSq SimTK::SymMat< M, ELT, RS >::scalarNormSqr ( ) const
inline

◆ sqrt()

template<int M, class ELT, int RS>
TSqrt SimTK::SymMat< M, ELT, RS >::sqrt ( ) const
inline

◆ abs()

template<int M, class ELT, int RS>
TAbs SimTK::SymMat< M, ELT, RS >::abs ( ) const
inline

◆ standardize()

template<int M, class ELT, int RS>
TStandard SimTK::SymMat< M, ELT, RS >::standardize ( ) const
inline

◆ trace()

template<int M, class ELT, int RS>
EStandard SimTK::SymMat< M, ELT, RS >::trace ( ) const
inline

◆ operator=() [1/4]

template<int M, class ELT, int RS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator= ( const SymMat< M, ELT, RS > &  src)
inline

Copy assignment; no harm if source and this are the same matrix.

◆ setFromLower()

template<int M, class ELT, int RS>
template<class EE , int CSS, int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::setFromLower ( const Mat< M, M, EE, CSS, RSS > &  m)
inline

Create a new SymMat of this type from a square Mat of the right size, looking only at lower elements and the real part of the diagonal.

◆ setFromUpper()

template<int M, class ELT, int RS>
template<class EE , int CSS, int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::setFromUpper ( const Mat< M, M, EE, CSS, RSS > &  m)
inline

Create a new SymMat of this type from a square Mat of the right size, looking only at upper elements and the real part of the diagonal.

Note that the SymMat's stored elements are still in its lower triangle; they are just initialized from the Mat's upper triangle. There is no transposing of elements here; we simply copy the upper elements of the Mat to the corresponding lower elements of the SymMat.

◆ setFromSymmetric()

template<int M, class ELT, int RS>
template<class EE , int CSS, int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::setFromSymmetric ( const Mat< M, M, EE, CSS, RSS > &  m)
inline

Create a new SymMat of this type from a square Mat of the right size, that is expected to be symmetric (hermitian) to within a tolerance.

All elements are used; we average the upper and lower elements of the Mat to produce the corresponding element of the SymMat.

◆ operator=() [2/4]

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator= ( const EE *  p)
inline

◆ operator=() [3/4]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator= ( const SymMat< M, EE, RSS > &  mm)
inline

◆ operator+=() [1/3]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator+= ( const SymMat< M, EE, RSS > &  mm)
inline

◆ operator+=() [2/3]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator+= ( const SymMat< M, negator< EE >, RSS > &  mm)
inline

◆ operator-=() [1/3]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator-= ( const SymMat< M, EE, RSS > &  mm)
inline

◆ operator-=() [2/3]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator-= ( const SymMat< M, negator< EE >, RSS > &  mm)
inline

◆ operator*=() [1/2]

template<int M, class ELT, int RS>
template<class EE , int RSS>
SymMat& SimTK::SymMat< M, ELT, RS >::operator*= ( const SymMat< M, EE, RSS > &  mm)
inline

◆ conformingAdd()

template<int M, class ELT, int RS>
template<class E2 , int RS2>
Result<SymMat<M,E2,RS2> >::Add SimTK::SymMat< M, ELT, RS >::conformingAdd ( const SymMat< M, E2, RS2 > &  r) const
inline

◆ conformingSubtract()

template<int M, class ELT, int RS>
template<class E2 , int RS2>
Result<SymMat<M,E2,RS2> >::Sub SimTK::SymMat< M, ELT, RS >::conformingSubtract ( const SymMat< M, E2, RS2 > &  r) const
inline

◆ conformingMultiply()

template<int M, class ELT, int RS>
template<class E2 , int RS2>
Result<SymMat<M,E2,RS2> >::Mul SimTK::SymMat< M, ELT, RS >::conformingMultiply ( const SymMat< M, E2, RS2 > &  s) const
inline

◆ elementwiseMultiply()

template<int M, class ELT, int RS>
template<class E2 , int RS2>
EltResult<E2>::Mul SimTK::SymMat< M, ELT, RS >::elementwiseMultiply ( const SymMat< M, E2, RS2 > &  r) const
inline

◆ elementwiseDivide()

template<int M, class ELT, int RS>
template<class E2 , int RS2>
EltResult<E2>::Dvd SimTK::SymMat< M, ELT, RS >::elementwiseDivide ( const SymMat< M, E2, RS2 > &  r) const
inline

◆ operator()() [1/3]

template<int M, class ELT, int RS>
const E& SimTK::SymMat< M, ELT, RS >::operator() ( int  i,
int  j 
) const
inline

◆ operator()() [2/3]

template<int M, class ELT, int RS>
E& SimTK::SymMat< M, ELT, RS >::operator() ( int  i,
int  j 
)
inline

◆ operator[]()

template<int M, class ELT, int RS>
TRow SimTK::SymMat< M, ELT, RS >::operator[] ( int  i) const
inline

◆ operator()() [3/3]

template<int M, class ELT, int RS>
TCol SimTK::SymMat< M, ELT, RS >::operator() ( int  j) const
inline

◆ normSqr()

template<int M, class ELT, int RS>
ScalarNormSq SimTK::SymMat< M, ELT, RS >::normSqr ( ) const
inline

◆ norm()

template<int M, class ELT, int RS>
CNT<ScalarNormSq>::TSqrt SimTK::SymMat< M, ELT, RS >::norm ( ) const
inline

◆ normalize()

template<int M, class ELT, int RS>
TNormalize SimTK::SymMat< M, ELT, RS >::normalize ( ) const
inline

There is no conventional meaning for normalize() applied to a matrix.

We choose to define it as follows: If the elements of this SymMat are scalars, the result is what you get by dividing each element by the Frobenius norm() calculated above. If the elements are not scalars, then the elements are separately normalized.

Normalize returns a matrix of the same dimension but in new, packed storage and with a return type that does not include negator<> even if the original SymMat<> does, because we can eliminate the negation here almost for free. But we can't standardize (change conjugate to complex) for free, so we'll retain conjugates if there are any.

◆ invert()

template<int M, class ELT, int RS>
TInvert SimTK::SymMat< M, ELT, RS >::invert ( ) const
inline

◆ operator+()

template<int M, class ELT, int RS>
const SymMat& SimTK::SymMat< M, ELT, RS >::operator+ ( ) const
inline

◆ operator-() [1/2]

template<int M, class ELT, int RS>
const TNeg& SimTK::SymMat< M, ELT, RS >::operator- ( ) const
inline

◆ operator-() [2/2]

template<int M, class ELT, int RS>
TNeg& SimTK::SymMat< M, ELT, RS >::operator- ( )
inline

◆ operator~() [1/2]

template<int M, class ELT, int RS>
const THerm& SimTK::SymMat< M, ELT, RS >::operator~ ( ) const
inline

◆ operator~() [2/2]

template<int M, class ELT, int RS>
THerm& SimTK::SymMat< M, ELT, RS >::operator~ ( )
inline

◆ negate()

template<int M, class ELT, int RS>
const TNeg& SimTK::SymMat< M, ELT, RS >::negate ( ) const
inline

◆ updNegate()

template<int M, class ELT, int RS>
TNeg& SimTK::SymMat< M, ELT, RS >::updNegate ( )
inline

◆ transpose()

template<int M, class ELT, int RS>
const THerm& SimTK::SymMat< M, ELT, RS >::transpose ( ) const
inline

◆ updTranspose()

template<int M, class ELT, int RS>
THerm& SimTK::SymMat< M, ELT, RS >::updTranspose ( )
inline

◆ positionalTranspose()

template<int M, class ELT, int RS>
const TPosTrans& SimTK::SymMat< M, ELT, RS >::positionalTranspose ( ) const
inline

◆ updPositionalTranspose()

template<int M, class ELT, int RS>
TPosTrans& SimTK::SymMat< M, ELT, RS >::updPositionalTranspose ( )
inline

◆ real() [1/2]

template<int M, class ELT, int RS>
const TReal& SimTK::SymMat< M, ELT, RS >::real ( ) const
inline

◆ real() [2/2]

template<int M, class ELT, int RS>
TReal& SimTK::SymMat< M, ELT, RS >::real ( )
inline

◆ imag() [1/2]

template<int M, class ELT, int RS>
const TImag& SimTK::SymMat< M, ELT, RS >::imag ( ) const
inline

◆ imag() [2/2]

template<int M, class ELT, int RS>
TImag& SimTK::SymMat< M, ELT, RS >::imag ( )
inline

◆ castAwayNegatorIfAny()

template<int M, class ELT, int RS>
const TWithoutNegator& SimTK::SymMat< M, ELT, RS >::castAwayNegatorIfAny ( ) const
inline

◆ updCastAwayNegatorIfAny()

template<int M, class ELT, int RS>
TWithoutNegator& SimTK::SymMat< M, ELT, RS >::updCastAwayNegatorIfAny ( )
inline

◆ scalarMultiply()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<E>::template Result<EE>::Mul> SimTK::SymMat< M, ELT, RS >::scalarMultiply ( const EE &  e) const
inline

◆ scalarMultiplyFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<EE>::template Result<E>::Mul> SimTK::SymMat< M, ELT, RS >::scalarMultiplyFromLeft ( const EE &  e) const
inline

◆ scalarDivide()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<E>::template Result<EE>::Dvd> SimTK::SymMat< M, ELT, RS >::scalarDivide ( const EE &  e) const
inline

◆ scalarDivideFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<EE>::template Result<E>::Dvd> SimTK::SymMat< M, ELT, RS >::scalarDivideFromLeft ( const EE &  e) const
inline

◆ scalarAdd()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<E>::template Result<EE>::Add> SimTK::SymMat< M, ELT, RS >::scalarAdd ( const EE &  e) const
inline

◆ scalarSubtract()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<E>::template Result<EE>::Sub> SimTK::SymMat< M, ELT, RS >::scalarSubtract ( const EE &  e) const
inline

◆ scalarSubtractFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat<M, typename CNT<EE>::template Result<E>::Sub> SimTK::SymMat< M, ELT, RS >::scalarSubtractFromLeft ( const EE &  e) const
inline

◆ operator=() [4/4]

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator= ( const EE &  e)
inline

◆ operator+=() [3/3]

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator+= ( const EE &  e)
inline

◆ operator-=() [3/3]

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator-= ( const EE &  e)
inline

◆ operator*=() [2/2]

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator*= ( const EE &  e)
inline

◆ operator/=()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::operator/= ( const EE &  e)
inline

◆ scalarEq()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarEq ( const EE &  ee)
inline

◆ scalarPlusEq()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarPlusEq ( const EE &  ee)
inline

◆ scalarMinusEq()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarMinusEq ( const EE &  ee)
inline

◆ scalarMinusEqFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarMinusEqFromLeft ( const EE &  ee)
inline

◆ scalarTimesEq()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarTimesEq ( const EE &  ee)
inline

◆ scalarTimesEqFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarTimesEqFromLeft ( const EE &  ee)
inline

◆ scalarDivideEq()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarDivideEq ( const EE &  ee)
inline

◆ scalarDivideEqFromLeft()

template<int M, class ELT, int RS>
template<class EE >
SymMat& SimTK::SymMat< M, ELT, RS >::scalarDivideEqFromLeft ( const EE &  ee)
inline

◆ setToNaN()

template<int M, class ELT, int RS>
void SimTK::SymMat< M, ELT, RS >::setToNaN ( )
inline

◆ setToZero()

template<int M, class ELT, int RS>
void SimTK::SymMat< M, ELT, RS >::setToZero ( )
inline

◆ getAs()

template<int M, class ELT, int RS>
static const SymMat& SimTK::SymMat< M, ELT, RS >::getAs ( const ELT *  p)
inlinestatic

◆ updAs()

template<int M, class ELT, int RS>
static SymMat& SimTK::SymMat< M, ELT, RS >::updAs ( ELT *  p)
inlinestatic

◆ getNaN()

template<int M, class ELT, int RS>
static TPacked SimTK::SymMat< M, ELT, RS >::getNaN ( )
inlinestatic

◆ isNaN()

template<int M, class ELT, int RS>
bool SimTK::SymMat< M, ELT, RS >::isNaN ( ) const
inline

Return true if any element of this SymMat contains a NaN anywhere.

◆ isInf()

template<int M, class ELT, int RS>
bool SimTK::SymMat< M, ELT, RS >::isInf ( ) const
inline

Return true if any element of this SymMat contains a +Inf or -Inf somewhere but no element contains a NaN anywhere.

◆ isFinite()

template<int M, class ELT, int RS>
bool SimTK::SymMat< M, ELT, RS >::isFinite ( ) const
inline

Return true if no element contains an Infinity or a NaN.

◆ getDefaultTolerance()

template<int M, class ELT, int RS>
static double SimTK::SymMat< M, ELT, RS >::getDefaultTolerance ( )
inlinestatic

For approximate comparisons, the default tolerance to use for a matrix is its shortest dimension times its elements' default tolerance.

◆ isNumericallyEqual() [1/3]

template<int M, class ELT, int RS>
template<class E2 , int RS2>
bool SimTK::SymMat< M, ELT, RS >::isNumericallyEqual ( const SymMat< M, E2, RS2 > &  m,
double  tol 
) const
inline

Test whether this matrix is numerically equal to some other matrix with the same shape, using a specified tolerance.

◆ isNumericallyEqual() [2/3]

template<int M, class ELT, int RS>
template<class E2 , int RS2>
bool SimTK::SymMat< M, ELT, RS >::isNumericallyEqual ( const SymMat< M, E2, RS2 > &  m) const
inline

Test whether this matrix is numerically equal to some other matrix with the same shape, using a default tolerance which is the looser of the default tolerances of the two objects being compared.

◆ isNumericallyEqual() [3/3]

template<int M, class ELT, int RS>
bool SimTK::SymMat< M, ELT, RS >::isNumericallyEqual ( const ELT &  e,
double  tol = getDefaultTolerance() 
) const
inline

Test whether this is numerically a "scalar" matrix, meaning that it is a diagonal matrix in which each diagonal element is numerically equal to the same scalar, using either a specified tolerance or the matrix's default tolerance (which is always the same or looser than the default tolerance for one of its elements).

◆ row()

template<int M, class ELT, int RS>
TRow SimTK::SymMat< M, ELT, RS >::row ( int  i) const
inline

◆ col()

template<int M, class ELT, int RS>
TCol SimTK::SymMat< M, ELT, RS >::col ( int  j) const
inline

◆ elt()

template<int M, class ELT, int RS>
E SimTK::SymMat< M, ELT, RS >::elt ( int  i,
int  j 
) const
inline

Return a value for any element of a symmetric matrix, even those in the upper triangle which aren't actually stored anywhere.

For elements whose underlying numeric types are complex, this will require computation in order to return the conjugates. So we always have to copy out the element, and may also have to conjugate it (one flop per complex number).

◆ getDiag()

template<int M, class ELT, int RS>
const TDiag& SimTK::SymMat< M, ELT, RS >::getDiag ( ) const
inline

◆ updDiag()

template<int M, class ELT, int RS>
TDiag& SimTK::SymMat< M, ELT, RS >::updDiag ( )
inline

◆ diag() [1/2]

template<int M, class ELT, int RS>
const TDiag& SimTK::SymMat< M, ELT, RS >::diag ( ) const
inline

◆ diag() [2/2]

template<int M, class ELT, int RS>
TDiag& SimTK::SymMat< M, ELT, RS >::diag ( )
inline

◆ getLower()

template<int M, class ELT, int RS>
const TLower& SimTK::SymMat< M, ELT, RS >::getLower ( ) const
inline

◆ updLower()

template<int M, class ELT, int RS>
TLower& SimTK::SymMat< M, ELT, RS >::updLower ( )
inline

◆ getUpper()

template<int M, class ELT, int RS>
const TUpper& SimTK::SymMat< M, ELT, RS >::getUpper ( ) const
inline

◆ updUpper()

template<int M, class ELT, int RS>
TUpper& SimTK::SymMat< M, ELT, RS >::updUpper ( )
inline

◆ getAsVec()

template<int M, class ELT, int RS>
const TAsVec& SimTK::SymMat< M, ELT, RS >::getAsVec ( ) const
inline

◆ updAsVec()

template<int M, class ELT, int RS>
TAsVec& SimTK::SymMat< M, ELT, RS >::updAsVec ( )
inline

◆ getEltDiag()

template<int M, class ELT, int RS>
const E& SimTK::SymMat< M, ELT, RS >::getEltDiag ( int  i) const
inline

◆ updEltDiag()

template<int M, class ELT, int RS>
E& SimTK::SymMat< M, ELT, RS >::updEltDiag ( int  i)
inline

◆ getEltLower()

template<int M, class ELT, int RS>
const E& SimTK::SymMat< M, ELT, RS >::getEltLower ( int  i,
int  j 
) const
inline

◆ updEltLower()

template<int M, class ELT, int RS>
E& SimTK::SymMat< M, ELT, RS >::updEltLower ( int  i,
int  j 
)
inline

◆ getEltUpper()

template<int M, class ELT, int RS>
const EHerm& SimTK::SymMat< M, ELT, RS >::getEltUpper ( int  i,
int  j 
) const
inline

◆ updEltUpper()

template<int M, class ELT, int RS>
EHerm& SimTK::SymMat< M, ELT, RS >::updEltUpper ( int  i,
int  j 
)
inline

◆ colSum()

template<int M, class ELT, int RS>
TRow SimTK::SymMat< M, ELT, RS >::colSum ( ) const
inline

Returns a row vector (Row) containing the column sums of this matrix.

◆ sum()

template<int M, class ELT, int RS>
TRow SimTK::SymMat< M, ELT, RS >::sum ( ) const
inline

This is an alternate name for colSum(); behaves like the Matlab function of the same name.

◆ rowSum()

template<int M, class ELT, int RS>
TCol SimTK::SymMat< M, ELT, RS >::rowSum ( ) const
inline

Returns a column vector (Vec) containing the row sums of this matrix.

This will be the conjugate transpose of the column sums.

Friends And Related Function Documentation

◆ SymMat

template<int M, class ELT, int RS>
template<int MM, class EE , int RSS>
friend class SymMat
friend

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