1 #ifndef SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
2 #define SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
51 template <
int M,
int N,
class ELT,
int CS,
int RS>
class Mat {
82 MaxDim = N > M ? N : M,
149 static int size() {
return M*N; }
152 static int nrow() {
return M; }
155 static int ncol() {
return N; }
164 for(
int j=0;j<N;++j) sum += CNT<TCol>::scalarNormSqr((*this)(j));
173 for(
int j=0;j<N;++j) msqrt(j) = (*this)(j).
sqrt();
182 for(
int j=0;j<N;++j) mabs(j) = (*this)(j).
abs();
188 for(
int j=0;j<N;++j) mstd(j) = (*this)(j).
standardize();
209 typedef typename MulOp::Type
Mul;
214 typedef typename MulOpNonConforming::Type
MulNon;
219 typedef typename DvdOp::Type
Dvd;
224 typedef typename AddOp::Type
Add;
229 typedef typename SubOp::Type
Sub;
252 for (
int j=0; j<N; ++j)
259 for (
int j=0; j<N; ++j)
270 for (
int j = 0; j < M; ++j)
271 for (
int i = j+1; i < M; ++i) {
281 template <
int CSS,
int RSS>
283 for (
int j=0; j<N; ++j)
292 template <
int CSS,
int RSS>
294 for (
int j=0; j<N; ++j)
305 template <
class EE,
int CSS,
int RSS>
307 {
for (
int j=0;j<N;++j) (*
this)(j) = mm(j);}
313 {
for (
int j=0;j<N;++j) (*
this)(j) = E(0);
diag()=e; }
319 explicit Mat(
const ENeg& e)
320 {
for (
int j=0;j<N;++j) (*
this)(j) = E(0);
diag()=e; }
332 Mat(
const E& e0,
const E& e1)
333 {assert(M*N==2);d[rIx(0)]=e0;d[rIx(1)]=e1;}
334 Mat(
const E& e0,
const E& e1,
const E& e2)
335 {assert(M*N==3);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;}
336 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3)
337 {assert(M*N==4);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;}
338 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4)
339 {assert(M*N==5);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;}
340 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
342 {assert(M*N==6);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
344 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
345 const E& e5,
const E& e6)
346 {assert(M*N==7);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
347 d[rIx(5)]=e5;d[rIx(6)]=e6;}
348 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
349 const E& e5,
const E& e6,
const E& e7)
350 {assert(M*N==8);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
351 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;}
352 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
353 const E& e5,
const E& e6,
const E& e7,
const E& e8)
354 {assert(M*N==9);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
355 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;}
356 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
357 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9)
358 {assert(M*N==10);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
359 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;}
360 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
361 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
363 {assert(M*N==11);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
364 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;}
365 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
366 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
367 const E& e10,
const E& e11)
368 {assert(M*N==12);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
369 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
371 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
372 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
373 const E& e10,
const E& e11,
const E& e12)
374 {assert(M*N==13);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
375 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
376 d[rIx(11)]=e11;d[rIx(12)]=e12;}
377 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
378 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
379 const E& e10,
const E& e11,
const E& e12,
const E& e13)
380 {assert(M*N==14);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
381 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
382 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;}
383 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
384 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
385 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14)
386 {assert(M*N==15);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
387 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
388 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;d[rIx(14)]=e14;}
389 Mat(
const E& e0,
const E& e1,
const E& e2,
const E& e3,
const E& e4,
390 const E& e5,
const E& e6,
const E& e7,
const E& e8,
const E& e9,
391 const E& e10,
const E& e11,
const E& e12,
const E& e13,
const E& e14,
393 {assert(M*N==16);d[rIx(0)]=e0;d[rIx(1)]=e1;d[rIx(2)]=e2;d[rIx(3)]=e3;d[rIx(4)]=e4;
394 d[rIx(5)]=e5;d[rIx(6)]=e6;d[rIx(7)]=e7;d[rIx(8)]=e8;d[rIx(9)]=e9;d[rIx(10)]=e10;
395 d[rIx(11)]=e11;d[rIx(12)]=e12;d[rIx(13)]=e13;d[rIx(14)]=e14;d[rIx(15)]=e15;}
398 explicit Mat(
const TRow& r0)
399 { assert(M==1); (*this)[0]=r0; }
400 Mat(
const TRow& r0,
const TRow& r1)
401 { assert(M==2);(*this)[0]=r0;(*this)[1]=r1; }
402 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2)
403 { assert(M==3);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2; }
404 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
406 { assert(M==4);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;(*this)[3]=r3; }
407 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
408 const TRow& r3,
const TRow& r4)
409 { assert(M==5);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
410 (*this)[3]=r3;(*this)[4]=r4; }
411 Mat(
const TRow& r0,
const TRow& r1,
const TRow& r2,
412 const TRow& r3,
const TRow& r4,
const TRow& r5)
413 { assert(M==6);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
414 (*this)[3]=r3;(*this)[4]=r4;(*this)[5]=r5; }
418 { assert(M==1); (*this)[0]=r0; }
420 { assert(M==2);(*this)[0]=r0;(*this)[1]=r1; }
421 template <
class EE,
int SS>
423 { assert(M==3);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2; }
424 template <
class EE,
int SS>
427 { assert(M==4);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;(*this)[3]=r3; }
428 template <
class EE,
int SS>
431 { assert(M==5);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
432 (*this)[3]=r3;(*this)[4]=r4; }
433 template <
class EE,
int SS>
436 { assert(M==6);(*this)[0]=r0;(*this)[1]=r1;(*this)[2]=r2;
437 (*this)[3]=r3;(*this)[4]=r4;(*this)[5]=r5; }
441 explicit Mat(
const TCol& r0)
442 { assert(N==1); (*this)(0)=r0; }
443 Mat(
const TCol& r0,
const TCol& r1)
444 { assert(N==2);(*this)(0)=r0;(*this)(1)=r1; }
445 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2)
446 { assert(N==3);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2; }
447 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
449 { assert(N==4);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;(*this)(3)=r3; }
450 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
451 const TCol& r3,
const TCol& r4)
452 { assert(N==5);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
453 (*this)(3)=r3;(*this)(4)=r4; }
454 Mat(
const TCol& r0,
const TCol& r1,
const TCol& r2,
455 const TCol& r3,
const TCol& r4,
const TCol& r5)
456 { assert(N==6);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
457 (*this)(3)=r3;(*this)(4)=r4;(*this)(5)=r5; }
461 { assert(N==1); (*this)(0)=r0; }
463 { assert(N==2);(*this)(0)=r0;(*this)(1)=r1; }
464 template <
class EE,
int SS>
466 { assert(N==3);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2; }
467 template <
class EE,
int SS>
470 { assert(N==4);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;(*this)(3)=r3; }
471 template <
class EE,
int SS>
474 { assert(N==5);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
475 (*this)(3)=r3;(*this)(4)=r4; }
476 template <
class EE,
int SS>
479 { assert(N==6);(*this)(0)=r0;(*this)(1)=r1;(*this)(2)=r2;
480 (*this)(3)=r3;(*this)(4)=r4;(*this)(5)=r5; }
484 template <
class EE>
explicit Mat(
const EE* p)
485 { assert(p);
for(
int i=0;i<M;++i) (*
this)[i]=&p[i*N]; }
491 for (
int j=0; j<N; ++j) (*
this)(j) = mm(j);
496 assert(p);
for(
int i=0;i<M;++i) (*
this)[i]=&p[i*N];
501 template <
class EE,
int CSS,
int RSS>
Mat&
503 for (
int j=0; j<N; ++j) (*
this)(j) += mm(j);
506 template <
class EE,
int CSS,
int RSS>
Mat&
508 for (
int j=0; j<N; ++j) (*
this)(j) -= -(mm(j));
512 template <
class EE,
int CSS,
int RSS>
Mat&
514 for (
int j=0; j<N; ++j) (*
this)(j) -= mm(j);
517 template <
class EE,
int CSS,
int RSS>
Mat&
519 for (
int j=0; j<N; ++j) (*
this)(j) += -(mm(j));
525 template <
class EE,
int CSS,
int RSS>
Mat&
528 for (
int j=0; j<N; ++j)
529 for (
int i=0; i<M; ++i)
530 (*
this)(i,j) = t[i] * mm(j);
538 template <
class E2,
int CS2,
int RS2>
539 typename Result<Mat<M,N,E2,CS2,RS2> >::Add
541 typename Result<Mat<M,N,E2,CS2,RS2> >::Add result;
542 for (
int j=0;j<N;++j) result(j) = (*this)(j) + r(j);
546 template <
class E2,
int CS2,
int RS2>
547 typename Result<Mat<M,N,E2,CS2,RS2> >::Sub
549 typename Result<Mat<M,N,E2,CS2,RS2> >::Sub result;
550 for (
int j=0;j<N;++j) result(j) = (*this)(j) - r(j);
554 template <
class E2,
int CS2,
int RS2>
561 template <
class E2,
int CS2,
int RS2>
562 typename EltResult<E2>::Mul
564 typename EltResult<E2>::Mul result;
565 for (
int j=0;j<N;++j)
571 template <
class E2,
int CS2,
int RS2>
572 typename EltResult<E2>::Dvd
574 typename EltResult<E2>::Dvd result;
575 for (
int j=0;j<N;++j)
582 template <
class E2,
int RS2>
583 typename Result<SymMat<M,E2,RS2> >::Add
589 template <
class E2,
int RS2>
590 typename Result<SymMat<M,E2,RS2> >::Sub
593 return sy.conformingSubtractFromLeft(*
this);
596 template <
class E2,
int RS2>
604 template <
int N2,
class E2,
int CS2,
int RS2>
605 typename Result<Mat<N,N2,E2,CS2,RS2> >::Mul
607 typename Result<Mat<N,N2,E2,CS2,RS2> >::Mul result;
608 for (
int j=0;j<N2;++j)
609 for (
int i=0;i<M;++i)
610 result(i,j) = (*this)[i].conformingMultiply(m(j));
614 template <
int M2,
class E2,
int CS2,
int RS2>
621 template <
int M2,
class E2,
int CS2,
int RS2>
622 typename Result<Mat<M2,N,E2,CS2,RS2> >::Dvd
627 template <
int M2,
class E2,
int CS2,
int RS2>
663 TNormalize elementwiseNormalized;
665 for (
int j=0; j<N; ++j)
666 elementwiseNormalized(j) = (*this)(j).
normalize();
667 return elementwiseNormalized;
681 const TNeg&
negate()
const {
return *
reinterpret_cast<const TNeg*
>(
this); }
682 TNeg&
updNegate() {
return *
reinterpret_cast<TNeg*
>(
this); }
684 const THerm&
transpose()
const {
return *
reinterpret_cast<const THerm*
>(
this); }
688 {
return *
reinterpret_cast<const TPosTrans*
>(
this); }
690 {
return *
reinterpret_cast<TPosTrans*
>(
this); }
708 const Precision* p =
reinterpret_cast<const Precision*
>(
this);
709 return *
reinterpret_cast<const TImag*
>(p+offs);
713 Precision* p =
reinterpret_cast<Precision*
>(
this);
714 return *
reinterpret_cast<TImag*
>(p+offs);
720 const TRow&
row(
int i)
const {
722 return *
reinterpret_cast<const TRow*
>(&d[i*RS]);
726 return *
reinterpret_cast<TRow*
>(&d[i*RS]);
729 const TCol&
col(
int j)
const {
731 return *
reinterpret_cast<const TCol*
>(&d[j*CS]);
735 return *
reinterpret_cast<TCol*
>(&d[j*CS]);
738 const E&
elt(
int i,
int j)
const {
752 const TDiag&
diag()
const {
return *
reinterpret_cast<const TDiag*
>(d); }
756 TDiag&
updDiag() {
return *
reinterpret_cast<TDiag*
>(d); }
759 TDiag&
diag() {
return *
reinterpret_cast<TDiag*
>(d); }
788 for (
int j=0; j<N; ++j) result(j) = (*this)(j).
scalarDivide(e);
833 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarEq(EE(0));
847 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarTimesEq(ee);
return *
this; }
852 {
for(
int j=0; j<N; ++j) (*
this)(j).
scalarDivideEq(ee);
return *
this; }
857 for (
int j=0; j<N; ++j)
862 for (
int j=0; j<N; ++j)
869 template <
int MM,
int NN>
struct SubMat {
873 template <
int MM,
int NN>
874 const typename SubMat<MM,NN>::Type&
getSubMat(
int i,
int j)
const {
875 assert(0 <= i && i + MM <= M);
876 assert(0 <= j && j + NN <= N);
879 template <
int MM,
int NN>
881 assert(0 <= i && i + MM <= M);
882 assert(0 <= j && j + NN <= N);
885 template <
int MM,
int NN>
886 void setSubMat(
int i,
int j,
const typename SubMat<MM,NN>::Type& value) {
887 assert(0 <= i && i + MM <= M);
888 assert(0 <= j && j + NN <= N);
895 assert(0 <= i && i < M);
897 for (
int r=0, nxt=0; r<M-1; ++r, ++nxt) {
899 out[r] = (*this)[nxt];
907 assert(0 <= j && j < N);
909 for (
int c=0, nxt=0; c<N-1; ++c, ++nxt) {
911 out(c) = (*this)(nxt);
920 assert(0 <= i && i < M);
921 assert(0 <= j && j < N);
923 for (
int c=0, nxtc=0; c<N-1; ++c, ++nxtc) {
925 for (
int r=0, nxtr=0; r<M-1; ++r, ++nxtr) {
927 out(r,c) = (*this)(nxtr,nxtc);
936 template <
class EE,
int SS>
939 out.template updSubMat<M,N>(0,0) = (*
this);
947 template <
class EE,
int SS>
950 out.template updSubMat<M,N>(0,0) = (*
this);
961 template <
class ER,
int SR,
class EC,
int SC>
966 out.template updSubMat<M,N>(0,0) = (*
this);
967 out[M].template updSubRow<N>(0) =
968 row.template getSubRow<N>(0);
978 template <
class EE,
int SS>
980 assert(0 <= i && i <= M);
983 for (
int r=0, nxt=0; r<M; ++r, ++nxt) {
984 if (nxt==i) out[nxt++] =
row;
985 out[nxt] = (*this)[r];
995 template <
class EE,
int SS>
997 assert(0 <= j && j <= N);
1000 for (
int c=0, nxt=0; c<N; ++c, ++nxt) {
1001 if (nxt==j) out(nxt++) =
col;
1002 out(nxt) = (*this)(c);
1014 template <
class ER,
int SR,
class EC,
int SC>
1017 assert(0 <= i && i <= M);
1018 assert(0 <= j && j <= N);
1020 for (
int c=0, nxtc=0; c<N; ++c, ++nxtc) {
1021 if (nxtc==j) ++nxtc;
1022 for (
int r=0, nxtr=0; r<M; ++r, ++nxtr) {
1023 if (nxtr==i) ++nxtr;
1024 out(nxtr,nxtc) = (*this)(r,c);
1033 static const Mat&
getAs(
const ELT* p) {
return *
reinterpret_cast<const Mat*
>(p);}
1045 for (
int j=0; j<N; ++j)
1054 bool seenInf =
false;
1055 for (
int j=0; j<N; ++j) {
1067 for (
int j=0; j<N; ++j)
1079 template <
class E2,
int CS2,
int RS2>
1081 for (
int j=0; j < N; ++j)
1090 template <
class E2,
int CS2,
int RS2>
1105 for (
int i=0; i<M; ++i)
1106 for (
int j=0; j<N; ++j) {
1127 if (M != N)
return false;
1128 for (
int j=0; j<M; ++j)
1129 for (
int i=j; i<M; ++i)
1142 if (M != N)
return false;
1143 for (
int j=0; j<M; ++j)
1144 for (
int i=j; i<M; ++i)
1153 for (
int j = 0; j < N; ++j)
1164 for (
int i = 0; i < M; ++i)
1172 std::stringstream stream;
1174 return stream.str();
1177 const ELT&
get(
int i,
int j)
const {
return elt(i,j); }
1179 void set(
int i,
int j,
const ELT& value) {
elt(i,j)=value; }
1188 int rIx(
int k)
const {
1189 const int row = k / N;
1190 const int col = k % N;
1191 return row*RS + col*CS;
1200 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1201 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<M,N,ER,CSR,RSR> >::Add
1204 ::AddOp::perform(l,r);
1207 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1208 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<M,N,ER,CSR,RSR> >::Sub
1211 ::SubOp::perform(l,r);
1215 template <
int M,
int N,
class EL,
int CSL,
int RSL,
int P,
class ER,
int CSR,
int RSR>
inline
1216 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<N,P,ER,CSR,RSR> >::Mul
1219 ::MulOp::perform(l,r);
1224 template <
int M,
int N,
class EL,
int CSL,
int RSL,
int MM,
int NN,
class ER,
int CSR,
int RSR>
inline
1225 typename Mat<M,N,EL,CSL,RSL>::template Result<Mat<MM,NN,ER,CSR,RSR> >::MulNon
1228 ::MulOpNonConforming::perform(l,r);
1231 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1233 for (
int j=0; j<N; ++j)
1234 if (l(j) != r(j))
return false;
1237 template <
int M,
int N,
class EL,
int CSL,
int RSL,
class ER,
int CSR,
int RSR>
inline
1250 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1251 typename Mat<M,N,E,CS,RS>::template Result<float>::Mul
1254 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1255 typename Mat<M,N,E,CS,RS>::template Result<float>::Mul
1258 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1259 typename Mat<M,N,E,CS,RS>::template Result<double>::Mul
1262 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1263 typename Mat<M,N,E,CS,RS>::template Result<double>::Mul
1266 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1267 typename Mat<M,N,E,CS,RS>::template Result<long double>::Mul
1270 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1271 typename Mat<M,N,E,CS,RS>::template Result<long double>::Mul
1275 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1276 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Mul
1278 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1279 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Mul
1285 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1286 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1289 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1290 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1294 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1295 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1297 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1298 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Mul
1302 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1303 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Mul
1305 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1306 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Mul
1317 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1318 typename Mat<M,N,E,CS,RS>::template Result<float>::Dvd
1322 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1323 typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1325 {
return l * r.
invert(); }
1327 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1328 typename Mat<M,N,E,CS,RS>::template Result<double>::Dvd
1332 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1333 typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1335 {
return l * r.
invert(); }
1337 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1338 typename Mat<M,N,E,CS,RS>::template Result<long double>::Dvd
1342 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1343 typename CNT<long double>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1345 {
return l * r.
invert(); }
1348 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1349 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Dvd
1353 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1354 typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1362 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1363 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Dvd
1366 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1367 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1369 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::DvdOp::perform(l,r); }
1372 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1373 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Dvd
1375 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1376 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Dvd
1380 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1381 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Dvd
1383 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1384 typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Dvd
1395 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1396 typename Mat<M,N,E,CS,RS>::template Result<float>::Add
1399 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1400 typename Mat<M,N,E,CS,RS>::template Result<float>::Add
1403 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1404 typename Mat<M,N,E,CS,RS>::template Result<double>::Add
1407 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1408 typename Mat<M,N,E,CS,RS>::template Result<double>::Add
1411 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1412 typename Mat<M,N,E,CS,RS>::template Result<long double>::Add
1415 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1416 typename Mat<M,N,E,CS,RS>::template Result<long double>::Add
1420 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1421 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Add
1423 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1424 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Add
1430 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1431 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1434 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1435 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1439 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1440 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1442 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1443 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Add
1447 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1448 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Add
1450 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1451 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Add
1457 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1458 typename Mat<M,N,E,CS,RS>::template Result<float>::Sub
1461 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1462 typename CNT<float>::template Result<Mat<M,N,E,CS,RS> >::Sub
1466 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1467 typename Mat<M,N,E,CS,RS>::template Result<double>::Sub
1470 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1471 typename CNT<double>::template Result<Mat<M,N,E,CS,RS> >::Sub
1475 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1476 typename Mat<M,N,E,CS,RS>::template Result<long double>::Sub
1479 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1480 typename CNT<long double>::template Result<Mat<M,N,E,CS,RS> >::Sub
1485 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1486 typename Mat<M,N,E,CS,RS>::template Result<typename CNT<E>::Precision>::Sub
1488 template <
int M,
int N,
class E,
int CS,
int RS>
inline
1489 typename CNT<typename CNT<E>::Precision>::template Result<Mat<M,N,E,CS,RS> >::Sub
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<std::complex<R> >::Sub
1500 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1501 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1503 {
return CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::SubOp::perform(l,r); }
1506 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1507 typename Mat<M,N,E,CS,RS>::template Result<std::complex<R> >::Sub
1509 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1510 typename CNT<std::complex<R> >::template Result<Mat<M,N,E,CS,RS> >::Sub
1514 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1515 typename Mat<M,N,E,CS,RS>::template Result<typename negator<R>::StdNumber>::Sub
1517 template <
int M,
int N,
class E,
int CS,
int RS,
class R>
inline
1518 typename CNT<R>::template Result<Mat<M,N,E,CS,RS> >::Sub
1523 template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1524 std::basic_ostream<CHAR,TRAITS>&
1526 for (
int i=0;i<M;++i) {
1527 o << std::endl <<
"[";
1528 for (
int j=0;j<N;++j)
1529 o << (j>0?
",":
"") << m(i,j);
1532 if (M) o << std::endl;
1536 template <
int M,
int N,
class E,
int CS,
int RS,
class CHAR,
class TRAITS>
inline
1537 std::basic_istream<CHAR,TRAITS>&
1547 #endif //SimTK_SIMMATRIX_SMALLMATRIX_MAT_H_
std::string toString() const
toString() returns a string representation of the Mat.
Definition: Mat.h:1171
TInvert invert() const
Definition: SmallMatrixMixed.h:1003
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:360
Matrix_< E > operator/(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:2693
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
Mat & operator=(const EE *p)
Definition: Mat.h:495
Mat & scalarDivideEq(const EE &ee)
Definition: Mat.h:851
Mat(const TRow &r0)
Definition: Mat.h:398
Mat< M2, M, E2, CS2, RS2 >::template Result< Mat >::Mul conformingMultiplyFromLeft(const Mat< M2, M, E2, CS2, RS2 > &m) const
Definition: Mat.h:616
const E & operator()(int i, int j) const
Definition: Mat.h:638
K::ScalarNormSq ScalarNormSq
Definition: CompositeNumericalTypes.h:166
Mat< M, N, typename CNT< EE >::template Result< E >::Mul > scalarMultiplyFromLeft(const EE &e) const
Definition: Mat.h:777
EStandard trace() const
Definition: Mat.h:761
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3)
Definition: Mat.h:447
Mat & scalarTimesEq(const EE &ee)
Definition: Mat.h:846
K::ULessScalar ULessScalar
Definition: CompositeNumericalTypes.h:161
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:429
Mat< M+1, N+1, E, M+1, 1 > TAppendRowCol
Definition: Mat.h:137
bool isNaN() const
Return true if any element of this Mat contains a NaN anywhere.
Definition: Mat.h:1044
const TReal & real() const
Definition: Mat.h:696
Mat & operator/=(const EE &e)
Definition: Mat.h:828
K::TReal TReal
Definition: CompositeNumericalTypes.h:141
EScalar Scalar
Definition: Mat.h:139
EStandard sum() const
Definition: Row.h:240
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &r) const
Definition: SymMat.h:503
TDiag & diag()
This non-const version of diag() is an alternate name for updDiag() available for historical reasons...
Definition: Mat.h:759
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4)
Definition: Mat.h:407
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:208
const E & getEltLower(int i, int j) const
Definition: SymMat.h:822
RS is total spacing between rows in memory (default 1)
Definition: SymMat.h:71
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:377
void setToZero()
Definition: Mat.h:861
const TNeg & operator-() const
Definition: Mat.h:676
Vec & scalarEq(const EE &ee)
Definition: Vec.h:728
TDropRow dropRow(int i) const
Return a matrix one row smaller than this one by dropping row i.
Definition: Mat.h:894
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:328
Mat< M, N, ENeg, CS, RS > TNeg
Definition: Mat.h:103
Mat< M, N, ENormalize, M, 1 > TNormalize
Definition: Mat.h:124
const TImag & imag() const
Definition: Mat.h:706
Mat< M, N+1, E, M, 1 > TAppendCol
Definition: Mat.h:136
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:425
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:919
Mat(const EE *p)
Definition: Mat.h:484
Vec< MinDim, E, RS+CS > TDiag
Definition: Mat.h:116
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:477
SimTK::conjugate<R> should be instantiated only for float, double, long double.
Definition: String.h:45
const THerm & transpose() const
Definition: Mat.h:684
K::TSqrt TSqrt
Definition: CompositeNumericalTypes.h:154
TReal & real()
Definition: Mat.h:697
static TSqrt sqrt(const K &t)
Definition: CompositeNumericalTypes.h:239
Mat< M+1, N, E, M+1, 1 > TAppendRow
Definition: Mat.h:135
static int nrow()
Return the number of rows in this Mat, echoing the value supplied for the template paramter M...
Definition: Mat.h:152
Mat & operator*=(const EE &e)
Definition: Mat.h:827
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:1091
Mat & operator=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:490
K::Scalar Scalar
Definition: CompositeNumericalTypes.h:160
EStdNumber StdNumber
Definition: Mat.h:142
static const Mat & getAs(const ELT *p)
Definition: Mat.h:1033
K::TNormalize TNormalize
Definition: CompositeNumericalTypes.h:158
Mat(const Row< N, EE, SS > &r0)
Definition: Mat.h:417
Mat< M, N, typename CNT< EE >::template Result< E >::Dvd > scalarDivideFromLeft(const EE &e) const
Definition: Mat.h:792
Result< Mat< M, N, E2, CS2, RS2 > >::Sub conformingSubtract(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:548
DvdOp::Type Dvd
Definition: Mat.h:219
MulOp::Type Mul
Definition: Mat.h:209
Mat(const E &e0, const E &e1)
Definition: Mat.h:332
TRow & operator[](int i)
Definition: Mat.h:634
Mat< M, N, typename CNT< E >::template Result< EE >::Sub > scalarSubtract(const EE &e) const
Definition: Mat.h:808
K::TImag TImag
Definition: CompositeNumericalTypes.h:142
Mat(const SymMat< M, ELT > &src)
Explicit construction of a Mat from a SymMat (symmetric/Hermitian matrix).
Definition: Mat.h:268
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:293
Result< Mat< M, N, E2, CS2, RS2 > >::Add conformingAdd(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:540
Mat()
Default construction initializes to NaN when debugging but is left uninitialized otherwise to ensure ...
Definition: Mat.h:239
E & operator()(int i, int j)
Definition: Mat.h:639
Mat< M2, N, E2, CS2, RS2 >::template Result< Mat >::Dvd conformingDivideFromLeft(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition: Mat.h:629
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:223
Mat< M, N, E, M, 1 > TPacked
Definition: Mat.h:131
std::basic_istream< CHAR, TRAITS > & operator>>(std::basic_istream< CHAR, TRAITS > &is, conjugate< R > &c)
Definition: conjugate.h:800
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:371
negator<N>, where N is a number type (real, complex, conjugate), is represented in memory identically...
Definition: String.h:44
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:312
Definition: CompositeNumericalTypes.h:120
Mat< M, N, ESqrt, M, 1 > TSqrt
Definition: Mat.h:120
TWithoutNegator & updCastAwayNegatorIfAny()
Definition: Mat.h:718
static double getDefaultTolerance()
Definition: CompositeNumericalTypes.h:269
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4, const E &e5)
Definition: Mat.h:340
CNT< ScalarNormSq >::TSqrt norm() const
Definition: Mat.h:644
Mat< M, N, EStandard, M, 1 > TStandard
Definition: Mat.h:122
Result< Mat< M2, N, E2, CS2, RS2 > >::Dvd conformingDivide(const Mat< M2, N, E2, CS2, RS2 > &m) const
Definition: Mat.h:623
Mat< M, N, typename CNT< E >::template Result< EE >::Mul > scalarMultiply(const EE &e) const
Definition: Mat.h:771
TSqrt sqrt() const
Elementwise square root; that is, the return value has the same dimensions as this Mat but with each ...
Definition: Mat.h:171
bool operator==(const PhiMatrix &p1, const PhiMatrix &p2)
Definition: SpatialAlgebra.h:774
THerm TransposeType
Definition: Mat.h:146
Mat< M, N, EImag, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TImag
Definition: Mat.h:109
TDiag & updDiag()
Select main diagonal (of largest leading square if rectangular) and return it as a writable view (as ...
Definition: Mat.h:756
Mat< M, N, P > Type
Definition: Mat.h:234
Result< Mat< N, N2, E2, CS2, RS2 > >::Mul conformingMultiply(const Mat< N, N2, E2, CS2, RS2 > &m) const
Definition: Mat.h:606
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:306
const E & elt(int i, int j) const
Definition: Mat.h:738
Mat< M, N, EReal, CS *CNT< E >::RealStrideFactor, RS *CNT< E >::RealStrideFactor > TReal
Definition: Mat.h:107
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:1053
static int size()
Return the total number of elements M*N contained in this Mat.
Definition: Mat.h:149
Vec & scalarPlusEq(const EE &ee)
Definition: Vec.h:730
Mat & operator+=(const EE &e)
Definition: Mat.h:825
Mat(const ENeg &e)
Explicit construction from a single element e whose type is negator<E> (abbreviated ENeg here) where E ...
Definition: Mat.h:319
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:389
TCol & operator()(int j)
Definition: Mat.h:636
K::TSqTHerm TSqTHerm
Definition: CompositeNumericalTypes.h:147
const TNeg & negate() const
Definition: Mat.h:681
TCol rowSum() const
Returns a column vector (Vec) containing the row sums of this matrix.
Definition: Mat.h:1162
ENumber Number
Definition: Mat.h:141
Mat< M-1, N-1, E, M-1, 1 > TDropRowCol
Definition: Mat.h:134
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
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3, const TRow &r4, const TRow &r5)
Definition: Mat.h:411
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:162
static int ncol()
Return the number of columns in this Mat, echoing the value supplied for the template paramter N...
Definition: Mat.h:155
TDropCol dropCol(int j) const
Return a matrix one column smaller than this one by dropping column j.
Definition: Mat.h:906
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
TImag & imag()
Definition: Mat.h:711
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:1179
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:472
const TWithoutNegator & castAwayNegatorIfAny() const
Definition: Mat.h:717
EltResult< E2 >::Mul elementwiseMultiply(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:563
const THerm & operator~() const
Definition: Mat.h:678
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:356
K::Precision Precision
Definition: CompositeNumericalTypes.h:164
Mat & scalarEq(const EE &ee)
Definition: Mat.h:832
Matrix_< E > operator*(const MatrixBase< E > &l, const typename CNT< E >::StdNumber &r)
Definition: BigMatrix.h:2685
TNormalize normalize() const
Definition: Mat.h:659
Vec< M, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: Vec.h:697
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
Mat(const TCol &r0)
Definition: Mat.h:441
K::TInvert TInvert
Definition: CompositeNumericalTypes.h:157
Mat< MM, NN, ELT, CS, RS > Type
Definition: Mat.h:870
Mat< M, N, typename CNT< E >::template Result< P >::Sub, M, 1 > Sub
Definition: Mat.h:200
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:468
Mat & operator*=(const Mat< N, N, EE, CSS, RSS > &mm)
Definition: Mat.h:526
THerm & operator~()
Definition: Mat.h:679
ELEM max(const VectorBase< ELEM > &v)
Definition: VectorMath.h:251
NTraits< N >::StdNumber StdNumber
Definition: negator.h:107
EScalarNormSq ScalarNormSq
Definition: Mat.h:144
Mat & operator-=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition: Mat.h:518
Mat(const TCol &r0, const TCol &r1, const TCol &r2)
Definition: Mat.h:445
SubOp::Type Sub
Definition: Mat.h:229
Mat & scalarDivideEqFromLeft(const EE &ee)
Definition: Mat.h:853
Mat(const E &e0, const E &e1, const E &e2, const E &e3)
Definition: Mat.h:336
K::TPosTrans TPosTrans
Definition: CompositeNumericalTypes.h:145
Mat(const TRow &r0, const TRow &r1, const TRow &r2, const TRow &r3)
Definition: Mat.h:404
Mat(const E &e0, const E &e1, const E &e2)
Definition: Mat.h:334
TAbs abs() const
Elementwise absolute value; that is, the return value has the same dimensions as this Mat but with ea...
Definition: Mat.h:180
EltResult< E2 >::Dvd elementwiseDivide(const Mat< M, N, E2, CS2, RS2 > &r) const
Definition: Mat.h:573
void setToNaN()
Definition: Mat.h:856
TStandard standardize() const
Definition: Mat.h:186
Mat(const TRow &r0, const TRow &r1)
Definition: Mat.h:400
static Mat< M, N, ELT, M, 1 > getNaN()
Definition: Mat.h:1037
const TCol & operator()(int j) const
Definition: Mat.h:635
Mat & operator+=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:502
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:213
K::StdNumber StdNumber
Definition: CompositeNumericalTypes.h:163
bool operator!=(const conjugate< R > &a, const float &b)
Definition: conjugate.h:859
void setSubMat(int i, int j, const typename SubMat< MM, NN >::Type &value)
Definition: Mat.h:886
const TRow & operator[](int i) const
Definition: Mat.h:633
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:218
SymMat< N, ESqHermT > TSqHermT
Definition: Mat.h:126
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:352
const SubMat< MM, NN >::Type & getSubMat(int i, int j) const
Definition: Mat.h:874
Specialized information about Composite Numerical Types which allows us to define appropriate templat...
Definition: CompositeNumericalTypes.h:136
Result< SymMat< M, E2, RS2 > >::Add conformingAdd(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:584
Mat(const Vec< M, EE, SS > &r0)
Definition: Mat.h:460
Mat< M, N, typename CNT< E >::template Result< EE >::Add > scalarAdd(const EE &e) const
Definition: Mat.h:800
TRow colSum() const
Returns a row vector (Row) containing the column sums of this matrix.
Definition: Mat.h:1151
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1, const Vec< M, EE, SS > &r2)
Definition: Mat.h:465
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:937
Generic Row.
Definition: Row.h:118
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:258
THerm & updTranspose()
Definition: Mat.h:685
const Mat & operator+() const
Definition: Mat.h:675
SymMat< M, ESqTHerm > TSqTHerm
Definition: Mat.h:127
const TDiag & diag() const
Definition: SymMat.h:806
E & elt(int i, int j)
Definition: Mat.h:743
const TPosTrans & positionalTranspose() const
Definition: Mat.h:687
Mat(const Mat &src)
Copy constructor copies only the elements that are present and does not touch any unused memory space...
Definition: Mat.h:251
const TCol & col(int j) const
Definition: Mat.h:729
SubMat< MM, NN >::Type & updSubMat(int i, int j)
Definition: Mat.h:880
Mandatory first inclusion for any Simbody source or header file.
TPosTrans & updPositionalTranspose()
Definition: Mat.h:689
Mat & operator+=(const Mat< M, N, negator< EE >, CSS, RSS > &mm)
Definition: Mat.h:507
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1, const Row< N, EE, SS > &r2)
Definition: Mat.h:422
Mat(const TCol &r0, const TCol &r1)
Definition: Mat.h:443
K::TNeg TNeg
Definition: CompositeNumericalTypes.h:139
Mat< M, N, E, CS, RS > T
Definition: Mat.h:102
static double getDefaultTolerance()
For approximate comparisions, the default tolerance to use for a matrix is its shortest dimension tim...
Definition: Mat.h:1075
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:1080
K::TStandard TStandard
Definition: CompositeNumericalTypes.h:156
Mat< M, N, typename CNT< E >::template Result< P >::Mul, M, 1 > Mul
Definition: Mat.h:197
ScalarNormSq normSqr() const
Definition: Mat.h:642
#define SimTK_INDEXCHECK(ix, ub, where)
Definition: ExceptionMacros.h:145
Mat< N, M, EInvert, N, 1 > TInvert
Definition: Mat.h:123
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:344
EPrecision Precision
Definition: Mat.h:143
MulOpNonConforming::Type MulNon
Definition: Mat.h:214
K::TWithoutNegator TWithoutNegator
Definition: CompositeNumericalTypes.h:140
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:383
const EHerm & getEltUpper(int i, int j) const
Definition: SymMat.h:826
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:962
SymMat< M, E2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:598
Vec< M, E, RS > TCol
Definition: Mat.h:115
EULessScalar ULessScalar
Definition: Mat.h:140
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:979
Mat(const TRow &r0, const TRow &r1, const TRow &r2)
Definition: Mat.h:402
Mat< M, N, typename CNT< E >::template Result< P >::Dvd, M, 1 > Dvd
Definition: Mat.h:198
Mat< M, N, E2, CS2, RS2 >::template Result< Mat >::Sub conformingSubtractFromLeft(const Mat< M, N, E2, CS2, RS2 > &l) const
Definition: Mat.h:556
Row< N, E, CS > TRow
Definition: Mat.h:114
Mat< M, N, EComplex, CS, RS > TComplex
Definition: Mat.h:110
Mat & scalarMinusEqFromLeft(const EE &ee)
Definition: Mat.h:843
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:282
bool isFinite() const
Return true if no element contains an Infinity or a NaN.
Definition: Mat.h:1066
Mat< M-1, N, E, M-1, 1 > TDropRow
Definition: Mat.h:132
This class represents a small matrix whose size is known at compile time, containing elements of any ...
Definition: Mat.h:51
K::TComplex TComplex
Definition: CompositeNumericalTypes.h:143
TNeg & operator-()
Definition: Mat.h:677
Mat< M, N, typename CNT< E >::template Result< P >::Add, M, 1 > Add
Definition: Mat.h:199
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:434
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:948
Mat & operator-=(const Mat< M, N, EE, CSS, RSS > &mm)
Definition: Mat.h:513
Mat(const Vec< M, EE, SS > &r0, const Vec< M, EE, SS > &r1)
Definition: Mat.h:462
K::Number Number
Definition: CompositeNumericalTypes.h:162
Mat< N, M, E, RS, CS > TPosTrans
Definition: Mat.h:112
AddOp::Type Add
Definition: Mat.h:224
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4)
Definition: Mat.h:450
Mat & operator-=(const EE &e)
Definition: Mat.h:826
Mat(const E &e0, const E &e1, const E &e2, const E &e3, const E &e4)
Definition: Mat.h:338
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:1141
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:348
Mat(const TCol &r0, const TCol &r1, const TCol &r2, const TCol &r3, const TCol &r4, const TCol &r5)
Definition: Mat.h:454
Mat & scalarMinusEq(const EE &ee)
Definition: Mat.h:840
TRow & row(int i)
Definition: Mat.h:724
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:228
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:365
K::TSqHermT TSqHermT
Definition: CompositeNumericalTypes.h:146
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:1015
const TRow & row(int i) const
Definition: Mat.h:720
TNeg & updNegate()
Definition: Mat.h:682
TCol & col(int j)
Definition: Mat.h:733
Mat< M, N, typename CNT< EE >::template Result< E >::Sub > scalarSubtractFromLeft(const EE &e) const
Definition: Mat.h:815
K::THerm THerm
Definition: CompositeNumericalTypes.h:144
TRow sum() const
This is an alternate name for colSum(); behaves like the Matlab function of the same name...
Definition: Mat.h:1159
Vec & scalarMinusEq(const EE &ee)
Definition: Vec.h:732
Mat & scalarPlusEq(const EE &ee)
Definition: Mat.h:837
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:996
Mat & scalarTimesEqFromLeft(const EE &ee)
Definition: Mat.h:848
Mat(const Row< N, EE, SS > &r0, const Row< N, EE, SS > &r1)
Definition: Mat.h:419
Mat< M, N, typename CNT< E >::template Result< EE >::Dvd > scalarDivide(const EE &e) const
Definition: Mat.h:786
E TElement
Definition: Mat.h:113
Result< SymMat< M, E2, RS2 > >::Sub conformingSubtract(const SymMat< M, E2, RS2 > &sy) const
Definition: Mat.h:591
Mat< M, N, EAbs, M, 1 > TAbs
Definition: Mat.h:121
K::TAbs TAbs
Definition: CompositeNumericalTypes.h:155
Mat< N, M, EHerm, RS, CS > THerm
Definition: Mat.h:111
static Mat & updAs(ELT *p)
Definition: Mat.h:1034
Mat< M, N, EWithoutNegator, CS, RS > TWithoutNegator
Definition: Mat.h:104
Mat< M, N-1, E, M, 1 > TDropCol
Definition: Mat.h:133