This is a small, fixed-size symmetric or Hermitian matrix designed for no-overhead inline computation.
More...
|
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...
|
|
SymMat & | operator= (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> |
SymMat & | setFromLower (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> |
SymMat & | setFromUpper (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> |
SymMat & | setFromSymmetric (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 > |
SymMat & | operator= (const EE *p) |
|
template<class EE , int RSS> |
SymMat & | operator= (const SymMat< M, EE, RSS > &mm) |
|
template<class EE , int RSS> |
SymMat & | operator+= (const SymMat< M, EE, RSS > &mm) |
|
template<class EE , int RSS> |
SymMat & | operator+= (const SymMat< M, negator< EE >, RSS > &mm) |
|
template<class EE , int RSS> |
SymMat & | operator-= (const SymMat< M, EE, RSS > &mm) |
|
template<class EE , int RSS> |
SymMat & | operator-= (const SymMat< M, negator< EE >, RSS > &mm) |
|
template<class EE , int RSS> |
SymMat & | operator*= (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 SymMat & | operator+ () const |
|
const TNeg & | operator- () const |
|
TNeg & | operator- () |
|
const THerm & | operator~ () const |
|
THerm & | operator~ () |
|
const TNeg & | negate () const |
|
TNeg & | updNegate () |
|
const THerm & | transpose () const |
|
THerm & | updTranspose () |
|
const TPosTrans & | positionalTranspose () const |
|
TPosTrans & | updPositionalTranspose () |
|
const TReal & | real () const |
|
TReal & | real () |
|
const TImag & | imag () const |
|
TImag & | imag () |
|
const TWithoutNegator & | castAwayNegatorIfAny () const |
|
TWithoutNegator & | updCastAwayNegatorIfAny () |
|
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 > |
SymMat & | operator= (const EE &e) |
|
template<class EE > |
SymMat & | operator+= (const EE &e) |
|
template<class EE > |
SymMat & | operator-= (const EE &e) |
|
template<class EE > |
SymMat & | operator*= (const EE &e) |
|
template<class EE > |
SymMat & | operator/= (const EE &e) |
|
template<class EE > |
SymMat & | scalarEq (const EE &ee) |
|
template<class EE > |
SymMat & | scalarPlusEq (const EE &ee) |
|
template<class EE > |
SymMat & | scalarMinusEq (const EE &ee) |
|
template<class EE > |
SymMat & | scalarMinusEqFromLeft (const EE &ee) |
|
template<class EE > |
SymMat & | scalarTimesEq (const EE &ee) |
|
template<class EE > |
SymMat & | scalarTimesEqFromLeft (const EE &ee) |
|
template<class EE > |
SymMat & | scalarDivideEq (const EE &ee) |
|
template<class EE > |
SymMat & | scalarDivideEqFromLeft (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 |
|
E | 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 TDiag & | getDiag () const |
|
TDiag & | updDiag () |
|
const TDiag & | diag () const |
|
TDiag & | diag () |
|
const TLower & | getLower () const |
|
TLower & | updLower () |
|
const TUpper & | getUpper () const |
|
TUpper & | updUpper () |
|
const TAsVec & | getAsVec () const |
|
TAsVec & | updAsVec () |
|
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...
|
|
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
-
M | The dimension of this square matrix. |
ELT | The element type. Must be a composite numerical type (CNT). The default is ELT=Real. |
RS | The 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).