1 #ifndef SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
2 #define SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
87 template <
int M,
class ELT,
int RS>
class SymMat {
89 typedef typename CNT<E>::TNeg ENeg;
90 typedef typename CNT<E>::TWithoutNegator EWithoutNegator;
91 typedef typename CNT<E>::TReal EReal;
92 typedef typename CNT<E>::TImag EImag;
93 typedef typename CNT<E>::TComplex EComplex;
94 typedef typename CNT<E>::THerm EHerm;
95 typedef typename CNT<E>::TPosTrans EPosTrans;
96 typedef typename CNT<E>::TSqHermT ESqHermT;
97 typedef typename CNT<E>::TSqTHerm ESqTHerm;
99 typedef typename CNT<E>::TSqrt ESqrt;
100 typedef typename CNT<E>::TAbs EAbs;
101 typedef typename CNT<E>::TStandard EStandard;
102 typedef typename CNT<E>::TInvert EInvert;
103 typedef typename CNT<E>::TNormalize ENormalize;
105 typedef typename CNT<E>::Scalar EScalar;
106 typedef typename CNT<E>::ULessScalar EULessScalar;
107 typedef typename CNT<E>::Number ENumber;
108 typedef typename CNT<E>::StdNumber EStdNumber;
109 typedef typename CNT<E>::Precision EPrecision;
110 typedef typename CNT<E>::ScalarNormSq EScalarNormSq;
175 static int size() {
return (M*(M+1))/2; }
176 static int nrow() {
return M; }
177 static int ncol() {
return M; }
221 typedef typename MulOp::Type
Mul;
224 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
226 typedef typename MulOpNonConforming::Type
MulNon;
230 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
232 typedef typename DvdOp::Type
Dvd;
235 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
237 typedef typename AddOp::Type
Add;
240 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
242 typedef typename SubOp::Type
Sub;
279 template <
class EE,
int CSS,
int RSS>
286 template <
class EE,
int CSS,
int RSS>
289 for (
int j=0; j<M; ++j)
290 for (
int i=j+1; i<M; ++i)
302 template <
class EE,
int CSS,
int RSS>
305 for (
int j=0; j<M; ++j)
306 for (
int i=j+1; i<M; ++i)
316 template <
class EE,
int CSS,
int RSS>
319 "The allegedly symmetric source matrix was not symmetric to within "
322 for (
int j=0; j<M; ++j)
323 for (
int i=j+1; i<M; ++i)
379 const E& e1,
const E& e2)
385 const E& e1,
const E& e2,
386 const E& e3,
const E& e4,
const E& e5)
393 const E& e1,
const E& e2,
394 const E& e3,
const E& e4,
const E& e5,
395 const E& e6,
const E& e7,
const E& e8,
const E& e9)
398 l[0]=e1;l[1]=e3;l[2]=e6;
403 const E& e1,
const E& e2,
404 const E& e3,
const E& e4,
const E& e5,
405 const E& e6,
const E& e7,
const E& e8,
const E& e9,
406 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14)
409 l[0]=e1;l[1]=e3;l[2]=e6;l[3]=e10;
410 l[4]=e4;l[5]=e7;l[6]=e11;
415 const E& e1,
const E& e2,
416 const E& e3,
const E& e4,
const E& e5,
417 const E& e6,
const E& e7,
const E& e8,
const E& e9,
418 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14,
419 const E& e15,
const E& e16,
const E& e17,
const E& e18,
const E& e19,
const E& e20)
423 l[0] =e1; l[1] =e3; l[2] =e6; l[3]=e10; l[4]=e15;
424 l[5] =e4; l[6] =e7; l[7] =e11; l[8]=e16;
425 l[9] =e8; l[10]=e12;l[11]=e17;
443 template <
class EE>
explicit SymMat(
const EE* p) {
445 for (
int i=0; i<M; ++i) {
446 const int rowStart = (i*(i+1))/2;
448 for (
int j=0; j<i; ++j)
457 for (
int i=0; i<M; ++i) {
458 const int rowStart = (i*(i+1))/2;
460 for (
int j=0; j<i; ++j)
476 template <
class EE,
int RSS>
SymMat&
481 template <
class EE,
int RSS>
SymMat&
487 template <
class EE,
int RSS>
SymMat&
492 template <
class EE,
int RSS>
SymMat&
500 template <
class EE,
int RSS>
SymMat&
510 template <
class E2,
int RS2>
511 typename Result<SymMat<M,E2,RS2> >::Add
513 return typename Result<SymMat<M,E2,RS2> >::Add
517 template <
class E2,
int RS2>
518 typename Result<SymMat<M,E2,RS2> >::Sub
520 return typename Result<SymMat<M,E2,RS2> >::Sub
527 template <
class E2,
int RS2>
528 typename Result<SymMat<M,E2,RS2> >::Mul
530 typename Result<SymMat<M,E2,RS2> >::Mul result;
531 for (
int j=0;j<M;++j)
532 for (
int i=0;i<M;++i)
533 result(i,j) = (*this)[i] * s(j);
538 template <
class E2,
int RS2>
539 typename EltResult<E2>::Mul
546 template <
class E2,
int RS2>
547 typename EltResult<E2>::Dvd
587 TNormalize elementwiseNormalized;
590 return elementwiseNormalized;
609 {
return *
reinterpret_cast<const TPosTrans*
>(
this); }
611 {
return *
reinterpret_cast<TPosTrans*
>(
this); }
619 const EImag* p =
reinterpret_cast<const EImag*
>(
this);
620 return *
reinterpret_cast<const TImag*
>(p+offs);
624 EImag* p =
reinterpret_cast<EImag*
>(
this);
625 return *
reinterpret_cast<TImag*
>(p+offs);
670 result.updDiag() += e;
704 {
updDiag() += ee;
return *
this; }
706 {
updDiag() -= ee;
return *
this; }
750 template <
class E2,
int RS2>
758 template <
class E2,
int RS2>
785 for (
int j=0; j<i; ++j)
788 for (
int j=i+1; j<M; ++j)
797 for (
int i=0; i<j; ++i)
800 for (
int i=j+1; i<M; ++i)
810 E
elt(
int i,
int j)
const {
848 for (
int i = 1; i < M; ++i)
849 for (
int j = 0; j < i; ++j) {
852 temp[i] += E(reinterpret_cast<const EHerm&>(value));
864 for (
int i = 1; i < M; ++i)
865 for (
int j = 0; j < i; ++j) {
868 temp[j] += E(reinterpret_cast<const EHerm&>(value));
877 const E& getlowerE(
int i)
const {
return d[(M+i)*RS];}
878 E& updlowerE(
int i) {
return d[(M+i)*RS];}
884 explicit SymMat(
const TAsVec& v) {
890 static int lowerIx(
int i,
int j) {
891 assert(0 <= j && j < i && i < M);
892 return (i-j-1) + j*(M-1) - (j*(j-1))/2;
895 template <
int MM,
class EE,
int RSS>
friend class SymMat;
904 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
908 ::AddOp::perform(l,r);
912 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
913 typename SymMat<M,E1,S1>::template Result< SymMat<M,E2,S2> >::Sub
916 ::SubOp::perform(l,r);
921 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
922 typename SymMat<M,E1,S1>::template Result< SymMat<M,E2,S2> >::Mul
925 ::MulOp::perform(l,r);
929 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline bool
931 return l.getAsVec() == r.getAsVec();
935 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline bool
945 template <
int M,
class E,
int S>
inline
946 typename SymMat<M,E,S>::template Result<float>::Mul
949 template <
int M,
class E,
int S>
inline
950 typename SymMat<M,E,S>::template Result<float>::Mul
953 template <
int M,
class E,
int S>
inline
954 typename SymMat<M,E,S>::template Result<double>::Mul
957 template <
int M,
class E,
int S>
inline
958 typename SymMat<M,E,S>::template Result<double>::Mul
961 template <
int M,
class E,
int S>
inline
962 typename SymMat<M,E,S>::template Result<long double>::Mul
965 template <
int M,
class E,
int S>
inline
966 typename SymMat<M,E,S>::template Result<long double>::Mul
970 template <
int M,
class E,
int S>
inline
971 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Mul
973 template <
int M,
class E,
int S>
inline
974 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Mul
980 template <
int M,
class E,
int S,
class R>
inline
981 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
984 template <
int M,
class E,
int S,
class R>
inline
985 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
989 template <
int M,
class E,
int S,
class R>
inline
990 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
992 template <
int M,
class E,
int S,
class R>
inline
993 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
997 template <
int M,
class E,
int S,
class R>
inline
998 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Mul
1000 template <
int M,
class E,
int S,
class R>
inline
1001 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Mul
1010 template <
int M,
class E,
int S>
inline
1011 typename SymMat<M,E,S>::template Result<float>::Dvd
1014 template <
int M,
class E,
int S>
inline
1015 typename CNT<float>::template Result<SymMat<M,E,S> >::Dvd
1019 template <
int M,
class E,
int S>
inline
1020 typename SymMat<M,E,S>::template Result<double>::Dvd
1023 template <
int M,
class E,
int S>
inline
1024 typename CNT<double>::template Result<SymMat<M,E,S> >::Dvd
1028 template <
int M,
class E,
int S>
inline
1029 typename SymMat<M,E,S>::template Result<long double>::Dvd
1032 template <
int M,
class E,
int S>
inline
1033 typename CNT<long double>::template Result<SymMat<M,E,S> >::Dvd
1038 template <
int M,
class E,
int S>
inline
1039 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Dvd
1041 template <
int M,
class E,
int S>
inline
1042 typename CNT<typename CNT<E>::Precision>::template Result<SymMat<M,E,S> >::Dvd
1049 template <
int M,
class E,
int S,
class R>
inline
1050 typename SymMat<M,E,S>::template Result<std::complex<R> >::Dvd
1053 template <
int M,
class E,
int S,
class R>
inline
1054 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Dvd
1059 template <
int M,
class E,
int S,
class R>
inline
1060 typename SymMat<M,E,S>::template Result<std::complex<R> >::Dvd
1062 template <
int M,
class E,
int S,
class R>
inline
1063 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Dvd
1067 template <
int M,
class E,
int S,
class R>
inline
1068 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Dvd
1070 template <
int M,
class E,
int S,
class R>
inline
1071 typename CNT<R>::template Result<SymMat<M,E,S> >::Dvd
1082 template <
int M,
class E,
int S>
inline
1083 typename SymMat<M,E,S>::template Result<float>::Add
1086 template <
int M,
class E,
int S>
inline
1087 typename SymMat<M,E,S>::template Result<float>::Add
1090 template <
int M,
class E,
int S>
inline
1091 typename SymMat<M,E,S>::template Result<double>::Add
1094 template <
int M,
class E,
int S>
inline
1095 typename SymMat<M,E,S>::template Result<double>::Add
1098 template <
int M,
class E,
int S>
inline
1099 typename SymMat<M,E,S>::template Result<long double>::Add
1102 template <
int M,
class E,
int S>
inline
1103 typename SymMat<M,E,S>::template Result<long double>::Add
1107 template <
int M,
class E,
int S>
inline
1108 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Add
1110 template <
int M,
class E,
int S>
inline
1111 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Add
1117 template <
int M,
class E,
int S,
class R>
inline
1118 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1121 template <
int M,
class E,
int S,
class R>
inline
1122 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1126 template <
int M,
class E,
int S,
class R>
inline
1127 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1129 template <
int M,
class E,
int S,
class R>
inline
1130 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1134 template <
int M,
class E,
int S,
class R>
inline
1135 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Add
1137 template <
int M,
class E,
int S,
class R>
inline
1138 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Add
1144 template <
int M,
class E,
int S>
inline
1145 typename SymMat<M,E,S>::template Result<float>::Sub
1148 template <
int M,
class E,
int S>
inline
1149 typename CNT<float>::template Result<SymMat<M,E,S> >::Sub
1153 template <
int M,
class E,
int S>
inline
1154 typename SymMat<M,E,S>::template Result<double>::Sub
1157 template <
int M,
class E,
int S>
inline
1158 typename CNT<double>::template Result<SymMat<M,E,S> >::Sub
1162 template <
int M,
class E,
int S>
inline
1163 typename SymMat<M,E,S>::template Result<long double>::Sub
1166 template <
int M,
class E,
int S>
inline
1167 typename CNT<long double>::template Result<SymMat<M,E,S> >::Sub
1172 template <
int M,
class E,
int S>
inline
1173 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Sub
1175 template <
int M,
class E,
int S>
inline
1176 typename CNT<typename CNT<E>::Precision>::template Result<SymMat<M,E,S> >::Sub
1183 template <
int M,
class E,
int S,
class R>
inline
1184 typename SymMat<M,E,S>::template Result<std::complex<R> >::Sub
1187 template <
int M,
class E,
int S,
class R>
inline
1188 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Sub
1193 template <
int M,
class E,
int S,
class R>
inline
1194 typename SymMat<M,E,S>::template Result<std::complex<R> >::Sub
1196 template <
int M,
class E,
int S,
class R>
inline
1197 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Sub
1201 template <
int M,
class E,
int S,
class R>
inline
1202 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Sub
1204 template <
int M,
class E,
int S,
class R>
inline
1205 typename CNT<R>::template Result<SymMat<M,E,S> >::Sub
1210 template <
int M,
class E,
int RS,
class CHAR,
class TRAITS>
inline
1211 std::basic_ostream<CHAR,TRAITS>&
1213 for (
int i=0;i<M;++i) {
1214 o << std::endl <<
"[";
1215 for (
int j=0; j<=i; ++j)
1216 o << (j>0?
" ":
"") << m(i,j);
1217 for (
int j=i+1; j<M; ++j)
1221 if (M) o << std::endl;
1225 template <
int M,
class E,
int RS,
class CHAR,
class TRAITS>
inline
1226 std::basic_istream<CHAR,TRAITS>&
1236 #endif //SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
Matrix_< E > operator/(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:613
SymMat< M, EInvert, 1 > TInvert
Definition: SymMat.h:162
const E & getEltDiag(int i) const
Definition: SymMat.h:834
SymMat< M, ENormalize, 1 > TNormalize
Definition: SymMat.h:163
SymMat< M, ESqTHerm, 1 > TSqTHerm
Definition: SymMat.h:165
SymMat< M, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft(const EE &e) const
Definition: SymMat.h:684
EPrecision Precision
Definition: SymMat.h:172
SymMat< M, EAbs, 1 > TAbs
Definition: SymMat.h:160
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 ...
Definition: SymMat.h:303
SymMat & operator/=(const EE &e)
Definition: SymMat.h:697
ScalarNormSq scalarNormSqr() const
Definition: SymMat.h:181
SymMat()
Default construction initializes to NaN when debugging but is left uninitialized otherwise.
Definition: SymMat.h:252
EltResult< E2 >::Mul elementwiseMultiply(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:540
SymMat(const ENeg &e)
Definition: SymMat.h:354
T THerm
Definition: SymMat.h:147
const TDiag & getDiag() const
Definition: SymMat.h:818
SymMat< M, ESqrt, 1 > TSqrt
Definition: SymMat.h:159
ScalarNormSq scalarNormSqr() const
Scalar norm square is sum( conjugate squares of all underlying scalars ), where conjugate square of s...
Definition: Vec.h:325
THerm & updTranspose()
Definition: SymMat.h:606
SymMat< M, EHerm, RS > TPosTrans
Definition: SymMat.h:148
bool isNaN() const
Return true if any element of this SymMat contains a NaN anywhere.
Definition: SymMat.h:735
SymMat & scalarMinusEq(const EE &ee)
Definition: SymMat.h:705
EStandard trace() const
Definition: SymMat.h:203
SymMat & operator+=(const EE &e)
Definition: SymMat.h:694
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 s...
Definition: SymMat.h:331
static const SymMat & getAs(const ELT *p)
Definition: SymMat.h:725
SymMat & scalarEq(const EE &ee)
Definition: SymMat.h:701
DvdOp::Type Dvd
Definition: SymMat.h:232
Vec & scalarMinusEqFromLeft(const EE &ee)
Definition: Vec.h:787
TSqrt sqrt() const
Definition: SymMat.h:188
TInvert invert() const
Definition: SymMat.h:594
TUpper & updUpper()
Definition: SymMat.h:829
static const THerm & transpose(const K &t)
Definition: CompositeNumericalTypes.h:216
static int ncol()
Definition: SymMat.h:177
SymMat< M, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: SymMat.h:660
SymMat< M, EWithoutNegator, RS > TWithoutNegator
Definition: SymMat.h:140
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
TAbs abs() const
Definition: SymMat.h:195
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
Vec< M, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: Vec.h:722
static Vec & updAs(ELT *p)
Recast a writable ordinary C++ array E[] to a writable Vec; assumes compatible length...
Definition: Vec.h:906
const TDiag & diag() const
Definition: SymMat.h:822
bool isFinite() const
Return true if no element contains an Infinity or a NaN.
Definition: SymMat.h:742
SymMat & operator-=(const EE &e)
Definition: SymMat.h:695
void setToZero()
Definition: SymMat.h:722
EScalarNormSq ScalarNormSq
Definition: SymMat.h:173
SymMat & scalarDivideEq(const EE &ee)
Definition: SymMat.h:716
SymMat< M, E, RS > T
Definition: SymMat.h:138
SymMat< M, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: SymMat.h:668
SymMat< M, EStandard, 1 > TStandard
Definition: SymMat.h:161
SymMat & scalarTimesEq(const EE &ee)
Definition: SymMat.h:712
#define SimTK_ERRCHK1(cond, whereChecked, fmt, a1)
Definition: ExceptionMacros.h:326
ScalarNormSq normSqr() const
Definition: SymMat.h:568
const TWithoutNegator & castAwayNegatorIfAny() const
Definition: SymMat.h:628
TRow row(int i) const
Definition: SymMat.h:781
MulOp::Type Mul
Definition: SymMat.h:221
void setToNaN()
Definition: SymMat.h:721
Result< SymMat< M, E2, RS2 > >::Mul conformingMultiply(const SymMat< M, E2, RS2 > &s) const
Definition: SymMat.h:529
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)
Definition: SymMat.h:402
const TLower & getLower() const
Definition: SymMat.h:825
EStdNumber StdNumber
Definition: SymMat.h:171
EStandard sum() const
Sum just adds up all the elements into a single return element that is the same type as this Vec's el...
Definition: Vec.h:364
const TPosTrans & positionalTranspose() const
Definition: SymMat.h:608
std::basic_istream< CHAR, TRAITS > & operator>>(std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c)
Definition: conjugate.h:800
Vec<(M *(M+1))/2, E, RS > TAsVec
Definition: SymMat.h:153
bool isNumericallyEqual(const Vec< M, E2, RS2 > &v, double tol) const
Test whether this vector is numerically equal to some other vector with the same shape, using a specified tolerance.
Definition: Vec.h:954
TPosTrans & updPositionalTranspose()
Definition: SymMat.h:610
This is a small, fixed-size symmetric or Hermitian matrix designed for no-overhead inline computation...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:592
Definition: CompositeNumericalTypes.h:120
static double getDefaultTolerance()
Definition: CompositeNumericalTypes.h:269
SymMat(const SymMat< M, EE, RSS > &src)
Construct a SymMat from a SymMat of the same dimensions, with any element type and spacing...
Definition: SymMat.h:342
SymMat< M, typename CNT< E >::template Result< P >::Sub, 1 > Sub
Definition: SymMat.h:212
TCol operator()(int j) const
Definition: SymMat.h:564
AddCNTs< M, M, ArgDepth, SymMat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > AddOp
Definition: SymMat.h:236
SymMat(const EE *p)
Definition: SymMat.h:443
SymMat< M, typename CNT< E >::template Result< P >::Add, 1 > Add
Definition: SymMat.h:211
EltResult< E2 >::Dvd elementwiseDivide(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:548
bool operator==(const PhiMatrix &p1, const PhiMatrix &p2)
Definition: SpatialAlgebra.h:774
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.
Definition: SymMat.h:759
void setToNaN()
Set every scalar in this Vec to NaN; this is the default initial value in Debug builds, but not in Release.
Definition: Vec.h:810
SymMat & scalarPlusEq(const EE &ee)
Definition: SymMat.h:703
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)
Definition: SymMat.h:392
SymMat & scalarDivideEqFromLeft(const EE &ee)
Definition: SymMat.h:718
static const Vec & getAs(const ELT *p)
Recast an ordinary C++ array E[] to a const Vec; assumes compatible length, stride, and packing.
Definition: Vec.h:902
const TNeg & operator-() const
Definition: SymMat.h:597
static SymMat & updAs(ELT *p)
Definition: SymMat.h:726
SubOp::Type Sub
Definition: SymMat.h:242
EHerm & updEltUpper(int i, int j)
Definition: SymMat.h:843
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 a...
Definition: SymMat.h:810
TNormalize normalize() const
If the elements of this Vec are scalars, the result is what you get by dividing each element by the n...
Definition: Vec.h:621
SymMat(const E &e)
Definition: SymMat.h:347
bool isNumericallySymmetric(double tol=getDefaultTolerance()) const
A Matrix is symmetric (actually Hermitian) if it is square and each element (i,j) is the Hermitian tr...
Definition: Mat.h:1172
CNT< ScalarNormSq >::TSqrt norm() const
Definition: SymMat.h:570
SymMat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
Definition: SymMat.h:384
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.
Definition: SymMat.h:751
SymMat< M, EImag, RS *CNT< E >::RealStrideFactor > TImag
Definition: SymMat.h:145
SymMat & operator-=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:488
const THerm & transpose() const
Definition: SymMat.h:605
SymMat & operator+=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:477
static int size()
Definition: SymMat.h:175
TImag & imag()
Definition: SymMat.h:622
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
bool isInf() const
Return true if any element of this Vec contains a +Infinity or -Infinity somewhere but no element con...
Definition: Vec.h:925
SymMat< M, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: SymMat.h:639
MulCNTs< M, M, ArgDepth, SymMat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > MulOp
Definition: SymMat.h:220
Matrix_< E > operator*(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:605
const SymMat & operator+() const
Definition: SymMat.h:596
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...
Definition: SymMat.h:378
TRow colSum() const
Returns a row vector (Row) containing the column sums of this matrix.
Definition: SymMat.h:846
const EHerm & getEltUpper(int i, int j) const
Definition: SymMat.h:842
TRow operator[](int i) const
Definition: SymMat.h:563
SymMat< M, typename CNT< E >::template Result< P >::Mul, 1 > Mul
Definition: SymMat.h:209
bool isNaN() const
Return true if any element of this Vec contains a NaN anywhere.
Definition: Vec.h:916
Vec< M, E, RS > TDiag
Definition: SymMat.h:150
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
bool isFinite() const
Return true if no element of this Vec contains an Infinity or a NaN anywhere.
Definition: Vec.h:940
TStandard standardize() const
Definition: SymMat.h:199
Vec<(M *(M-1))/2, E, RS > TLower
Definition: SymMat.h:151
TLower & updLower()
Definition: SymMat.h:826
SymMat & operator=(const EE *p)
Definition: SymMat.h:455
SymMat< M, EComplex, RS > TComplex
Definition: SymMat.h:146
TRow sum() const
This is an alternate name for colSum(); behaves like the Matlab function of the same name...
Definition: SymMat.h:858
SymMat & scalarMinusEqFromLeft(const EE &ee)
Definition: SymMat.h:709
TDiag & updDiag()
Definition: SymMat.h:819
const TDiag & diag() const
Select main diagonal (of largest leading square if rectangular) and return it as a read-only view (as...
Definition: Mat.h:798
SubCNTs< M, M, ArgDepth, SymMat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > SubOp
Definition: SymMat.h:241
SymMat & operator=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:469
E & updEltDiag(int i)
Definition: SymMat.h:835
negator, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
EULessScalar ULessScalar
Definition: SymMat.h:169
This is a fixed-length row vector designed for no-overhead inline computation.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:590
static double getDefaultTolerance()
For approximate comparisions, the default tolerance to use for a matrix is its shortest dimension tim...
Definition: Mat.h:1121
Vec<(M *(M-1))/2, EHerm, RS > TUpper
Definition: SymMat.h:152
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 symmetri...
Definition: SymMat.h:317
bool isInf() const
Return true if any element of this SymMat contains a +Inf or -Inf somewhere but no element contains a...
Definition: SymMat.h:739
TDiag & diag()
Definition: SymMat.h:823
bool operator!=(const conjugate< R > &a, const float &b)
Definition: conjugate.h:859
NTraits< N >::StdNumber StdNumber
Definition: negator.h:107
Row< M, E, 1 > TRow
Definition: SymMat.h:157
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
Vec< M, E, 1 > TCol
Definition: SymMat.h:158
static int nrow()
Definition: SymMat.h:176
SymMat & operator=(const SymMat &src)
Copy assignment; no harm if source and this are the same matrix.
Definition: SymMat.h:264
THerm & operator~()
Definition: SymMat.h:600
TReal & real()
Definition: SymMat.h:614
EScalar Scalar
Definition: SymMat.h:168
const TUpper & getUpper() const
Definition: SymMat.h:828
TNeg & updNegate()
Definition: SymMat.h:603
E TElement
Definition: SymMat.h:149
SymMat & operator+=(const SymMat< M, negator< EE >, RSS > &mm)
Definition: SymMat.h:482
SymMat< M, typename CNT< E >::template Result< EE >::Sub > scalarSubtract(const EE &e) const
Definition: SymMat.h:676
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:591
Mandatory first inclusion for any Simbody source or header file.
Vec< M, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: Vec.h:737
const TAsVec & getAsVec() const
Definition: SymMat.h:831
Vec & scalarTimesEqFromLeft(const EE &ee)
Definition: Vec.h:791
Vec< M, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: Vec.h:728
TNormalize normalize() const
There is no conventional meaning for normalize() applied to a matrix.
Definition: SymMat.h:583
E & updEltLower(int i, int j)
Definition: SymMat.h:839
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)
Definition: SymMat.h:414
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
TWithoutNegator & updCastAwayNegatorIfAny()
Definition: SymMat.h:629
SymMat< M, EReal, RS *CNT< E >::RealStrideFactor > TReal
Definition: SymMat.h:143
SymMat< M, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: SymMat.h:654
ENumber Number
Definition: SymMat.h:170
const THerm & operator~() const
Definition: SymMat.h:599
AddOp::Type Add
Definition: SymMat.h:237
TCol col(int j) const
Definition: SymMat.h:793
This is a fixed-length column vector designed for no-overhead inline computation. ...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:589
const TReal & real() const
Return a reference to the real portion of this Vec if it has complex elements; otherwise the type doe...
Definition: Vec.h:679
DvdCNTs< M, M, ArgDepth, SymMat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > DvdOp
Definition: SymMat.h:231
const E & getEltLower(int i, int j) const
Definition: SymMat.h:838
SymMat & scalarTimesEqFromLeft(const EE &ee)
Definition: SymMat.h:714
SymMat< M, P > Type
Definition: SymMat.h:247
const TNeg & negate() const
Definition: SymMat.h:602
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:512
SimTK::conjugate should be instantiated only for float, double, long double.
Definition: String.h:45
SymMat< M, typename CNT< E >::template Result< P >::Dvd, 1 > Dvd
Definition: SymMat.h:210
MulCNTsNonConforming< M, M, ArgDepth, SymMat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > MulOpNonConforming
Definition: SymMat.h:225
Vec< M, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: Vec.h:743
void setToZero()
Set every scalar in this Vec to zero.
Definition: Vec.h:815
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 symm...
Definition: SymMat.h:280
SymMat(int i)
Definition: SymMat.h:361
SymMat & operator*=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:501
const E & operator()(int i, int j) const
Definition: SymMat.h:556
static TPacked getNaN()
Definition: SymMat.h:729
const TImag & imag() const
Definition: SymMat.h:617
SymMat< M, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: SymMat.h:645
TNeg & operator-()
Definition: SymMat.h:598
MulOpNonConforming::Type MulNon
Definition: SymMat.h:226
SymMat(const SymMat &src)
Copy constructor.
Definition: SymMat.h:259
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:519
E & operator()(int i, int j)
Definition: SymMat.h:558
SymMat< M, ESqHermT, 1 > TSqHermT
Definition: SymMat.h:164
SymMat(const SymMat< M, ENeg, RSS > &src)
This is an implicit conversion from a SymMat of the same length and negated element type...
Definition: SymMat.h:336
Vec & scalarDivideEqFromLeft(const EE &ee)
Definition: Vec.h:795
const TReal & real() const
Definition: SymMat.h:613
static const TReal & real(const T &t)
Definition: CompositeNumericalTypes.h:203
static double getDefaultTolerance()
For approximate comparisions, the default tolerance to use for a matrix is its shortest dimension tim...
Definition: SymMat.h:746
SymMat< M, E, 1 > TPacked
Definition: SymMat.h:166
TCol rowSum() const
Returns a column vector (Vec) containing the row sums of this matrix.
Definition: SymMat.h:862
SymMat< M, ENeg, RS > TNeg
Definition: SymMat.h:139
TAsVec & updAsVec()
Definition: SymMat.h:832
SymMat & operator-=(const SymMat< M, negator< EE >, RSS > &mm)
Definition: SymMat.h:493
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 ...
Definition: SymMat.h:287
SymMat & operator*=(const EE &e)
Definition: SymMat.h:696