1#ifndef SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
2#define SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
100template <
int M,
int N,
class ELT,
int CS,
int RS>
class Mat {
200 static int size() {
return M*N; }
203 static int nrow() {
return M; }
206 static int ncol() {
return N; }
260 typedef typename MulOp::Type
Mul;
265 typedef typename MulOpNonConforming::Type
MulNon;
270 typedef typename DvdOp::Type
Dvd;
275 typedef typename AddOp::Type
Add;
280 typedef typename SubOp::Type
Sub;
303 for (
int j=0;
j<N; ++
j)
310 for (
int j=0;
j<N; ++
j)
321 for (
int j = 0;
j < M; ++
j)
322 for (
int i =
j+1;
i < M; ++
i) {
323 (*this)(
i,
j) =
src.getEltLower(
i,
j);
324 (*this)(
j,
i) =
src.getEltUpper(
j,
i);
332 template <
int CSS,
int RSS>
334 for (
int j=0;
j<N; ++
j)
343 template <
int CSS,
int RSS>
345 for (
int j=0;
j<N; ++
j)
356 template <
class EE,
int CSS,
int RSS>
358 {
for (
int j=0;
j<N;++
j) (*
this)(
j) =
mm(
j);}
364 {
for (
int j=0;
j<N;++
j) (*
this)(
j) =
E(0);
diag()=e; }
371 {
for (
int j=0;
j<N;++
j) (*
this)(
j) =
E(0);
diag()=e; }
385 typename = std::enable_if_t<
386 (M*N==
sizeof...(Elements)) &&
387 (std::is_convertible_v<Elements&&, const E&> && ...)
394 std::make_integer_sequence<
int,
sizeof...(Elements)>{}
404 {
assert(M==3);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2; }
407 {
assert(M==4);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;(*this)[3]=
r3; }
410 {
assert(M==5);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;
411 (*this)[3]=
r3;(*this)[4]=
r4; }
414 {
assert(M==6);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;
415 (*this)[3]=
r3;(*this)[4]=
r4;(*this)[5]=
r5; }
422 template <
class EE,
int SS>
424 {
assert(M==3);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2; }
425 template <
class EE,
int SS>
428 {
assert(M==4);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;(*this)[3]=
r3; }
429 template <
class EE,
int SS>
432 {
assert(M==5);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;
433 (*this)[3]=
r3;(*this)[4]=
r4; }
434 template <
class EE,
int SS>
437 {
assert(M==6);(*this)[0]=
r0;(*this)[1]=
r1;(*this)[2]=
r2;
438 (*this)[3]=
r3;(*this)[4]=
r4;(*this)[5]=
r5; }
447 {
assert(N==3);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2; }
450 {
assert(N==4);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;(*this)(3)=
r3; }
453 {
assert(N==5);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;
454 (*this)(3)=
r3;(*this)(4)=
r4; }
457 {
assert(N==6);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;
458 (*this)(3)=
r3;(*this)(4)=
r4;(*this)(5)=
r5; }
465 template <
class EE,
int SS>
467 {
assert(N==3);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2; }
468 template <
class EE,
int SS>
471 {
assert(N==4);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;(*this)(3)=
r3; }
472 template <
class EE,
int SS>
475 {
assert(N==5);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;
476 (*this)(3)=
r3;(*this)(4)=
r4; }
477 template <
class EE,
int SS>
480 {
assert(N==6);(*this)(0)=
r0;(*this)(1)=
r1;(*this)(2)=
r2;
481 (*this)(3)=
r3;(*this)(4)=
r4;(*this)(5)=
r5; }
485 template <
class EE>
explicit Mat(
const EE* p)
486 {
assert(p);
for(
int i=0;
i<M;++
i) (*
this)[
i]=&p[
i*N]; }
492 for (
int j=0;
j<N; ++
j) (*
this)(
j) =
mm(
j);
497 assert(p);
for(
int i=0;
i<M;++
i) (*
this)[
i]=&p[
i*N];
502 template <
class EE,
int CSS,
int RSS>
Mat&
504 for (
int j=0;
j<N; ++
j) (*
this)(
j) +=
mm(
j);
507 template <
class EE,
int CSS,
int RSS>
Mat&
509 for (
int j=0;
j<N; ++
j) (*
this)(
j) -= -(
mm(
j));
513 template <
class EE,
int CSS,
int RSS>
Mat&
515 for (
int j=0;
j<N; ++
j) (*
this)(
j) -=
mm(
j);
518 template <
class EE,
int CSS,
int RSS>
Mat&
520 for (
int j=0;
j<N; ++
j) (*
this)(
j) += -(
mm(
j));
526 template <
class EE,
int CSS,
int RSS>
Mat&
529 for (
int j=0;
j<N; ++
j)
530 for (
int i=0;
i<M; ++
i)
539 template <
class E2,
int CS2,
int RS2>
543 for (
int j=0;
j<N;++
j) result(
j) = (*this)(
j) +
r(
j);
547 template <
class E2,
int CS2,
int RS2>
551 for (
int j=0;
j<N;++
j) result(
j) = (*this)(
j) -
r(
j);
555 template <
class E2,
int CS2,
int RS2>
562 template <
class E2,
int CS2,
int RS2>
566 for (
int j=0;
j<N;++
j)
572 template <
class E2,
int CS2,
int RS2>
576 for (
int j=0;
j<N;++
j)
583 template <
class E2,
int RS2>
587 return sy.conformingAdd(*
this);
590 template <
class E2,
int RS2>
594 return sy.conformingSubtractFromLeft(*
this);
597 template <
class E2,
int RS2>
601 return sy.conformingSubtract(*
this);
605 template <
int N2,
class E2,
int CS2,
int RS2>
609 for (
int j=0;
j<
N2;++
j)
610 for (
int i=0;
i<M;++
i)
611 result(
i,
j) = (*this)[
i].conformingMultiply(m(
j));
615 template <
int M2,
class E2,
int CS2,
int RS2>
622 template <
int M2,
class E2,
int CS2,
int RS2>
628 template <
int M2,
class E2,
int CS2,
int RS2>
666 for (
int j=0;
j<N; ++
j)
689 {
return *
reinterpret_cast<const TPosTrans*
>(
this); }
691 {
return *
reinterpret_cast<TPosTrans*
>(
this); }
710 return *
reinterpret_cast<const TImag*
>(p+
offs);
715 return *
reinterpret_cast<TImag*
>(p+
offs);
723 return *
reinterpret_cast<const TRow*
>(&d[
i*
RS]);
727 return *
reinterpret_cast<TRow*
>(&d[
i*
RS]);
732 return *
reinterpret_cast<const TCol*
>(&d[
j*
CS]);
736 return *
reinterpret_cast<TCol*
>(&d[
j*
CS]);
858 for (
int j=0;
j<N; ++
j)
863 for (
int j=0;
j<N; ++
j)
870 template <
int MM,
int NN>
struct SubMat {
874 template <
int MM,
int NN>
880 template <
int MM,
int NN>
886 template <
int MM,
int NN>
898 for (
int r=0,
nxt=0;
r<M-1; ++
r, ++
nxt) {
910 for (
int c=0,
nxt=0;
c<N-1; ++
c, ++
nxt) {
937 template <
class EE,
int SS>
948 template <
class EE,
int SS>
962 template <
class ER,
int SR,
class EC,
int SC>
979 template <
class EE,
int SS>
996 template <
class EE,
int SS>
1015 template <
class ER,
int SR,
class EC,
int SC>
1046 for (
int j=0;
j<N; ++
j)
1056 for (
int j=0;
j<N; ++
j) {
1068 for (
int j=0;
j<N; ++
j)
1080 template <
class E2,
int CS2,
int RS2>
1082 for (
int j=0;
j < N; ++
j)
1091 template <
class E2,
int CS2,
int RS2>
1106 for (
int i=0;
i<M; ++
i)
1107 for (
int j=0;
j<N; ++
j) {
1128 if (M != N)
return false;
1129 for (
int j=0;
j<M; ++
j)
1130 for (
int i=
j;
i<M; ++
i)
1143 if (M != N)
return false;
1144 for (
int j=0;
j<M; ++
j)
1145 for (
int i=
j;
i<M; ++
i)
1154 for (
int j = 0;
j < N; ++
j)
1165 for (
int i = 0;
i < M; ++
i)
1173 std::stringstream
stream;
1189 int rIx(
int k)
const {
1190 const int row =
k / N;
1191 const int col =
k % N;
1198 ((d[rIx(
Idx)] = std::get<Idx>(
els)) , ...);
1207template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1211 ::AddOp::perform(l,r);
1214template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1218 ::SubOp::perform(l,r);
1222template <
int M,
int N,
class EL,
int CSL,
int RSL,
int P,
class ER,
int CSR,
int RSR>
inline
1226 ::MulOp::perform(l,r);
1231template <
int M,
int N,
class EL,
int CSL,
int RSL,
int MM,
int NN,
class ER,
int CSR,
int RSR>
inline
1235 ::MulOpNonConforming::perform(l,r);
1238template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1240 for (
int j=0; j<N; ++j)
1241 if (l(j) != r(j))
return false;
1244template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1257template <
int M,
int N,
class E,
int CS,
int RS>
inline
1261template <
int M,
int N,
class E,
int CS,
int RS>
inline
1265template <
int M,
int N,
class E,
int CS,
int RS>
inline
1269template <
int M,
int N,
class E,
int CS,
int RS>
inline
1274template <
int M,
int N,
class E,
int CS,
int RS>
inline
1277template <
int M,
int N,
class E,
int CS,
int RS>
inline
1284template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1288template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1293template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1296template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1301template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1304template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1316template <
int M,
int N,
class E,
int CS,
int RS>
inline
1321template <
int M,
int N,
class E,
int CS,
int RS>
inline
1322typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1324{
return l * r.
invert(); }
1326template <
int M,
int N,
class E,
int CS,
int RS>
inline
1331template <
int M,
int N,
class E,
int CS,
int RS>
inline
1332typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1334{
return l * r.
invert(); }
1337template <
int M,
int N,
class E,
int CS,
int RS>
inline
1342template <
int M,
int N,
class E,
int CS,
int RS>
inline
1343typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1351template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1355template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1356typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1358 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::DvdOp::perform(l,r); }
1361template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1364template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1365typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1369template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1372template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1373typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1384template <
int M,
int N,
class E,
int CS,
int RS>
inline
1388template <
int M,
int N,
class E,
int CS,
int RS>
inline
1392template <
int M,
int N,
class E,
int CS,
int RS>
inline
1396template <
int M,
int N,
class E,
int CS,
int RS>
inline
1401template <
int M,
int N,
class E,
int CS,
int RS>
inline
1404template <
int M,
int N,
class E,
int CS,
int RS>
inline
1411template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1415template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1420template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1423template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1428template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1431template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1438template <
int M,
int N,
class E,
int CS,
int RS>
inline
1442template <
int M,
int N,
class E,
int CS,
int RS>
inline
1443typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Sub
1447template <
int M,
int N,
class E,
int CS,
int RS>
inline
1451template <
int M,
int N,
class E,
int CS,
int RS>
inline
1452typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Sub
1457template <
int M,
int N,
class E,
int CS,
int RS>
inline
1460template <
int M,
int N,
class E,
int CS,
int RS>
inline
1461typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Sub
1468template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1472template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1473typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1475 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::SubOp::perform(l,r); }
1478template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1481template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1482typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1486template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1489template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1490typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Sub
1495template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1496std::basic_ostream<CHAR,TRAITS>&
1497operator<<(std::basic_ostream<CHAR,TRAITS>& o,
const Mat<M,N,E,CS,RS>& m) {
1498 for (
int i=0;i<M;++i) {
1499 o << std::endl <<
"[";
1500 for (
int j=0;j<N;++j)
1501 o << (j>0?
",":
"") << m(i,j);
1504 if (M) o << std::endl;
1508template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1509std::basic_istream<CHAR,TRAITS>&
#define SimTK_INDEXCHECK(ix, ub, where)
Definition ExceptionMacros.h:145
Mandatory first inclusion for any Simbody source or header file.
#define SimTK_NODISCARD
Warn if a caller fails to capture or use the return value of a method.
Definition SimTKcommon/include/SimTKcommon/internal/common.h:315
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition CompositeNumericalTypes.h:136
K::ULessScalar ULessScalar
Definition CompositeNumericalTypes.h:161
static double getDefaultTolerance()
Definition CompositeNumericalTypes.h:269
K::ScalarNormSq ScalarNormSq
Definition CompositeNumericalTypes.h:166
K::StdNumber StdNumber
Definition CompositeNumericalTypes.h:163
static TSqrt sqrt(const K &t)
Definition CompositeNumericalTypes.h:239
K::TSqHermT TSqHermT
Definition CompositeNumericalTypes.h:146
K::TSqrt TSqrt
Definition CompositeNumericalTypes.h:154
K::TInvert TInvert
Definition CompositeNumericalTypes.h:157
K::TNormalize TNormalize
Definition CompositeNumericalTypes.h:158
K::TWithoutNegator TWithoutNegator
Definition CompositeNumericalTypes.h:140
K::TReal TReal
Definition CompositeNumericalTypes.h:141
K::THerm THerm
Definition CompositeNumericalTypes.h:144
K::TPosTrans TPosTrans
Definition CompositeNumericalTypes.h:145
K::TNeg TNeg
Definition CompositeNumericalTypes.h:139
K::TStandard TStandard
Definition CompositeNumericalTypes.h:156
K::TComplex TComplex
Definition CompositeNumericalTypes.h:143
K::TSqTHerm TSqTHerm
Definition CompositeNumericalTypes.h:147
K::TImag TImag
Definition CompositeNumericalTypes.h:142
K::Precision Precision
Definition CompositeNumericalTypes.h:164
K::Scalar Scalar
Definition CompositeNumericalTypes.h:160
K::TAbs TAbs
Definition CompositeNumericalTypes.h:155
K::Number Number
Definition CompositeNumericalTypes.h:162
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition Mat.h:100
Mat()
Default construction initializes to NaN when debugging but is left uninitialized otherwise to ensure ...
Definition Mat.h:290
CNT< E >::TImag EImag
Definition Mat.h:106
SubMat< MM, NN >::Type & updSubMat(int i, int j)
Definition Mat.h:881
Mat< M, N, E2, CS2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const Mat< M, N, E2, CS2, RS2 > &l) const
Definition Mat.h:557
Mat(const SymMat< M, ELT > &src)
Explicit construction of a Mat from a SymMat (symmetric/Hermitian matrix).
Definition Mat.h:319
const E & elt(int i, int j) const
Definition Mat.h:739
void setSubMat(int i, int j, const typename SubMat< MM, NN >::Type &value)
Definition Mat.h:887
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &sy) const
Definition Mat.h:592
TAppendRowCol appendRowCol(const Row< N+1, ER, SR > &row, const Vec< M+1, EC, SC > &col) const
Return a matrix one row and one column larger than this one by adding a row to the bottom and a colum...
Definition Mat.h:963
Result< Mat< N, N2, E2, CS2, RS2 > >::Mul conformingMultiply(const Mat< N, N2, E2, CS2, RS2 > &m) const
Definition Mat.h:607
Mat< M, N, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition Mat.h:793
EltResult< E2 >::Dvd elementwiseDivide(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition Mat.h:574
Mat & scalarTimesEqFromLeft(const EE &ee)
Definition Mat.h:849
TWithoutNegator & updCastAwayNegatorIfAny()
Definition Mat.h:719
Mat< M-1, N-1, E, M-1, 1 > TDropRowCol
Definition Mat.h:185
Mat< M, N+1, E, M, 1 > TAppendCol
Definition Mat.h:187
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3)
Definition Mat.h:448
static int nrow()
Return the number of rows in this Mat, echoing the value supplied for the template parameter M.
Definition Mat.h:203
const TReal & real() const
Definition Mat.h:697
Mat(const TCol &r0)
Definition Mat.h:442
const TCol & operator()(int j) const
Definition Mat.h:636
CNT< E >::TComplex EComplex
Definition Mat.h:107
CNT< E >::TStandard EStandard
Definition Mat.h:115
EStdNumber StdNumber
Definition Mat.h:193
Mat< M, N, ENeg, CS, RS > TNeg
Definition Mat.h:154
void setToNaN()
Definition Mat.h:857
E & elt(int i, int j)
Definition Mat.h:744
TInvert invert() const
Definition SmallMatrixMixed.h:1004
THerm TransposeType
Definition Mat.h:197
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4)
Definition Mat.h:408
Mat & scalarDivideEqFromLeft(const EE &ee)
Definition Mat.h:854
static double getDefaultTolerance()
For approximate comparisons, the default tolerance to use for a matrix is its shortest dimension time...
Definition Mat.h:1076
TRow & operator[](int i)
Definition Mat.h:635
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2, const Row< N, EE, SS > &r3, const Row< N, EE, SS > &r4)
Definition Mat.h:430
Mat< M, N, EAbs, M, 1 > TAbs
Definition Mat.h:172
TRow sum() const
This is an alternate name for colSum(); behaves like the Matlab function of the same name.
Definition Mat.h:1160
bool isNumericallyEqual(const Mat< M, N, E2, CS2, RS2 > &m, double tol) const
Test whether this matrix is numerically equal to some other matrix with the same shape,...
Definition Mat.h:1081
CNT< E >::TWithoutNegator EWithoutNegator
Definition Mat.h:104
CNT< E >::TSqHermT ESqHermT
Definition Mat.h:110
Mat< M, N, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition Mat.h:778
Mat< M, N, EStandard, M, 1 > TStandard
Definition Mat.h:173
Result< Mat< M2, N, E2, CS2, RS2 > >::Dvd conformingDivide(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition Mat.h:624
TDropRow dropRow(int i) const
Return a matrix one row smaller than this one by dropping row i.
Definition Mat.h:895
CNT< E >::Number ENumber
Definition Mat.h:121
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1)
Definition Mat.h:420
Mat(Elements &&... elementsRowByRow)
Definition Mat.h:390
const THerm & transpose() const
Definition Mat.h:685
ScalarNormSq normSqr() const
Definition Mat.h:643
SymMat< N, ESqHermT > TSqHermT
Definition Mat.h:177
Mat(const Row< N, EE, SS > &r0)
Definition Mat.h:418
Mat & scalarMinusEqFromLeft(const EE &ee)
Definition Mat.h:844
EScalar Scalar
Definition Mat.h:190
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2, const Vec< M, EE, SS > &r3)
Definition Mat.h:469
TStandard standardize() const
Definition Mat.h:237
EScalarNormSq ScalarNormSq
Definition Mat.h:195
TReal & real()
Definition Mat.h:698
static const Mat & getAs(const ELT *p)
Definition Mat.h:1034
EStandard trace() const
Definition Mat.h:762
CNT< E >::TAbs EAbs
Definition Mat.h:114
ScalarNormSq scalarNormSqr() const
Scalar norm square is the sum of squares of all the scalars that comprise the value of this Mat.
Definition Mat.h:213
CNT< ScalarNormSq >::TSqrt norm() const
Definition Mat.h:645
Mat< M, N, typename CNT< E >::template Result< EE >::Sub > scalarSubtract(const EE &e) const
Definition Mat.h:809
Mat & operator-=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition Mat.h:519
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4, const TCol &r5)
Definition Mat.h:455
Mat< M, N, E, M, 1 > TPacked
Definition Mat.h:182
Vec< M, E, RS > TCol
Definition Mat.h:166
EltResult< E2 >::Mul elementwiseMultiply(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition Mat.h:564
const TRow & operator[](int i) const
Definition Mat.h:634
Mat(const Vec< M, EE, SS > &r0)
Definition Mat.h:461
TAbs abs() const
Elementwise absolute value; that is, the return value has the same dimensions as this Mat but with ea...
Definition Mat.h:231
TPosTrans & updPositionalTranspose()
Definition Mat.h:690
const E & operator()(int i, int j) const
Definition Mat.h:639
CNT< E >::ScalarNormSq EScalarNormSq
Definition Mat.h:124
Mat< N, M, E, RS, CS > TPosTrans
Definition Mat.h:163
ELT E
Definition Mat.h:102
static int ncol()
Return the number of columns in this Mat, echoing the value supplied for the template parameter N.
Definition Mat.h:206
Mat< M2, N, E2, CS2, RS2 >::template Result< Mat >::Dvd conformingDivideFromLeft(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition Mat.h:630
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2)
Definition Mat.h:423
bool isExactlySymmetric() const
A Matrix is symmetric (actually Hermitian) if it is square and each element (i,j) is the Hermitian (c...
Definition Mat.h:1142
CNT< E >::Precision EPrecision
Definition Mat.h:123
Mat< M, N, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft(const EE &e) const
Definition Mat.h:816
CNT< E >::TPosTrans EPosTrans
Definition Mat.h:109
Mat & scalarPlusEq(const EE &ee)
Definition Mat.h:838
CNT< E >::TNormalize ENormalize
Definition Mat.h:117
const TPosTrans & positionalTranspose() const
Definition Mat.h:688
SymMat< M, ESqTHerm > TSqTHerm
Definition Mat.h:178
Mat & scalarDivideEq(const EE &ee)
Definition Mat.h:852
Row< N, E, CS > TRow
Definition Mat.h:165
Mat< M, N, E, CS, RS > T
Definition Mat.h:153
Mat(const TRow &r0, const TRow &r1, const TRow &r2)
Definition Mat.h:403
Mat< M, N, ENormalize, M, 1 > TNormalize
Definition Mat.h:175
Mat & operator+=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition Mat.h:503
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4)
Definition Mat.h:451
const TRow & row(int i) const
Definition Mat.h:721
TRow colSum() const
Returns a row vector (Row) containing the column sums of this matrix.
Definition Mat.h:1152
TCol & col(int j)
Definition Mat.h:734
Mat(const Mat &src)
Copy constructor copies only the elements that are present and does not touch any unused memory space...
Definition Mat.h:302
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4, const TRow &r5)
Definition Mat.h:412
Mat & scalarEq(const EE &ee)
Definition Mat.h:833
Result< Mat< M, N, E2, CS2, RS2 > >::Add conformingAdd(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition Mat.h:541
TRow & row(int i)
Definition Mat.h:725
TNeg & updNegate()
Definition Mat.h:683
CNT< E >::TSqrt ESqrt
Definition Mat.h:113
Mat< M, N, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition Mat.h:772
Mat & operator*=(const Mat< N, N, EE, CSS, RSS > &mm)
Definition Mat.h:527
ENumber Number
Definition Mat.h:192
TNormalize normalize() const
Definition Mat.h:660
static int size()
Return the total number of elements M*N contained in this Mat.
Definition Mat.h:200
TAppendCol insertCol(int j, const Vec< M, EE, SS > &col) const
Return a matrix one column larger than this one by inserting a column before column j.
Definition Mat.h:997
Mat & operator=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition Mat.h:491
Mat(const Mat< M, N, E, CSS, RSS > &src)
This provides an implicit conversion from a Mat of the same dimensions and element type but with diff...
Definition Mat.h:333
CNT< E >::TInvert EInvert
Definition Mat.h:116
const TNeg & negate() const
Definition Mat.h:682
void set(int i, int j, const ELT &value)
Variant of indexing operator that's scripting friendly to set entry (i, j)
Definition Mat.h:1180
E & operator()(int i, int j)
Definition Mat.h:640
Mat & operator-=(const EE &e)
Definition Mat.h:827
Mat< M+1, N, E, M+1, 1 > TAppendRow
Definition Mat.h:186
CNT< E >::Scalar EScalar
Definition Mat.h:119
bool isFinite() const
Return true if no element contains an Infinity or a NaN.
Definition Mat.h:1067
Vec< MinDim, E, RS+CS > TDiag
Definition Mat.h:167
Mat< M2, M, E2, CS2, RS2 >::template Result< Mat >::Mul conformingMultiplyFromLeft(const Mat< M2, M, E2, CS2, RS2 > &m) const
Definition Mat.h:617
TSqrt sqrt() const
Elementwise square root; that is, the return value has the same dimensions as this Mat but with each ...
Definition Mat.h:222
CNT< E >::TReal EReal
Definition Mat.h:105
TDiag & diag()
This non-const version of diag() is an alternate name for updDiag() available for historical reasons.
Definition Mat.h:760
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 eac...
Definition Mat.h:1103
@ NPackedElements
Definition Mat.h:135
@ ImagOffset
Definition Mat.h:138
@ ArgDepth
Definition Mat.h:141
@ NCols
Definition Mat.h:130
@ RowSpacing
Definition Mat.h:133
@ RealStrideFactor
Definition Mat.h:139
@ NActualElements
Definition Mat.h:136
@ IsPrecision
Definition Mat.h:148
@ IsScalar
Definition Mat.h:144
@ IsNumber
Definition Mat.h:146
@ ColSpacing
Definition Mat.h:134
@ SignInterpretation
Definition Mat.h:149
@ IsStdNumber
Definition Mat.h:147
@ NActualScalars
Definition Mat.h:137
@ NRows
Definition Mat.h:129
@ MinDim
Definition Mat.h:131
@ IsULessScalar
Definition Mat.h:145
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &sy) const
Definition Mat.h:585
const SubMat< MM, NN >::Type & getSubMat(int i, int j) const
Definition Mat.h:875
TNeg & operator-()
Definition Mat.h:678
Mat(const EE *p)
Definition Mat.h:485
static Mat & updAs(ELT *p)
Definition Mat.h:1035
TAppendRowCol insertRowCol(int i, int j, const Row< N+1, ER, SR > &row, const Vec< M+1, EC, SC > &col) const
Return a matrix one row and one column larger than this one by inserting a row before row i and a col...
Definition Mat.h:1016
TAppendRow appendRow(const Row< N, EE, SS > &row) const
Return a matrix one row larger than this one by adding a row to the end.
Definition Mat.h:938
static Mat< M, N, ELT, M, 1 > getNaN()
Definition Mat.h:1038
Mat< M-1, N, E, M-1, 1 > TDropRow
Definition Mat.h:183
THerm & updTranspose()
Definition Mat.h:686
Mat(const E &e)
Explicit construction from a single element e of this Mat's element type E sets all the main diagonal...
Definition Mat.h:363
const ELT & get(int i, int j) const
Variant of indexing operator that's scripting friendly to get entry (i, j)
Definition Mat.h:1178
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:753
CNT< E >::TNeg ENeg
Definition Mat.h:103
Mat(int i)
Explicit construction from an int value means we convert the int into an object of this Mat's element...
Definition Mat.h:379
Mat< N, M, EInvert, N, 1 > TInvert
Definition Mat.h:174
CNT< E >::THerm EHerm
Definition Mat.h:108
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2, const Row< N, EE, SS > &r3)
Definition Mat.h:426
const TCol & col(int j) const
Definition Mat.h:730
std::string toString() const
toString() returns a string representation of the Mat.
Definition Mat.h:1172
bool isNaN() const
Return true if any element of this Mat contains a NaN anywhere.
Definition Mat.h:1045
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:1127
TCol rowSum() const
Returns a column vector (Vec) containing the row sums of this matrix.
Definition Mat.h:1163
TAppendCol appendCol(const Vec< M, EE, SS > &col) const
Return a matrix one column larger than this one by adding a column to the end.
Definition Mat.h:949
EULessScalar ULessScalar
Definition Mat.h:191
Mat & operator+=(const EE &e)
Definition Mat.h:826
bool isInf() const
Return true if any element of this Mat contains a +Inf or -Inf somewhere but no element contains a Na...
Definition Mat.h:1054
Mat< M, N-1, E, M, 1 > TDropCol
Definition Mat.h:184
Mat & operator*=(const EE &e)
Definition Mat.h:828
Mat< M, N, EReal, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TReal
Definition Mat.h:158
Mat< M, N, ESqrt, M, 1 > TSqrt
Definition Mat.h:171
SymMat< M, E2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const SymMat< M, E2, RS2 > &sy) const
Definition Mat.h:599
const THerm & operator~() const
Definition Mat.h:679
Mat & operator/=(const EE &e)
Definition Mat.h:829
TDropCol dropCol(int j) const
Return a matrix one column smaller than this one by dropping column j.
Definition Mat.h:907
TAppendRow insertRow(int i, const Row< N, EE, SS > &row) const
Return a matrix one row larger than this one by inserting a row before row i.
Definition Mat.h:980
const TWithoutNegator & castAwayNegatorIfAny() const
Definition Mat.h:718
Mat< M+1, N+1, E, M+1, 1 > TAppendRowCol
Definition Mat.h:188
Mat< M, N, EComplex, CS, RS > TComplex
Definition Mat.h:161
CNT< E >::ULessScalar EULessScalar
Definition Mat.h:120
TDiag & updDiag()
Select main diagonal (of largest leading square if rectangular) and return it as a writable view (as ...
Definition Mat.h:757
Mat(const TCol &r0, const TCol &r1, const TCol &r2)
Definition Mat.h:446
Result< Mat< M, N, E2, CS2, RS2 > >::Sub conformingSubtract(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition Mat.h:549
const Mat & operator+() const
Definition Mat.h:676
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2, const Vec< M, EE, SS > &r3, const Vec< M, EE, SS > &r4)
Definition Mat.h:473
Mat(const Mat< M, N, EE, CSS, RSS > &mm)
Explicit construction of a Mat from a source Mat of the same dimensions and an assignment-compatible ...
Definition Mat.h:357
Mat(const TRow &r0)
Definition Mat.h:399
Mat & operator-=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition Mat.h:514
Mat(const TRow &r0, const TRow &r1)
Definition Mat.h:401
Mat(const Mat< M, N, ENeg, CSS, RSS > &src)
This provides an implicit conversion from a Mat of the same dimensions and negated element type,...
Definition Mat.h:344
CNT< E >::StdNumber EStdNumber
Definition Mat.h:122
Mat(const ENeg &e)
Explicit construction from a single element e whose type is negator<E> (abbreviated ENeg here) where ...
Definition Mat.h:370
Mat< M, N, EImag, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TImag
Definition Mat.h:160
Mat(const TCol &r0, const TCol &r1)
Definition Mat.h:444
TImag & imag()
Definition Mat.h:712
const TImag & imag() const
Definition Mat.h:707
Mat & scalarTimesEq(const EE &ee)
Definition Mat.h:847
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2, const Vec< M, EE, SS > &r3, const Vec< M, EE, SS > &r4, const Vec< M, EE, SS > &r5)
Definition Mat.h:478
Mat & scalarMinusEq(const EE &ee)
Definition Mat.h:841
Mat< M, N, EWithoutNegator, CS, RS > TWithoutNegator
Definition Mat.h:155
Mat & operator=(const Mat &src)
Copy assignment copies only the elements that are present and does not touch any unused memory space ...
Definition Mat.h:309
Mat & operator+=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition Mat.h:508
void setToZero()
Definition Mat.h:862
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1)
Definition Mat.h:463
Mat< M, N, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition Mat.h:801
Mat< N, M, EHerm, RS, CS > THerm
Definition Mat.h:162
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2)
Definition Mat.h:466
EPrecision Precision
Definition Mat.h:194
E TElement
Definition Mat.h:164
TCol & operator()(int j)
Definition Mat.h:637
TDropRowCol dropRowCol(int i, int j) const
Return a matrix one row and one column smaller than this one by dropping row i and column j.
Definition Mat.h:920
Mat & operator=(const EE *p)
Definition Mat.h:496
const TNeg & operator-() const
Definition Mat.h:677
Mat< M, N, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition Mat.h:787
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3)
Definition Mat.h:405
THerm & operator~()
Definition Mat.h:680
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2, const Row< N, EE, SS > &r3, const Row< N, EE, SS > &r4, const Row< N, EE, SS > &r5)
Definition Mat.h:435
CNT< E >::TSqTHerm ESqTHerm
Definition Mat.h:111
bool isNumericallyEqual(const Mat< M, N, E2, CS2, RS2 > &m) const
Test whether this matrix is numerically equal to some other matrix with the same shape,...
Definition Mat.h:1092
This is a fixed-length row vector designed for no-overhead inline computation.
Definition Row.h:132
EStandard sum() const
Definition Row.h:254
This is a small, fixed-size symmetric or Hermitian matrix designed for no-overhead inline computation...
Definition SymMat.h:87
This is a fixed-length column vector designed for no-overhead inline computation.
Definition Vec.h:186
Vec & scalarMinusEq(const EE &ee)
Definition Vec.h:837
Vec & scalarPlusEq(const EE &ee)
Definition Vec.h:835
Vec< M, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition Vec.h:802
Vec & scalarEq(const EE &ee)
Definition Vec.h:833
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:368
SimTK::conjugate<R> should be instantiated only for float, double.
Definition conjugate.h:178
negator<N>, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition negator.h:75
NTraits< N >::StdNumber StdNumber
Definition negator.h:107
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition Assembler.h:37
Matrix_< E > operator*(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition BigMatrix.h:605
Matrix_< E > operator/(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition BigMatrix.h:613
std::basic_istream< CHAR, TRAITS > & operator>>(std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c)
Definition conjugate.h:505
@ MAX_RESOLVED_DEPTH
Definition CompositeNumericalTypes.h:120
Matrix_< typename CNT< E1 >::template Result< E2 >::Add > operator+(const MatrixBase< E1 > &l, const MatrixBase< E2 > &r)
Definition BigMatrix.h:568
std::ostream & operator<<(std::ostream &o, const ContactForce &f)
Definition CompliantContactSubsystem.h:387
Matrix_< typename CNT< E1 >::template Result< E2 >::Sub > operator-(const MatrixBase< E1 > &l, const MatrixBase< E2 > &r)
Definition BigMatrix.h:584
bool operator==(const PhiMatrix &p1, const PhiMatrix &p2)
Definition SpatialAlgebra.h:791
bool operator!=(const L &left, const R &right)
Definition SimTKcommon/include/SimTKcommon/internal/common.h:664
Mat< M, N, typename CNT< E >::template Result< P >::Add, M, 1 > Add
Definition Mat.h:250
Mat< M, N, typename CNT< E >::template Result< P >::Sub, M, 1 > Sub
Definition Mat.h:251
Mat< M, N, typename CNT< E >::template Result< P >::Mul, M, 1 > Mul
Definition Mat.h:248
Mat< M, N, typename CNT< E >::template Result< P >::Dvd, M, 1 > Dvd
Definition Mat.h:249
MulCNTs< M, N, ArgDepth, Mat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > MulOp
Definition Mat.h:259
DvdOp::Type Dvd
Definition Mat.h:270
MulOpNonConforming::Type MulNon
Definition Mat.h:265
SubCNTs< M, N, ArgDepth, Mat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > SubOp
Definition Mat.h:279
MulOp::Type Mul
Definition Mat.h:260
MulCNTsNonConforming< M, N, ArgDepth, Mat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > MulOpNonConforming
Definition Mat.h:264
SubOp::Type Sub
Definition Mat.h:280
AddOp::Type Add
Definition Mat.h:275
DvdCNTs< M, N, ArgDepth, Mat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > DvdOp
Definition Mat.h:269
AddCNTs< M, N, ArgDepth, Mat, ColSpacing, RowSpacing, CNT< P >::NRows, CNT< P >::NCols, CNT< P >::ArgDepth, P, CNT< P >::ColSpacing, CNT< P >::RowSpacing > AddOp
Definition Mat.h:274
Mat< MM, NN, ELT, CS, RS > Type
Definition Mat.h:871
Mat< M, N, P > Type
Definition Mat.h:285