1 #ifndef SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
2 #define SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
71 template <
int M,
class ELT,
int RS>
class SymMat {
159 static int size() {
return (M*(M+1))/2; }
160 static int nrow() {
return M; }
161 static int ncol() {
return M; }
205 typedef typename MulOp::Type
Mul;
210 typedef typename MulOpNonConforming::Type
MulNon;
216 typedef typename DvdOp::Type
Dvd;
221 typedef typename AddOp::Type
Add;
226 typedef typename SubOp::Type
Sub;
263 template <
class EE,
int CSS,
int RSS>
270 template <
class EE,
int CSS,
int RSS>
273 for (
int j=0; j<M; ++j)
274 for (
int i=j+1; i<M; ++i)
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)
300 template <
class EE,
int CSS,
int RSS>
303 "The allegedly symmetric source matrix was not symmetric to within "
306 for (
int j=0; j<M; ++j)
307 for (
int i=j+1; i<M; ++i)
363 const E& e1,
const E& e2)
369 const E& e1,
const E& e2,
370 const E& e3,
const E& e4,
const E& e5)
377 const E& e1,
const E& e2,
378 const E& e3,
const E& e4,
const E& e5,
379 const E& e6,
const E& e7,
const E& e8,
const E& e9)
382 l[0]=e1;l[1]=e3;l[2]=e6;
387 const E& e1,
const E& e2,
388 const E& e3,
const E& e4,
const E& e5,
389 const E& e6,
const E& e7,
const E& e8,
const E& e9,
390 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14)
393 l[0]=e1;l[1]=e3;l[2]=e6;l[3]=e10;
394 l[4]=e4;l[5]=e7;l[6]=e11;
399 const E& e1,
const E& e2,
400 const E& e3,
const E& e4,
const E& e5,
401 const E& e6,
const E& e7,
const E& e8,
const E& e9,
402 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14,
403 const E& e15,
const E& e16,
const E& e17,
const E& e18,
const E& e19,
const E& e20)
407 l[0] =e1; l[1] =e3; l[2] =e6; l[3]=e10; l[4]=e15;
408 l[5] =e4; l[6] =e7; l[7] =e11; l[8]=e16;
409 l[9] =e8; l[10]=e12;l[11]=e17;
427 template <
class EE>
explicit SymMat(
const EE* p) {
429 for (
int i=0; i<M; ++i) {
430 const int rowStart = (i*(i+1))/2;
432 for (
int j=0; j<i; ++j)
441 for (
int i=0; i<M; ++i) {
442 const int rowStart = (i*(i+1))/2;
444 for (
int j=0; j<i; ++j)
460 template <
class EE,
int RSS>
SymMat&
465 template <
class EE,
int RSS>
SymMat&
471 template <
class EE,
int RSS>
SymMat&
476 template <
class EE,
int RSS>
SymMat&
484 template <
class EE,
int RSS>
SymMat&
494 template <
class E2,
int RS2>
495 typename Result<SymMat<M,E2,RS2> >::Add
497 return typename Result<SymMat<M,E2,RS2> >::Add
501 template <
class E2,
int RS2>
502 typename Result<SymMat<M,E2,RS2> >::Sub
504 return typename Result<SymMat<M,E2,RS2> >::Sub
511 template <
class E2,
int RS2>
512 typename Result<SymMat<M,E2,RS2> >::Mul
514 typename Result<SymMat<M,E2,RS2> >::Mul result;
515 for (
int j=0;j<M;++j)
516 for (
int i=0;i<M;++i)
517 result(i,j) = (*this)[i] * s(j);
522 template <
class E2,
int RS2>
523 typename EltResult<E2>::Mul
530 template <
class E2,
int RS2>
531 typename EltResult<E2>::Dvd
571 TNormalize elementwiseNormalized;
574 return elementwiseNormalized;
593 {
return *
reinterpret_cast<const TPosTrans*
>(
this); }
595 {
return *
reinterpret_cast<TPosTrans*
>(
this); }
603 const EImag* p =
reinterpret_cast<const EImag*
>(
this);
604 return *
reinterpret_cast<const TImag*
>(p+offs);
608 EImag* p =
reinterpret_cast<EImag*
>(
this);
609 return *
reinterpret_cast<TImag*
>(p+offs);
688 {
updDiag() += ee;
return *
this; }
690 {
updDiag() -= ee;
return *
this; }
734 template <
class E2,
int RS2>
742 template <
class E2,
int RS2>
769 for (
int j=0; j<i; ++j)
772 for (
int j=i+1; j<M; ++j)
781 for (
int i=0; i<j; ++i)
784 for (
int i=j+1; i<M; ++i)
794 E
elt(
int i,
int j)
const {
832 for (
int i = 1; i < M; ++i)
833 for (
int j = 0; j < i; ++j) {
836 temp[i] += E(reinterpret_cast<const EHerm&>(value));
848 for (
int i = 1; i < M; ++i)
849 for (
int j = 0; j < i; ++j) {
852 temp[j] += E(reinterpret_cast<const EHerm&>(value));
861 const E& getlowerE(
int i)
const {
return d[(M+i)*RS];}
862 E& updlowerE(
int i) {
return d[(M+i)*RS];}
868 explicit SymMat(
const TAsVec& v) {
874 static int lowerIx(
int i,
int j) {
875 assert(0 <= j && j < i && i < M);
876 return (i-j-1) + j*(M-1) - (j*(j-1))/2;
879 template <
int MM,
class EE,
int RSS>
friend class SymMat;
888 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
892 ::AddOp::perform(l,r);
896 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
897 typename SymMat<M,E1,S1>::template Result< SymMat<M,E2,S2> >::Sub
900 ::SubOp::perform(l,r);
905 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline
906 typename SymMat<M,E1,S1>::template Result< SymMat<M,E2,S2> >::Mul
909 ::MulOp::perform(l,r);
913 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline bool
919 template <
int M,
class E1,
int S1,
class E2,
int S2>
inline bool
929 template <
int M,
class E,
int S>
inline
930 typename SymMat<M,E,S>::template Result<float>::Mul
933 template <
int M,
class E,
int S>
inline
934 typename SymMat<M,E,S>::template Result<float>::Mul
937 template <
int M,
class E,
int S>
inline
938 typename SymMat<M,E,S>::template Result<double>::Mul
941 template <
int M,
class E,
int S>
inline
942 typename SymMat<M,E,S>::template Result<double>::Mul
945 template <
int M,
class E,
int S>
inline
946 typename SymMat<M,E,S>::template Result<long double>::Mul
949 template <
int M,
class E,
int S>
inline
950 typename SymMat<M,E,S>::template Result<long double>::Mul
954 template <
int M,
class E,
int S>
inline
955 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Mul
957 template <
int M,
class E,
int S>
inline
958 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Mul
964 template <
int M,
class E,
int S,
class R>
inline
965 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
968 template <
int M,
class E,
int S,
class R>
inline
969 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
973 template <
int M,
class E,
int S,
class R>
inline
974 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
976 template <
int M,
class E,
int S,
class R>
inline
977 typename SymMat<M,E,S>::template Result<std::complex<R> >::Mul
981 template <
int M,
class E,
int S,
class R>
inline
982 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Mul
984 template <
int M,
class E,
int S,
class R>
inline
985 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Mul
994 template <
int M,
class E,
int S>
inline
995 typename SymMat<M,E,S>::template Result<float>::Dvd
998 template <
int M,
class E,
int S>
inline
999 typename CNT<float>::template Result<SymMat<M,E,S> >::Dvd
1003 template <
int M,
class E,
int S>
inline
1004 typename SymMat<M,E,S>::template Result<double>::Dvd
1007 template <
int M,
class E,
int S>
inline
1008 typename CNT<double>::template Result<SymMat<M,E,S> >::Dvd
1012 template <
int M,
class E,
int S>
inline
1013 typename SymMat<M,E,S>::template Result<long double>::Dvd
1016 template <
int M,
class E,
int S>
inline
1017 typename CNT<long double>::template Result<SymMat<M,E,S> >::Dvd
1022 template <
int M,
class E,
int S>
inline
1023 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Dvd
1025 template <
int M,
class E,
int S>
inline
1026 typename CNT<typename CNT<E>::Precision>::template Result<SymMat<M,E,S> >::Dvd
1033 template <
int M,
class E,
int S,
class R>
inline
1034 typename SymMat<M,E,S>::template Result<std::complex<R> >::Dvd
1037 template <
int M,
class E,
int S,
class R>
inline
1038 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Dvd
1043 template <
int M,
class E,
int S,
class R>
inline
1044 typename SymMat<M,E,S>::template Result<std::complex<R> >::Dvd
1046 template <
int M,
class E,
int S,
class R>
inline
1047 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Dvd
1051 template <
int M,
class E,
int S,
class R>
inline
1052 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Dvd
1054 template <
int M,
class E,
int S,
class R>
inline
1055 typename CNT<R>::template Result<SymMat<M,E,S> >::Dvd
1066 template <
int M,
class E,
int S>
inline
1067 typename SymMat<M,E,S>::template Result<float>::Add
1070 template <
int M,
class E,
int S>
inline
1071 typename SymMat<M,E,S>::template Result<float>::Add
1074 template <
int M,
class E,
int S>
inline
1075 typename SymMat<M,E,S>::template Result<double>::Add
1078 template <
int M,
class E,
int S>
inline
1079 typename SymMat<M,E,S>::template Result<double>::Add
1082 template <
int M,
class E,
int S>
inline
1083 typename SymMat<M,E,S>::template Result<long double>::Add
1086 template <
int M,
class E,
int S>
inline
1087 typename SymMat<M,E,S>::template Result<long double>::Add
1091 template <
int M,
class E,
int S>
inline
1092 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Add
1094 template <
int M,
class E,
int S>
inline
1095 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Add
1101 template <
int M,
class E,
int S,
class R>
inline
1102 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1105 template <
int M,
class E,
int S,
class R>
inline
1106 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1110 template <
int M,
class E,
int S,
class R>
inline
1111 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1113 template <
int M,
class E,
int S,
class R>
inline
1114 typename SymMat<M,E,S>::template Result<std::complex<R> >::Add
1118 template <
int M,
class E,
int S,
class R>
inline
1119 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Add
1121 template <
int M,
class E,
int S,
class R>
inline
1122 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Add
1128 template <
int M,
class E,
int S>
inline
1129 typename SymMat<M,E,S>::template Result<float>::Sub
1132 template <
int M,
class E,
int S>
inline
1133 typename CNT<float>::template Result<SymMat<M,E,S> >::Sub
1137 template <
int M,
class E,
int S>
inline
1138 typename SymMat<M,E,S>::template Result<double>::Sub
1141 template <
int M,
class E,
int S>
inline
1142 typename CNT<double>::template Result<SymMat<M,E,S> >::Sub
1146 template <
int M,
class E,
int S>
inline
1147 typename SymMat<M,E,S>::template Result<long double>::Sub
1150 template <
int M,
class E,
int S>
inline
1151 typename CNT<long double>::template Result<SymMat<M,E,S> >::Sub
1156 template <
int M,
class E,
int S>
inline
1157 typename SymMat<M,E,S>::template Result<typename CNT<E>::Precision>::Sub
1159 template <
int M,
class E,
int S>
inline
1160 typename CNT<typename CNT<E>::Precision>::template Result<SymMat<M,E,S> >::Sub
1167 template <
int M,
class E,
int S,
class R>
inline
1168 typename SymMat<M,E,S>::template Result<std::complex<R> >::Sub
1171 template <
int M,
class E,
int S,
class R>
inline
1172 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Sub
1177 template <
int M,
class E,
int S,
class R>
inline
1178 typename SymMat<M,E,S>::template Result<std::complex<R> >::Sub
1180 template <
int M,
class E,
int S,
class R>
inline
1181 typename CNT<std::complex<R> >::template Result<SymMat<M,E,S> >::Sub
1185 template <
int M,
class E,
int S,
class R>
inline
1186 typename SymMat<M,E,S>::template Result<typename negator<R>::StdNumber>::Sub
1188 template <
int M,
class E,
int S,
class R>
inline
1189 typename CNT<R>::template Result<SymMat<M,E,S> >::Sub
1194 template <
int M,
class E,
int RS,
class CHAR,
class TRAITS>
inline
1195 std::basic_ostream<CHAR,TRAITS>&
1197 for (
int i=0;i<M;++i) {
1198 o << std::endl <<
"[";
1199 for (
int j=0; j<=i; ++j)
1200 o << (j>0?
" ":
"") << m(i,j);
1201 for (
int j=i+1; j<M; ++j)
1205 if (M) o << std::endl;
1209 template <
int M,
class E,
int RS,
class CHAR,
class TRAITS>
inline
1210 std::basic_istream<CHAR,TRAITS>&
1220 #endif //SimTK_SIMMATRIX_SMALLMATRIX_SYMMAT_H_
Matrix_< E > operator/(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:2693
SymMat(const E &e)
Definition: SymMat.h:331
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:1126
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:376
SymMat & scalarPlusEq(const EE &ee)
Definition: SymMat.h:687
TCol rowSum() const
Returns a column vector (Vec) containing the row sums of this matrix.
Definition: SymMat.h:846
const TReal & real() const
Definition: SymMat.h:597
SymMat< M, ESqTHerm, 1 > TSqTHerm
Definition: SymMat.h:149
bool isFinite() const
Return true if no element of this Vec contains an Infinity or a NaN anywhere.
Definition: Vec.h:887
Vec<(M *(M+1))/2, E, RS > TAsVec
Definition: SymMat.h:137
TNeg & operator-()
Definition: SymMat.h:582
K::ScalarNormSq ScalarNormSq
Definition: CompositeNumericalTypes.h:166
const TDiag & getDiag() const
Definition: SymMat.h:802
SymMat & operator*=(const EE &e)
Definition: SymMat.h:680
SymMat(int i)
Definition: SymMat.h:345
K::ULessScalar ULessScalar
Definition: CompositeNumericalTypes.h:161
SymMat< M, E, 1 > TPacked
Definition: SymMat.h:150
SymMat< M, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: SymMat.h:644
K::TReal TReal
Definition: CompositeNumericalTypes.h:141
SymMat< M, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: SymMat.h:629
SymMat & operator=(const EE *p)
Definition: SymMat.h:439
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:503
Vec< M, E, RS > TDiag
Definition: SymMat.h:134
SymMat & operator+=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:461
ScalarNormSq scalarNormSqr() const
Scalar norm square is sum( conjugate squares of all underlying scalars ), where conjugate square of s...
Definition: Vec.h:272
DvdOp::Type Dvd
Definition: SymMat.h:216
const E & getEltLower(int i, int j) const
Definition: SymMat.h:822
const TLower & getLower() const
Definition: SymMat.h:809
RS is total spacing between rows in memory (default 1)
Definition: SymMat.h:71
SymMat & scalarMinusEqFromLeft(const EE &ee)
Definition: SymMat.h:693
SymMat & scalarDivideEqFromLeft(const EE &ee)
Definition: SymMat.h:702
E TElement
Definition: SymMat.h:133
static const THerm & transpose(const K &t)
Definition: CompositeNumericalTypes.h:216
const TNeg & negate() const
Definition: SymMat.h:586
const TWithoutNegator & castAwayNegatorIfAny() const
Definition: SymMat.h:612
bool isNaN() const
Return true if any element of this Vec contains a NaN anywhere.
Definition: Vec.h:863
SimTK::conjugate<R> should be instantiated only for float, double, long double.
Definition: String.h:45
const SymMat & operator+() const
Definition: SymMat.h:580
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
const TNeg & operator-() const
Definition: SymMat.h:581
const TUpper & getUpper() const
Definition: SymMat.h:812
SymMat & scalarTimesEq(const EE &ee)
Definition: SymMat.h:696
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
static Vec & updAs(ELT *p)
Recast a writable ordinary C++ array E[] to a writable Vec<M,E,S>; assumes compatible length...
Definition: Vec.h:853
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
K::TNormalize TNormalize
Definition: CompositeNumericalTypes.h:158
EULessScalar ULessScalar
Definition: SymMat.h:153
Vec< M, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: Vec.h:675
TDiag & diag()
Definition: SymMat.h:807
SymMat & scalarTimesEqFromLeft(const EE &ee)
Definition: SymMat.h:698
TAsVec & updAsVec()
Definition: SymMat.h:816
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:301
#define SimTK_ERRCHK1(cond, whereChecked, fmt, a1)
Definition: ExceptionMacros.h:326
E & updEltLower(int i, int j)
Definition: SymMat.h:823
K::TImag TImag
Definition: CompositeNumericalTypes.h:142
T THerm
Definition: SymMat.h:131
MulOp::Type Mul
Definition: SymMat.h:205
EPrecision Precision
Definition: SymMat.h:156
SymMat< M, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: SymMat.h:652
Vec<(M *(M-1))/2, E, RS > TLower
Definition: SymMat.h:135
std::basic_istream< CHAR, TRAITS > & operator>>(std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c)
Definition: conjugate.h:800
void setToZero()
Definition: SymMat.h:706
negator<N>, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
Definition: CompositeNumericalTypes.h:120
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:320
SymMat< M, EWithoutNegator, RS > TWithoutNegator
Definition: SymMat.h:124
bool isFinite() const
Return true if no element contains an Infinity or a NaN.
Definition: SymMat.h:726
static double getDefaultTolerance()
Definition: CompositeNumericalTypes.h:269
const THerm & transpose() const
Definition: SymMat.h:589
SymMat< M, typename CNT< E >::template Result< P >::Sub, 1 > Sub
Definition: SymMat.h:196
TDiag & updDiag()
Definition: SymMat.h:803
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:220
SymMat< M, typename CNT< E >::template Result< P >::Add, 1 > Add
Definition: SymMat.h:195
const THerm & operator~() const
Definition: SymMat.h:583
SymMat< M, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft(const EE &e) const
Definition: SymMat.h:668
bool operator==(const PhiMatrix &p1, const PhiMatrix &p2)
Definition: SpatialAlgebra.h:774
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:386
E & operator()(int i, int j)
Definition: SymMat.h:542
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:264
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:315
TCol col(int j) const
Definition: SymMat.h:777
TSqrt sqrt() const
Definition: SymMat.h:172
SymMat & operator=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:453
TImag & imag()
Definition: SymMat.h:606
SymMat & scalarMinusEq(const EE &ee)
Definition: SymMat.h:689
SymMat< M, typename CNT< E >::template Result< EE >::Sub > scalarSubtract(const EE &e) const
Definition: SymMat.h:660
SubOp::Type Sub
Definition: SymMat.h:226
Row< M, E, 1 > TRow
Definition: SymMat.h:141
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:326
SymMat & scalarDivideEq(const EE &ee)
Definition: SymMat.h:700
TInvert invert() const
Definition: SymMat.h:578
K::TSqTHerm TSqTHerm
Definition: CompositeNumericalTypes.h:147
SymMat(const SymMat &src)
Copy constructor.
Definition: SymMat.h:243
void setToNaN()
Definition: SymMat.h:705
TReal & real()
Definition: SymMat.h:598
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:743
THerm & updTranspose()
Definition: SymMat.h:590
TRow row(int i) const
Definition: SymMat.h:765
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:311
SymMat< M, ESqrt, 1 > TSqrt
Definition: SymMat.h:143
SymMat & operator*=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:485
This is a fixed length column vector designed for no-overhead inline computation. ...
Definition: Vec.h:131
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:496
SymMat & operator-=(const SymMat< M, negator< EE >, RSS > &mm)
Definition: SymMat.h:477
EltResult< E2 >::Mul elementwiseMultiply(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:524
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:626
Vec< M, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: Vec.h:669
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:287
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
TRow sum() const
This is an alternate name for colSum(); behaves like the Matlab function of the same name...
Definition: SymMat.h:842
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:204
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:757
Matrix_< E > operator*(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:2685
const TAsVec & getAsVec() const
Definition: SymMat.h:815
void setToZero()
Set every scalar in this Vec to zero.
Definition: Vec.h:762
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:752
K::TInvert TInvert
Definition: CompositeNumericalTypes.h:157
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:901
SymMat< M, typename CNT< E >::template Result< P >::Mul, 1 > Mul
Definition: SymMat.h:193
THerm & operator~()
Definition: SymMat.h:584
SymMat & operator-=(const EE &e)
Definition: SymMat.h:679
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:723
SymMat(const EE *p)
Definition: SymMat.h:427
SymMat()
Default construction initializes to NaN when debugging but is left uninitialized otherwise.
Definition: SymMat.h:236
SymMat< M, E, RS > T
Definition: SymMat.h:122
E & updEltDiag(int i)
Definition: SymMat.h:819
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
SymMat & scalarEq(const EE &ee)
Definition: SymMat.h:685
NTraits< N >::StdNumber StdNumber
Definition: negator.h:107
static const SymMat & getAs(const ELT *p)
Definition: SymMat.h:709
TRow operator[](int i) const
Definition: SymMat.h:547
SymMat< M, EHerm, RS > TPosTrans
Definition: SymMat.h:132
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:794
SymMat< M, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: SymMat.h:638
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:225
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:568
K::TPosTrans TPosTrans
Definition: CompositeNumericalTypes.h:145
SymMat & operator+=(const SymMat< M, negator< EE >, RSS > &mm)
Definition: SymMat.h:466
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:271
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:398
SymMat & operator=(const SymMat &src)
Copy assignment; no harm if source and this are the same matrix.
Definition: SymMat.h:248
TLower & updLower()
Definition: SymMat.h:810
EScalar Scalar
Definition: SymMat.h:152
static TPacked getNaN()
Definition: SymMat.h:713
SymMat< M, EStandard, 1 > TStandard
Definition: SymMat.h:145
EHerm & updEltUpper(int i, int j)
Definition: SymMat.h:827
SymMat< M, EImag, RS *CNT< E >::RealStrideFactor > TImag
Definition: SymMat.h:129
SymMat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
Definition: SymMat.h:368
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
TCol operator()(int j) const
Definition: SymMat.h:548
Vec & scalarTimesEqFromLeft(const EE &ee)
Definition: Vec.h:738
bool operator!=(const conjugate< R > &a, const float &b)
Definition: conjugate.h:859
Vec< M, E, 1 > TCol
Definition: SymMat.h:142
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
Vec<(M *(M-1))/2, EHerm, RS > TUpper
Definition: SymMat.h:136
SymMat & operator-=(const SymMat< M, EE, RSS > &mm)
Definition: SymMat.h:472
SymMat< M, ESqHermT, 1 > TSqHermT
Definition: SymMat.h:148
const E & operator()(int i, int j) const
Definition: SymMat.h:540
SymMat< M, EInvert, 1 > TInvert
Definition: SymMat.h:146
Generic Row.
Definition: Row.h:118
TNeg & updNegate()
Definition: SymMat.h:587
const TDiag & diag() const
Definition: SymMat.h:806
EStandard trace() const
Definition: SymMat.h:187
Vec & scalarMinusEqFromLeft(const EE &ee)
Definition: Vec.h:734
Mandatory first inclusion for any Simbody source or header file.
static double getDefaultTolerance()
For approximate comparisions, the default tolerance to use for a matrix is its shortest dimension tim...
Definition: SymMat.h:730
EScalarNormSq ScalarNormSq
Definition: SymMat.h:157
K::TNeg TNeg
Definition: CompositeNumericalTypes.h:139
TAbs abs() const
Definition: SymMat.h:179
static SymMat & updAs(ELT *p)
Definition: SymMat.h:710
static double getDefaultTolerance()
For approximate comparisions, the default tolerance to use for a matrix is its shortest dimension tim...
Definition: Mat.h:1075
ENumber Number
Definition: SymMat.h:154
K::TStandard TStandard
Definition: CompositeNumericalTypes.h:156
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
EStdNumber StdNumber
Definition: SymMat.h:155
K::TWithoutNegator TWithoutNegator
Definition: CompositeNumericalTypes.h:140
const EHerm & getEltUpper(int i, int j) const
Definition: SymMat.h:826
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:735
static int size()
Definition: SymMat.h:159
AddOp::Type Add
Definition: SymMat.h:221
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:362
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:215
TPosTrans & updPositionalTranspose()
Definition: SymMat.h:594
SymMat< M, P > Type
Definition: SymMat.h:231
SymMat< M, EComplex, RS > TComplex
Definition: SymMat.h:130
SymMat< M, typename CNT< E >::template Result< P >::Dvd, 1 > Dvd
Definition: SymMat.h:194
bool isNaN() const
Return true if any element of this SymMat contains a NaN anywhere.
Definition: SymMat.h:719
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:209
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition: Mat.h:51
CNT< ScalarNormSq >::TSqrt norm() const
Definition: SymMat.h:554
K::TComplex TComplex
Definition: CompositeNumericalTypes.h:143
TNormalize normalize() const
There is no conventional meaning for normalize() applied to a matrix.
Definition: SymMat.h:567
SymMat< M, EAbs, 1 > TAbs
Definition: SymMat.h:144
K::Number Number
Definition: CompositeNumericalTypes.h:162
bool isInf() const
Return true if any element of this Vec contains a +Infinity or -Infinity somewhere but no element con...
Definition: Vec.h:872
TWithoutNegator & updCastAwayNegatorIfAny()
Definition: SymMat.h:613
TStandard standardize() const
Definition: SymMat.h:183
SymMat< M, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: SymMat.h:623
EltResult< E2 >::Dvd elementwiseDivide(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:532
MulOpNonConforming::Type MulNon
Definition: SymMat.h:210
const TPosTrans & positionalTranspose() const
Definition: SymMat.h:592
SymMat< M, EReal, RS *CNT< E >::RealStrideFactor > TReal
Definition: SymMat.h:127
ScalarNormSq scalarNormSqr() const
Definition: SymMat.h:165
K::TSqHermT TSqHermT
Definition: CompositeNumericalTypes.h:146
ScalarNormSq normSqr() const
Definition: SymMat.h:552
static int nrow()
Definition: SymMat.h:160
const TImag & imag() const
Definition: SymMat.h:601
SymMat(const ENeg &e)
Definition: SymMat.h:338
static const TReal & real(const T &t)
Definition: CompositeNumericalTypes.h:203
K::THerm THerm
Definition: CompositeNumericalTypes.h:144
Result< SymMat< M, E2, RS2 > >::Mul conformingMultiply(const SymMat< M, E2, RS2 > &s) const
Definition: SymMat.h:513
SymMat< M, ENormalize, 1 > TNormalize
Definition: SymMat.h:147
static int ncol()
Definition: SymMat.h:161
Vec< M, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: Vec.h:684
TUpper & updUpper()
Definition: SymMat.h:813
Vec & scalarDivideEqFromLeft(const EE &ee)
Definition: Vec.h:742
TRow colSum() const
Returns a row vector (Row) containing the column sums of this matrix.
Definition: SymMat.h:830
Vec< M, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: Vec.h:690
const E & getEltDiag(int i) const
Definition: SymMat.h:818
static const Vec & getAs(const ELT *p)
Recast an ordinary C++ array E[] to a const Vec<M,E,S>; assumes compatible length, stride, and packing.
Definition: Vec.h:849
SymMat & operator+=(const EE &e)
Definition: SymMat.h:678
SymMat & operator/=(const EE &e)
Definition: SymMat.h:681
K::TAbs TAbs
Definition: CompositeNumericalTypes.h:155
SymMat< M, ENeg, RS > TNeg
Definition: SymMat.h:123