1 #ifndef SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
2 #define SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
97 template <
int M,
int N,
class ELT,
int CS,
int RS>
class Mat {
99 typedef typename CNT<E>::TNeg ENeg;
100 typedef typename CNT<E>::TWithoutNegator EWithoutNegator;
101 typedef typename CNT<E>::TReal EReal;
102 typedef typename CNT<E>::TImag EImag;
103 typedef typename CNT<E>::TComplex EComplex;
104 typedef typename CNT<E>::THerm EHerm;
105 typedef typename CNT<E>::TPosTrans EPosTrans;
106 typedef typename CNT<E>::TSqHermT ESqHermT;
107 typedef typename CNT<E>::TSqTHerm ESqTHerm;
109 typedef typename CNT<E>::TSqrt ESqrt;
110 typedef typename CNT<E>::TAbs EAbs;
111 typedef typename CNT<E>::TStandard EStandard;
112 typedef typename CNT<E>::TInvert EInvert;
113 typedef typename CNT<E>::TNormalize ENormalize;
115 typedef typename CNT<E>::Scalar EScalar;
116 typedef typename CNT<E>::ULessScalar EULessScalar;
117 typedef typename CNT<E>::Number ENumber;
118 typedef typename CNT<E>::StdNumber EStdNumber;
119 typedef typename CNT<E>::Precision EPrecision;
120 typedef typename CNT<E>::ScalarNormSq EScalarNormSq;
128 MaxDim = N > M ? N : M,
195 static int size() {
return M*N; }
198 static int nrow() {
return M; }
201 static int ncol() {
return N; }
210 for(
int j=0;j<N;++j) sum += CNT<TCol>::scalarNormSqr((*this)(j));
219 for(
int j=0;j<N;++j) msqrt(j) = (*this)(j).
sqrt();
228 for(
int j=0;j<N;++j) mabs(j) = (*this)(j).
abs();
234 for(
int j=0;j<N;++j) mstd(j) = (*this)(j).
standardize();
255 typedef typename MulOp::Type
Mul;
258 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
260 typedef typename MulOpNonConforming::Type
MulNon;
263 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
265 typedef typename DvdOp::Type
Dvd;
268 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
270 typedef typename AddOp::Type
Add;
273 CNT<P>::NRows, CNT<P>::NCols, CNT<P>::ArgDepth,
275 typedef typename SubOp::Type
Sub;
298 for (
int j=0; j<N; ++j)
305 for (
int j=0; j<N; ++j)
316 for (
int j = 0; j < M; ++j)
317 for (
int i = j+1; i < M; ++i) {
327 template <
int CSS,
int RSS>
329 for (
int j=0; j<N; ++j)
338 template <
int CSS,
int RSS>
340 for (
int j=0; j<N; ++j)
351 template <
class EE,
int CSS,
int RSS>
353 {
for (
int j=0;j<N;++j) (*
this)(j) = mm(j);}
359 {
for (
int j=0;j<N;++j) (*
this)(j) = E(0);
diag()=e; }
365 explicit Mat(
const ENeg& e)
366 {
for (
int j=0;j<N;++j) (*
this)(j) = E(0);
diag()=e; }
378 Mat(
const E& e0,
const E& e1)
379 {assert(M*N==2);d[rIx(0)]=e0;d[rIx(1)]=e1;}
380 Mat(
const E& e0,
const E& e1,
const E& e2)
381 {assert(M*N==3);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;}
382 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3)
383 {assert(M*N==4);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;}
384 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4)
385 {assert(M*N==5);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;}
386 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
388 {assert(M*N==6);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
390 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
391 const E& e5,
const E& e6)
392 {assert(M*N==7);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
393 d[rIx(5)]=e5;d[rIx(6)]=e6;}
394 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
395 const E& e5,
const E& e6,
const E& e7)
396 {assert(M*N==8);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
397 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;}
398 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
399 const E& e5,
const E& e6,
const E& e7,
const E& e8)
400 {assert(M*N==9);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
401 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;}
402 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
403 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9)
404 {assert(M*N==10);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
405 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;}
406 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
407 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
409 {assert(M*N==11);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
410 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;}
411 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
412 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
413 const E& e10,
const E& e11)
414 {assert(M*N==12);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
415 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
417 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
418 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
419 const E& e10,
const E& e11,
const E& e12)
420 {assert(M*N==13);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
421 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
422 d[rIx(11)]=e11;d[rIx(12)]=e12;}
423 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
424 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
425 const E& e10,
const E& e11,
const E& e12,
const E& e13)
426 {assert(M*N==14);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
427 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
428 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;}
429 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
430 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
431 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14)
432 {assert(M*N==15);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
433 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
434 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;d[rIx(14)]=e14;}
435 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
436 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
437 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14,
439 {assert(M*N==16);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
440 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
441 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;d[rIx(14)]=e14;d[rIx(15)]=e15;}
444 explicit Mat(
const TRow& r0)
445 { assert(M==1); (*this)[0]=r0; }
446 Mat(
const TRow& r0,
const TRow& r1)
447 { assert(M==2);(*this)[0]=r0;(*this)[1]=r1; }
448 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2)
449 { assert(M==3);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2; }
450 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
452 { assert(M==4);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;(*this)[3]=r3; }
453 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
454 const TRow& r3,
const TRow& r4)
455 { assert(M==5);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
456 (*this)[3]=r3;(*this)[4]=r4; }
457 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
458 const TRow& r3,
const TRow& r4,
const TRow& r5)
459 { assert(M==6);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
460 (*this)[3]=r3;(*this)[4]=r4;(*this)[5]=r5; }
464 { assert(M==1); (*this)[0]=r0; }
466 { assert(M==2);(*this)[0]=r0;(*this)[1]=r1; }
467 template <
class EE,
int SS>
469 { assert(M==3);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2; }
470 template <
class EE,
int SS>
473 { assert(M==4);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;(*this)[3]=r3; }
474 template <
class EE,
int SS>
477 { assert(M==5);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
478 (*this)[3]=r3;(*this)[4]=r4; }
479 template <
class EE,
int SS>
482 { assert(M==6);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
483 (*this)[3]=r3;(*this)[4]=r4;(*this)[5]=r5; }
487 explicit Mat(
const TCol& r0)
488 { assert(N==1); (*this)(0)=r0; }
489 Mat(
const TCol& r0,
const TCol& r1)
490 { assert(N==2);(*this)(0)=r0;(*this)(1)=r1; }
491 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2)
492 { assert(N==3);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2; }
493 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
495 { assert(N==4);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;(*this)(3)=r3; }
496 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
497 const TCol& r3,
const TCol& r4)
498 { assert(N==5);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
499 (*this)(3)=r3;(*this)(4)=r4; }
500 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
501 const TCol& r3,
const TCol& r4,
const TCol& r5)
502 { assert(N==6);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
503 (*this)(3)=r3;(*this)(4)=r4;(*this)(5)=r5; }
507 { assert(N==1); (*this)(0)=r0; }
509 { assert(N==2);(*this)(0)=r0;(*this)(1)=r1; }
510 template <
class EE,
int SS>
512 { assert(N==3);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2; }
513 template <
class EE,
int SS>
516 { assert(N==4);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;(*this)(3)=r3; }
517 template <
class EE,
int SS>
520 { assert(N==5);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
521 (*this)(3)=r3;(*this)(4)=r4; }
522 template <
class EE,
int SS>
525 { assert(N==6);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
526 (*this)(3)=r3;(*this)(4)=r4;(*this)(5)=r5; }
530 template <
class EE>
explicit Mat(
const EE* p)
531 { assert(p);
for(
int i=0;i<M;++i) (*
this)[i]=&p[i*N]; }
537 for (
int j=0; j<N; ++j) (*
this)(j) = mm(j);
542 assert(p);
for(
int i=0;i<M;++i) (*
this)[i]=&p[i*N];
547 template <
class EE,
int CSS,
int RSS>
Mat&
549 for (
int j=0; j<N; ++j) (*
this)(j) += mm(j);
552 template <
class EE,
int CSS,
int RSS>
Mat&
554 for (
int j=0; j<N; ++j) (*
this)(j) -= -(mm(j));
558 template <
class EE,
int CSS,
int RSS>
Mat&
560 for (
int j=0; j<N; ++j) (*
this)(j) -= mm(j);
563 template <
class EE,
int CSS,
int RSS>
Mat&
565 for (
int j=0; j<N; ++j) (*
this)(j) += -(mm(j));
571 template <
class EE,
int CSS,
int RSS>
Mat&
574 for (
int j=0; j<N; ++j)
575 for (
int i=0; i<M; ++i)
576 (*
this)(i,j) = t[i] * mm(j);
584 template <
class E2,
int CS2,
int RS2>
585 typename Result<Mat<M,N,E2,CS2,RS2> >::Add
587 typename Result<Mat<M,N,E2,CS2,RS2> >::Add result;
588 for (
int j=0;j<N;++j) result(j) = (*this)(j) + r(j);
592 template <
class E2,
int CS2,
int RS2>
593 typename Result<Mat<M,N,E2,CS2,RS2> >::Sub
595 typename Result<Mat<M,N,E2,CS2,RS2> >::Sub result;
596 for (
int j=0;j<N;++j) result(j) = (*this)(j) - r(j);
600 template <
class E2,
int CS2,
int RS2>
603 return l.conformingSubtract(*
this);
607 template <
class E2,
int CS2,
int RS2>
608 typename EltResult<E2>::Mul
610 typename EltResult<E2>::Mul result;
611 for (
int j=0;j<N;++j)
617 template <
class E2,
int CS2,
int RS2>
618 typename EltResult<E2>::Dvd
620 typename EltResult<E2>::Dvd result;
621 for (
int j=0;j<N;++j)
628 template <
class E2,
int RS2>
629 typename Result<SymMat<M,E2,RS2> >::Add
635 template <
class E2,
int RS2>
636 typename Result<SymMat<M,E2,RS2> >::Sub
639 return sy.conformingSubtractFromLeft(*
this);
642 template <
class E2,
int RS2>
650 template <
int N2,
class E2,
int CS2,
int RS2>
651 typename Result<Mat<N,N2,E2,CS2,RS2> >::Mul
653 typename Result<Mat<N,N2,E2,CS2,RS2> >::Mul result;
654 for (
int j=0;j<N2;++j)
655 for (
int i=0;i<M;++i)
656 result(i,j) = (*this)[i].conformingMultiply(m(j));
660 template <
int M2,
class E2,
int CS2,
int RS2>
663 return m.conformingMultiply(*
this);
667 template <
int M2,
class E2,
int CS2,
int RS2>
668 typename Result<Mat<M2,N,E2,CS2,RS2> >::Dvd
673 template <
int M2,
class E2,
int CS2,
int RS2>
676 return m.conformingMultiply((*this).invert());
709 TNormalize elementwiseNormalized;
711 for (
int j=0; j<N; ++j)
712 elementwiseNormalized(j) = (*this)(j).
normalize();
713 return elementwiseNormalized;
727 const TNeg&
negate()
const {
return *
reinterpret_cast<const TNeg*
>(
this); }
728 TNeg&
updNegate() {
return *
reinterpret_cast<TNeg*
>(
this); }
730 const THerm&
transpose()
const {
return *
reinterpret_cast<const THerm*
>(
this); }
734 {
return *
reinterpret_cast<const TPosTrans*
>(
this); }
736 {
return *
reinterpret_cast<TPosTrans*
>(
this); }
754 const Precision* p =
reinterpret_cast<const Precision*
>(
this);
755 return *
reinterpret_cast<const TImag*
>(p+offs);
759 Precision* p =
reinterpret_cast<Precision*
>(
this);
760 return *
reinterpret_cast<TImag*
>(p+offs);
766 const TRow&
row(
int i)
const {
768 return *
reinterpret_cast<const TRow*
>(&d[i*RS]);
772 return *
reinterpret_cast<TRow*
>(&d[i*RS]);
775 const TCol&
col(
int j)
const {
777 return *
reinterpret_cast<const TCol*
>(&d[j*CS]);
781 return *
reinterpret_cast<TCol*
>(&d[j*CS]);
784 const E&
elt(
int i,
int j)
const {
798 const TDiag&
diag()
const {
return *
reinterpret_cast<const TDiag*
>(d); }
802 TDiag&
updDiag() {
return *
reinterpret_cast<TDiag*
>(d); }
805 TDiag&
diag() {
return *
reinterpret_cast<TDiag*
>(d); }
834 for (
int j=0; j<N; ++j) result(j) = (*this)(j).
scalarDivide(e);
879 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarEq(EE(0));
893 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarTimesEq(ee);
return *
this; }
898 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarDivideEq(ee);
return *
this; }
903 for (
int j=0; j<N; ++j)
908 for (
int j=0; j<N; ++j)
915 template <
int MM,
int NN>
struct SubMat {
919 template <
int MM,
int NN>
920 const typename SubMat<MM,NN>::Type&
getSubMat(
int i,
int j)
const {
921 assert(0 <= i && i + MM <= M);
922 assert(0 <= j && j + NN <= N);
925 template <
int MM,
int NN>
927 assert(0 <= i && i + MM <= M);
928 assert(0 <= j && j + NN <= N);
931 template <
int MM,
int NN>
932 void setSubMat(
int i,
int j,
const typename SubMat<MM,NN>::Type& value) {
933 assert(0 <= i && i + MM <= M);
934 assert(0 <= j && j + NN <= N);
941 assert(0 <= i && i < M);
943 for (
int r=0, nxt=0; r<M-1; ++r, ++nxt) {
945 out[r] = (*this)[nxt];
953 assert(0 <= j && j < N);
955 for (
int c=0, nxt=0; c<N-1; ++c, ++nxt) {
957 out(c) = (*this)(nxt);
966 assert(0 <= i && i < M);
967 assert(0 <= j && j < N);
969 for (
int c=0, nxtc=0; c<N-1; ++c, ++nxtc) {
971 for (
int r=0, nxtr=0; r<M-1; ++r, ++nxtr) {
973 out(r,c) = (*this)(nxtr,nxtc);
982 template <
class EE,
int SS>
985 out.template updSubMat<M,N>(0,0) = (*
this);
993 template <
class EE,
int SS>
996 out.template updSubMat<M,N>(0,0) = (*
this);
1007 template <
class ER,
int SR,
class EC,
int SC>
1012 out.template updSubMat<M,N>(0,0) = (*
this);
1013 out[M].template updSubRow<N>(0) =
1014 row.template getSubRow<N>(0);
1024 template <
class EE,
int SS>
1026 assert(0 <= i && i <= M);
1029 for (
int r=0, nxt=0; r<M; ++r, ++nxt) {
1030 if (nxt==i) out[nxt++] =
row;
1031 out[nxt] = (*this)[r];
1041 template <
class EE,
int SS>
1043 assert(0 <= j && j <= N);
1046 for (
int c=0, nxt=0; c<N; ++c, ++nxt) {
1047 if (nxt==j) out(nxt++) =
col;
1048 out(nxt) = (*this)(c);
1060 template <
class ER,
int SR,
class EC,
int SC>
1063 assert(0 <= i && i <= M);
1064 assert(0 <= j && j <= N);
1066 for (
int c=0, nxtc=0; c<N; ++c, ++nxtc) {
1067 if (nxtc==j) ++nxtc;
1068 for (
int r=0, nxtr=0; r<M; ++r, ++nxtr) {
1069 if (nxtr==i) ++nxtr;
1070 out(nxtr,nxtc) = (*this)(r,c);
1079 static const Mat&
getAs(
const ELT* p) {
return *
reinterpret_cast<const Mat*
>(p);}
1091 for (
int j=0; j<N; ++j)
1100 bool seenInf =
false;
1101 for (
int j=0; j<N; ++j) {
1113 for (
int j=0; j<N; ++j)
1125 template <
class E2,
int CS2,
int RS2>
1127 for (
int j=0; j < N; ++j)
1136 template <
class E2,
int CS2,
int RS2>
1151 for (
int i=0; i<M; ++i)
1152 for (
int j=0; j<N; ++j) {
1173 if (M != N)
return false;
1174 for (
int j=0; j<M; ++j)
1175 for (
int i=j; i<M; ++i)
1188 if (M != N)
return false;
1189 for (
int j=0; j<M; ++j)
1190 for (
int i=j; i<M; ++i)
1199 for (
int j = 0; j < N; ++j)
1210 for (
int i = 0; i < M; ++i)
1218 std::stringstream stream;
1220 return stream.str();
1223 const ELT&
get(
int i,
int j)
const {
return elt(i,j); }
1225 void set(
int i,
int j,
const ELT& value) {
elt(i,j)=value; }
1234 int rIx(
int k)
const {
1235 const int row = k / N;
1236 const int col = k % N;
1237 return row*RS + col*CS;
1246 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1247 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<M,N,ER,CSR,RSR> >::Add
1250 ::AddOp::perform(l,r);
1253 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1254 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<M,N,ER,CSR,RSR> >::Sub
1257 ::SubOp::perform(l,r);
1261 template <
int M,
int N,
class EL,
int CSL,
int RSL,
int P,
class ER,
int CSR,
int RSR>
inline
1262 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<N,P,ER,CSR,RSR> >::Mul
1265 ::MulOp::perform(l,r);
1270 template <
int M,
int N,
class EL,
int CSL,
int RSL,
int MM,
int NN,
class ER,
int CSR,
int RSR>
inline
1271 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<MM,NN,ER,CSR,RSR> >::MulNon
1274 ::MulOpNonConforming::perform(l,r);
1277 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1279 for (
int j=0; j<N; ++j)
1280 if (l(j) != r(j))
return false;
1283 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1296 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1297 typename Mat<M,N,E,CS,RS>::template Result<float>::Mul
1300 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1301 typename Mat<M,N,E,CS,RS>::template Result<float>::Mul
1304 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1305 typename Mat<M,N,E,CS,RS>::template Result<double>::Mul
1308 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1309 typename Mat<M,N,E,CS,RS>::template Result<double>::Mul
1312 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1313 typename Mat<M,N,E,CS,RS>::template Result<long double>::Mul
1316 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1317 typename Mat<M,N,E,CS,RS>::template Result<long double>::Mul
1321 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1322 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Mul
1324 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1325 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Mul
1331 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1332 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1335 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1336 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1340 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1341 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1343 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1344 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1348 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1349 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Mul
1351 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1352 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Mul
1363 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1364 typename Mat<M,N,E,CS,RS>::template Result<float>::Dvd
1368 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1369 typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1371 {
return l * r.invert(); }
1373 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1374 typename Mat<M,N,E,CS,RS>::template Result<double>::Dvd
1378 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1379 typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1381 {
return l * r.invert(); }
1383 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1384 typename Mat<M,N,E,CS,RS>::template Result<long double>::Dvd
1388 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1389 typename CNT<long double>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1391 {
return l * r.invert(); }
1394 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1395 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Dvd
1399 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1400 typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1408 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1409 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Dvd
1412 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1413 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1415 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::DvdOp::perform(l,r); }
1418 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1419 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Dvd
1421 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1422 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1426 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1427 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Dvd
1429 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1430 typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1441 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1442 typename Mat<M,N,E,CS,RS>::template Result<float>::Add
1445 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1446 typename Mat<M,N,E,CS,RS>::template Result<float>::Add
1449 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1450 typename Mat<M,N,E,CS,RS>::template Result<double>::Add
1453 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1454 typename Mat<M,N,E,CS,RS>::template Result<double>::Add
1457 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1458 typename Mat<M,N,E,CS,RS>::template Result<long double>::Add
1461 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1462 typename Mat<M,N,E,CS,RS>::template Result<long double>::Add
1466 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1467 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Add
1469 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1470 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Add
1476 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1477 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1480 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1481 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1485 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1486 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1488 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1489 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1493 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1494 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Add
1496 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1497 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Add
1503 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1504 typename Mat<M,N,E,CS,RS>::template Result<float>::Sub
1507 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1508 typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Sub
1512 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1513 typename Mat<M,N,E,CS,RS>::template Result<double>::Sub
1516 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1517 typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Sub
1521 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1522 typename Mat<M,N,E,CS,RS>::template Result<long double>::Sub
1525 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1526 typename CNT<long double>::template Result<Mat<M,N,E,CS,RS> >::Sub
1531 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1532 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Sub
1534 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1535 typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Sub
1542 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1543 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Sub
1546 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1547 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1549 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::SubOp::perform(l,r); }
1552 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1553 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Sub
1555 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1556 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1560 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1561 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Sub
1563 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1564 typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Sub
1569 template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1570 std::basic_ostream<CHAR,TRAITS>&
1572 for (
int i=0;i<M;++i) {
1573 o << std::endl <<
"[";
1574 for (
int j=0;j<N;++j)
1575 o << (j>0?
",":
"") << m(i,j);
1578 if (M) o << std::endl;
1582 template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1583 std::basic_istream<CHAR,TRAITS>&
1593 #endif //SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
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:983
Mat(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)
Definition: Mat.h:417
Matrix_< E > operator/(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:613
Mat & operator+=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition: Mat.h:553
Mat< M, N+1, E, M, 1 > TAppendCol
Definition: Mat.h:182
Vec< MinDim, E, RS+CS > TDiag
Definition: Mat.h:162
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1)
Definition: Mat.h:465
TDiag & diag()
This non-const version of diag() is an alternate name for updDiag() available for historical reasons...
Definition: Mat.h:805
EScalarNormSq ScalarNormSq
Definition: Mat.h:190
TReal & real()
Definition: Mat.h:743
EStdNumber StdNumber
Definition: Mat.h:188
Mat & scalarTimesEq(const EE &ee)
Definition: Mat.h:892
Mat & scalarMinusEqFromLeft(const EE &ee)
Definition: Mat.h:889
static int ncol()
Return the number of columns in this Mat, echoing the value supplied for the template paramter N...
Definition: Mat.h:201
void setToZero()
Definition: Mat.h:907
const E & elt(int i, int j) const
Definition: Mat.h:784
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:254
const Mat & operator+() const
Definition: Mat.h:721
TInvert invert() const
Definition: SmallMatrixMixed.h:1003
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:1025
Mat()
Default construction initializes to NaN when debugging but is left uninitialized otherwise to ensure ...
Definition: Mat.h:285
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1)
Definition: Mat.h:508
TPosTrans & updPositionalTranspose()
Definition: Mat.h:735
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2)
Definition: Mat.h:511
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3)
Definition: Mat.h:493
ENumber Number
Definition: Mat.h:187
E TElement
Definition: Mat.h:159
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
Elementwise absolute value; that is, the return value has the same dimensions as this Mat but with ea...
Definition: Mat.h:226
E & elt(int i, int j)
Definition: Mat.h:789
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:630
Result< Mat< N, N2, E2, CS2, RS2 > >::Mul conformingMultiply(const Mat< N, N2, E2, CS2, RS2 > &m) const
Definition: Mat.h:652
Vec & scalarEq(const EE &ee)
Definition: Vec.h:781
const TDiag & diag() const
Definition: SymMat.h:822
const TRow & operator[](int i) const
Definition: Mat.h:679
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:352
Mat(const TCol &r0, const TCol &r1, const TCol &r2)
Definition: Mat.h:491
const E & operator()(int i, int j) const
Definition: Mat.h:684
Mat< M+1, N, E, M+1, 1 > TAppendRow
Definition: Mat.h:181
Mat< N, M, EInvert, N, 1 > TInvert
Definition: Mat.h:169
E & operator()(int i, int j)
Definition: Mat.h:685
DvdOp::Type Dvd
Definition: Mat.h:265
MulOp::Type Mul
Definition: Mat.h:255
Mat(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)
Definition: Mat.h:398
Mat(const TCol &r0, const TCol &r1)
Definition: Mat.h:489
Mat(const TRow &r0)
Definition: Mat.h:444
SubMat< MM, NN >::Type & updSubMat(int i, int j)
Definition: Mat.h:926
Mat< M, N-1, E, M, 1 > TDropCol
Definition: Mat.h:179
EScalar Scalar
Definition: Mat.h:185
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:994
Vec & scalarPlusEq(const EE &ee)
Definition: Vec.h:783
const TWithoutNegator & castAwayNegatorIfAny() const
Definition: Mat.h:763
SymMat< N, ESqHermT > TSqHermT
Definition: Mat.h:172
Mat< M, N, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: Mat.h:838
EULessScalar ULessScalar
Definition: Mat.h:186
Mat< M+1, N+1, E, M+1, 1 > TAppendRowCol
Definition: Mat.h:183
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:269
Mat< M, N, EImag, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TImag
Definition: Mat.h:155
Mat< M, N, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: Mat.h:846
Mat & operator+=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:548
Mat< M, N, E, M, 1 > TPacked
Definition: Mat.h:177
TRow sum() const
This is an alternate name for colSum(); behaves like the Matlab function of the same name...
Definition: Mat.h:1205
const THerm & transpose() const
Definition: Mat.h:730
TNeg & updNegate()
Definition: Mat.h:728
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
Mat(const TCol &r0)
Definition: Mat.h:487
std::basic_istream< CHAR, TRAITS > & operator>>(std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c)
Definition: conjugate.h:800
std::string toString() const
toString() returns a string representation of the Mat.
Definition: Mat.h:1217
Mat(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: Mat.h:429
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
Mat & operator=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:536
Mat & operator-=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:559
Vec< M, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: Vec.h:750
static double getDefaultTolerance()
Definition: CompositeNumericalTypes.h:269
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4)
Definition: Mat.h:453
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6, const E &e7)
Definition: Mat.h:394
const TImag & imag() const
Definition: Mat.h:752
EStandard sum() const
Definition: Row.h:254
Mat(const TRow &r0, const TRow &r1)
Definition: Mat.h:446
bool operator==(const PhiMatrix &p1, const PhiMatrix &p2)
Definition: SpatialAlgebra.h:774
Mat & operator-=(const EE &e)
Definition: Mat.h:872
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:965
Mat(const Vec< M, EE, SS > &r0)
Definition: Mat.h:506
Mat< M, N, P > Type
Definition: Mat.h:280
TStandard standardize() const
Definition: Mat.h:232
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:374
const TPosTrans & positionalTranspose() const
Definition: Mat.h:733
Mat< M, N, EStandard, M, 1 > TStandard
Definition: Mat.h:168
const TNeg & negate() const
Definition: Mat.h:727
Result< Mat< M2, N, E2, CS2, RS2 > >::Dvd conformingDivide(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition: Mat.h:669
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4)
Definition: Mat.h:384
Mat< M, N, E2, CS2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const Mat< M, N, E2, CS2, RS2 > &l) const
Definition: Mat.h:602
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
TNormalize normalize() const
Definition: Mat.h:705
void setSubMat(int i, int j, const typename SubMat< MM, NN >::Type &value)
Definition: Mat.h:932
Mat & operator/=(const EE &e)
Definition: Mat.h:874
THerm TransposeType
Definition: Mat.h:192
Mat< M2, N, E2, CS2, RS2 >::template Result< Mat >::Dvd conformingDivideFromLeft(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition: Mat.h:675
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:304
Mat< N, M, E, RS, CS > TPosTrans
Definition: Mat.h:158
Mat< M, N, EReal, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TReal
Definition: Mat.h:153
bool isNaN() const
Return true if any element of this Mat contains a NaN anywhere.
Definition: Mat.h:1090
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:1008
THerm & operator~()
Definition: Mat.h:725
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
static Mat< M, N, ELT, M, 1 > getNaN()
Definition: Mat.h:1083
const TCol & operator()(int j) const
Definition: Mat.h:681
static int nrow()
Return the number of rows in this Mat, echoing the value supplied for the template paramter M...
Definition: Mat.h:198
Matrix_< E > operator*(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:605
Mat< M, N, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: Mat.h:823
Mat & operator=(const EE *p)
Definition: Mat.h:541
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:514
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
Definition: Mat.h:386
Mat & scalarPlusEq(const EE &ee)
Definition: Mat.h:883
TRow & operator[](int i)
Definition: Mat.h:680
Mat(const E &e0, const E &e1, const E &e2, const E &e3)
Definition: Mat.h:382
static Mat & updAs(ELT *p)
Definition: Mat.h:1080
Mat & operator*=(const Mat< N, N, EE, CSS, RSS > &mm)
Definition: Mat.h:572
const EHerm & getEltUpper(int i, int j) const
Definition: SymMat.h:842
Mat< MM, NN, ELT, CS, RS > Type
Definition: Mat.h:916
Mat< M, N, typename CNT< E >::template Result< P >::Sub, M, 1 > Sub
Definition: Mat.h:246
EltResult< E2 >::Dvd elementwiseDivide(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:619
Mat & scalarDivideEq(const EE &ee)
Definition: Mat.h:897
Mat & operator+=(const EE &e)
Definition: Mat.h:871
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:1187
Mat & operator*=(const EE &e)
Definition: Mat.h:873
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
Mat & scalarDivideEqFromLeft(const EE &ee)
Definition: Mat.h:899
const TNeg & operator-() const
Definition: Mat.h:722
SubOp::Type Sub
Definition: Mat.h:275
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4)
Definition: Mat.h:496
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
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, using a specified tolerance.
Definition: Mat.h:1126
Mat(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)
Definition: Mat.h:435
Mat< M, N, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: Mat.h:832
CNT< ScalarNormSq >::TSqrt norm() const
Definition: Mat.h:690
Mat & scalarMinusEq(const EE &ee)
Definition: Mat.h:886
Vec< M, E, RS > TCol
Definition: Mat.h:161
Mat< M, N, EAbs, M, 1 > TAbs
Definition: Mat.h:167
TDiag & updDiag()
Select main diagonal (of largest leading square if rectangular) and return it as a writable view (as ...
Definition: Mat.h:802
Mat< M, N, typename CNT< E >::template Result< EE >::Sub > scalarSubtract(const EE &e) const
Definition: Mat.h:854
Mat< M, N, ESqrt, M, 1 > TSqrt
Definition: Mat.h:166
const TReal & real() const
Definition: Mat.h:742
const SubMat< MM, NN >::Type & getSubMat(int i, int j) const
Definition: Mat.h:920
TSqrt sqrt() const
Elementwise square root; that is, the return value has the same dimensions as this Mat but with each ...
Definition: Mat.h:217
TNeg & operator-()
Definition: Mat.h:723
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:637
static int size()
Return the total number of elements M*N contained in this Mat.
Definition: Mat.h:195
negator, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
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
Mat< M-1, N-1, E, M-1, 1 > TDropRowCol
Definition: Mat.h:180
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:480
SymMat< M, ESqTHerm > TSqTHerm
Definition: Mat.h:173
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:518
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:358
TDropRow dropRow(int i) const
Return a matrix one row smaller than this one by dropping row i.
Definition: Mat.h:940
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:339
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:475
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:259
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2)
Definition: Mat.h:468
Mat< M, N, EWithoutNegator, CS, RS > TWithoutNegator
Definition: Mat.h:150
SymMat< M, E2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:644
bool operator!=(const conjugate< R > &a, const float &b)
Definition: conjugate.h:859
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 c...
Definition: Mat.h:1061
NTraits< N >::StdNumber StdNumber
Definition: negator.h:107
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:264
Mat< M, N, EComplex, CS, RS > TComplex
Definition: Mat.h:156
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
Mat(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)
Definition: Mat.h:406
Mat(const E &e0, const E &e1)
Definition: Mat.h:378
ScalarNormSq normSqr() const
Definition: Mat.h:688
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5, const E &e6)
Definition: Mat.h:390
TCol & operator()(int j)
Definition: Mat.h:682
Mat(const Mat &src)
Copy constructor copies only the elements that are present and does not touch any unused memory space...
Definition: Mat.h:297
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
TCol & col(int j)
Definition: Mat.h:779
Mat< M, N, ENormalize, M, 1 > TNormalize
Definition: Mat.h:170
Vec & scalarMinusEq(const EE &ee)
Definition: Vec.h:785
Mandatory first inclusion for any Simbody source or header file.
Mat< M2, M, E2, CS2, RS2 >::template Result< Mat >::Mul conformingMultiplyFromLeft(const Mat< M2, M, E2, CS2, RS2 > &m) const
Definition: Mat.h:662
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3)
Definition: Mat.h:450
Mat(const SymMat< M, ELT > &src)
Explicit construction of a Mat from a SymMat (symmetric/Hermitian matrix).
Definition: Mat.h:314
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:523
const THerm & operator~() const
Definition: Mat.h:724
Mat< M, N, typename CNT< E >::template Result< P >::Mul, M, 1 > Mul
Definition: Mat.h:243
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
MulOpNonConforming::Type MulNon
Definition: Mat.h:260
EPrecision Precision
Definition: Mat.h:189
This is a fixed-length column vector designed for no-overhead inline computation. ...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:589
TCol rowSum() const
Returns a column vector (Vec) containing the row sums of this matrix.
Definition: Mat.h:1208
Mat< M, N, E, CS, RS > T
Definition: Mat.h:148
const E & getEltLower(int i, int j) const
Definition: SymMat.h:838
TImag & imag()
Definition: Mat.h:757
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:208
TWithoutNegator & updCastAwayNegatorIfAny()
Definition: Mat.h:764
static const Mat & getAs(const ELT *p)
Definition: Mat.h:1079
EStandard trace() const
Definition: Mat.h:807
Mat< M, N, typename CNT< E >::template Result< P >::Dvd, M, 1 > Dvd
Definition: Mat.h:244
Result< Mat< M, N, E2, CS2, RS2 > >::Sub conformingSubtract(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:594
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:512
Result< Mat< M, N, E2, CS2, RS2 > >::Add conformingAdd(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:586
void setToNaN()
Definition: Mat.h:902
SimTK::conjugate should be instantiated only for float, double, long double.
Definition: String.h:45
Mat(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)
Definition: Mat.h:411
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4, const TCol &r5)
Definition: Mat.h:500
Mat(const TRow &r0, const TRow &r1, const TRow &r2)
Definition: Mat.h:448
Mat< N, M, EHerm, RS, CS > THerm
Definition: Mat.h:157
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, using a default tolerance which is the looser of the default tolerances of the two objects being compared.
Definition: Mat.h:1137
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:471
Mat< M, N, typename CNT< E >::template Result< P >::Add, M, 1 > Add
Definition: Mat.h:245
EltResult< E2 >::Mul elementwiseMultiply(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:609
TRow colSum() const
Returns a row vector (Row) containing the column sums of this matrix.
Definition: Mat.h:1197
AddOp::Type Add
Definition: Mat.h:270
const TRow & row(int i) const
Definition: Mat.h:766
Mat< M-1, N, E, M-1, 1 > TDropRow
Definition: Mat.h:178
Mat(const E &e0, const E &e1, const E &e2)
Definition: Mat.h:380
Mat & operator-=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition: Mat.h:564
bool isFinite() const
Return true if no element contains an Infinity or a NaN.
Definition: Mat.h:1112
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:274
Mat(const Row< N, EE, SS > &r0)
Definition: Mat.h:463
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:519
TRow & row(int i)
Definition: Mat.h:770
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:1225
Mat(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)
Definition: Mat.h:423
Mat< M, N, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: Mat.h:817
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:1042
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:328
Mat(const EE *p)
Definition: Mat.h:530
Mat< M, N, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft(const EE &e) const
Definition: Mat.h:861
Mat(const ENeg &e)
Explicit construction from a single element e whose type is negator (abbreviated ENeg here) where ...
Definition: Mat.h:365
Mat< M, N, ENeg, CS, RS > TNeg
Definition: Mat.h:149
Mat & scalarEq(const EE &ee)
Definition: Mat.h:878
Mat & scalarTimesEqFromLeft(const EE &ee)
Definition: Mat.h:894
Mat(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: Mat.h:402
const TCol & col(int j) const
Definition: Mat.h:775
TDropCol dropCol(int j) const
Return a matrix one column smaller than this one by dropping column j.
Definition: Mat.h:952
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4, const TRow &r5)
Definition: Mat.h:457
Row< N, E, CS > TRow
Definition: Mat.h:160
THerm & updTranspose()
Definition: Mat.h:731
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:1099