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 {
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;
260 typedef typename MulOpNonConforming::Type
MulNon;
265 typedef typename DvdOp::Type
Dvd;
270 typedef typename AddOp::Type
Add;
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>
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>
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>
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_