26 if (a == 0 &&
std::abs(b) < eps )
return 0;
27 if (b == 0 &&
std::abs(a) < eps )
return 0;
30 std::cout <<
"\nFailure " << a <<
" different than " << b << std::endl;
32 std::cout <<
"\n" << s <<
" : Failure " << a <<
" different than " << b << std::endl;
36 int compare(
int a,
int b,
const std::string & s=
"") {
39 std::cout <<
"\nFailure " << a <<
" different than " << b << std::endl;
41 std::cout <<
"\n" << s <<
" : Failure " << a <<
" different than " << b << std::endl;
44 int compare(
bool a,
bool b,
const std::string & s=
"") {
45 return compare(static_cast<int>(a), static_cast<int>(b),s);
52 std::cout <<
"x: " << x << std::endl;
53 std::cout <<
"y: " << y << std::endl;
74 std::cout <<
"A: " << std::endl << A << std::endl;
79 std::cout <<
"z: " << std::endl << z << std::endl;
82 #ifdef TEST_STATIC_CHECK
90 float m[4] = {1,2,3,4};
96 std::cout <<
"sm: " << std::endl << sm << std::endl;
99 std::vector<float> vm(sm.
begin(), sm.
end() );
105 if ( sp1 != sp2) { std::cout <<
"Test STL interface for SVector failed" << std::endl;
return -1; }
106 if ( sm2 != sm) { std::cout <<
"Test STL interface for SMatrix failed" << std::endl;
return -1; }
112 std::cout <<
"3x3 Identity\n" << i3 << std::endl;
115 std::cout <<
"2x3 Identity\n" << i23 << std::endl;
118 std::cout <<
"Sym matrix Identity\n" << is3 << std::endl;
123 std::cout <<
"4x3 Identity\n" << A << std::endl;
125 std::vector<float>
v(6);
126 for (
int i = 0; i <6; ++i) v[i] =
double(i+1);
128 std::cout << s3 << std::endl;
141 std::cout <<
"A: " << std::endl << A << std::endl;
144 std::cout <<
"x: " << x << std::endl;
147 std::cout <<
"y: " << y << std::endl;
156 A(0,0) =
A(0,1) =
A(1,0) = 1;
160 std::cout <<
"A: " << std::endl << A << std::endl;
164 std::cout <<
"Determinant: " << det << std::endl;
166 std::cout <<
"A again: " << std::endl << A << std::endl;
170 std::cout <<
"A^-1: " << std::endl << A << std::endl;
173 std::cout <<
"A^-1 * B: " << std::endl << A * B << std::endl;
182 A(0,0) =
A(0,1) =
A(1,0) = 1;
184 std::cout <<
" A: " << std::endl << A << std::endl;
187 std::cout <<
"x: " << x << std::endl;
190 std::cout <<
" (x+1)^T * (A+1) * (x+1): " <<
Similarity(x+1,A+1) << std::endl;
199 A(0,0) =
A(0,1) =
A(1,1) =
A(2,2) = 4.;
201 std::cout <<
"A: " << std::endl << A << std::endl;
203 std::cout <<
" x: " << x << std::endl;
205 std::cout <<
" a: " << a << std::endl;
208 std::cout <<
" y: " << y << std::endl;
211 std::cout <<
" b: " << b << std::endl;
220 A(0,0) =
A(0,1) =
A(1,1) =
A(2,0) =
A(3,1) = 4.;
221 std::cout <<
"A: " << std::endl << A << std::endl;
224 S(0,0) =
S(0,1) =
S(1,1) =
S(0,2) = 1.;
225 std::cout <<
" S: " << std::endl << S << std::endl;
228 std::cout <<
" C: " << std::endl << C << std::endl;
250 std::cout <<
"x\n" << x <<
"y\n" << y <<
"z\n" << z << std::endl;
253 std::cout <<
"x * (- y) : " << std::endl <<
Times(x, -y) << std::endl;
256 std::cout <<
"x += z - y: " << std::endl << x << std::endl;
259 std::cout <<
"sqrt(z): " << std::endl <<
sqrt(z) << std::endl;
262 std::cout <<
"2 * y: " << std::endl << 2 * y << std::endl;
267 std::cout <<
"fabs(3*x -z): " << std::endl <<
fabs(3*x -z) << std::endl;
271 std::cout <<
" fabs(-z+3*x) " << std::endl <<
fabs(ztmp) << std::endl;
286 std::cout <<
"A: " << std::endl << A << std::endl;
291 std::cout <<
"dot(x,y): " <<
Dot(x,y) << std::endl;
293 std::cout <<
"mag(x): " <<
Mag(x) << std::endl;
295 std::cout <<
"cross(x,y): " <<
Cross(x,y) << std::endl;
297 std::cout <<
"unit(x): " <<
Unit(x) << std::endl;
300 std::cout <<
"x + y: " << x+y << std::endl;
302 std::cout <<
"x + y(0) " << (x+
y)(0) << std::endl;
304 std::cout <<
"x * -y: " << x * -y << std::endl;
306 std::cout <<
"x += z - y: " << x << std::endl;
309 std::cout <<
"sqrt(z): " <<
sqrt(z) << std::endl;
312 std::cout <<
"2 * y: " << 2 * y << std::endl;
315 std::cout <<
"fabs(-z + 3*x): " <<
fabs(-z + 3*x) << std::endl;
320 std::cout <<
"a: " << a << std::endl;
324 std::cout << x2 << std::endl;
333 A(0,0) =
A(0,1) =
A(1,0) = 1;
339 std::cout <<
"Determinant: " << det << std::endl;
344 std::cout <<
"inversion failed\n";
347 std::cout <<
"A^-1: " << std::endl << Ainv << std::endl;
350 std::cout <<
"A^-1 * A: " << std::endl << Ainv * A << std::endl;
358 double d[9] = { 1,2,3,4,5,6,7,8,9};
361 std::cout <<
"A: " << A << std::endl;
366 std::cout <<
" v23 = " << v23 <<
" \tv69 = " << v69 << std::endl;
367 iret |=
compare(
Dot(v23,v69),
double(2*6+3*9) );
373 std::cout <<
" subA1 = " << subA1 <<
" \nsubA2 = " << subA2 << std::endl;
374 iret |=
compare ( subA1(0,0), subA2(1,0));
375 iret |=
compare ( subA1(0,1), subA2(1,1));
380 std::cout <<
" diagonal = " << diag << std::endl;
386 std::cout <<
" B = " << B << std::endl;
388 #ifdef UNSUPPORTED_TEMPLATE_EXPRESSION
397 std::cout <<
" vU = " << vU <<
" \tvL = " << vL << std::endl;
403 std::cout <<
" sub vU = " << subV << std::endl;
405 iret |=
compare( vU[2], subV[1] );
414 iret |=
compare( static_cast<int>(C==D), 1 );
419 iret |=
compare( static_cast<int>(C==C2), 1 );
420 iret |=
compare( static_cast<int>(D==D2), 1 );
430 double dSym[15] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
431 double d3[10] = {1,2,3,4,5,6,7,8,9,10};
432 double d2[10] = {10,1,4,5,8,2,3,6,7,9};
454 m6 = - m32 * m1 + m1;
457 std::cout << m4 << std::endl;
458 std::cout << m5 << std::endl;
459 std::cout << m6 << std::endl;
462 iret |=
compare( m4==m5,
true );
463 iret |=
compare( m4==m6,
true );
479 std::cout <<
"S\n" << S << std::endl;
482 std::cout <<
"S\n" << a * S << std::endl;
494 double d1 =
std::sqrt( IS1(1,0)*IS1(1,0) + IS1(0,1)*IS1(0,1) );
498 iret |=
compare( d1 < 1
E-6,
true,
"inversion1" );
503 M1(0,1) = 1; M1(1,0) = 1; M1(0,2) = 1; M1(1,2) = 1;
510 iret |=
compare( mS2(0,1),
S(0,1)-1 );
512 iret |=
compare( mS2(0,1),
S(0,1) );
540 iret |=
compare( v2[1], v[1]+a );
542 iret |=
compare( v3[1], v[1]+a );
543 iret |=
compare( v3[0], v2[0] );
546 iret |=
compare( v2[1], v[1]-a );
548 iret |=
compare( v3[1], a - v[1] );
552 iret |=
compare( v2[1], b*v[1]+a );
554 iret |=
compare( v3[1], b*v[1]+a );
556 iret |=
compare( v2[1], b*v[1]-a );
558 iret |=
compare( v3[1], a - b*v[1] );
561 iret |=
compare( v2[1], a*v[1]/b );
567 iret |=
compare( v2[1], a*v[1] );
569 iret |=
compare( v3[1], b*v[1] );
571 iret |=
compare( v2[1], v[1]/b );
584 iret |=
compare( m2(1,0),
m(1,0)+a );
586 iret |=
compare( m3(1,0),
m(1,0)+a );
587 iret |=
compare( m3(0,0), m2(0,0) );
590 iret |=
compare( m2(1,0),
m(1,0)-a );
592 iret |=
compare( m3(1,0), a -
m(1,0) );
596 iret |=
compare( m2(1,0), b*
m(1,0)+a );
598 iret |=
compare( m3(1,0), b*
m(1,0)+a );
600 iret |=
compare( m2(1,0), b*
m(1,0)-a );
602 iret |=
compare( m3(1,0), a - b*
m(1,0) );
605 iret |=
compare( m2(1,0), a*
m(1,0)/b );
609 w(0,0) = 5; w(0,1) = 6; w(1,0)=7; w(1,1) = 8;
613 iret |=
compare( m2(1,0), a*
m(1,0) );
615 iret |=
compare( m3(1,0), b*
m(1,0) );
617 iret |=
compare( m2(1,0),
m(1,0)/b );
624 s(0,0) = 1; s(1,0) = 2; s(1,1) = 3;
629 iret |=
compare( s2(1,0), s(1,0)+a );
631 iret |=
compare( s3(1,0), s(1,0)+a );
632 iret |=
compare( s3(0,0), s2(0,0) );
635 iret |=
compare( s2(1,0), s(1,0)-a );
637 iret |=
compare( s3(1,0), a - s(1,0) );
642 iret |=
compare( s2(1,0), b*s(1,0)+a );
644 iret |=
compare( s3(1,0), b*s(1,0)+a );
646 iret |=
compare( s2(1,0), b*s(1,0)-a );
648 iret |=
compare( s3(1,0), a - b*s(1,0) );
651 iret |=
compare( s2(1,0), a*s(1,0)/b );
656 t(0,0) = 4; t(0,1) = 5; t(1,1) = 6;
660 iret |=
compare( s2(1,0), a*s(1,0),
"a*(r+t)" );
662 iret |=
compare( s3(1,0), b*s(1,0),
"(t+r)*b" );
664 iret |=
compare( s2(1,0), s(1,0)/b,
"(r+t)/b" );
685 double u[6] = {1,2,3,4,5,6};
698 iret |=
compare(
A(1,0),-2*U(0,0) );
699 iret |=
compare(
A(1,1),-2*U(0,1) );
700 iret |=
compare(
A(2,1),-2*U(1,1) );
701 iret |=
compare(
A(2,2),-2*U(1,2) );
745 #ifdef TEST_STATIC_CHECK
793 SMatrix<double,2,3,MatRepStd<double,2,3> > sA = A.
Sub<
SMatrix<double,2,3,MatRepStd<double,2,3> > > (1,0);
810 #ifdef TEST_STATIC_CHECK
819 #ifdef TEST_STATIC_CHECK
826 iret |=
compare( sA(1,1),v[1] );
828 iret |=
compare( sB(0,0),v[0] );
834 iret |=
compare( sAt.Trace(), v[0]+v[1]);
846 double u[12] = {1,2,3,4,5,6,7,8,9,10,11,12};
847 double w[6] = {1,2,3,4,5,6};
850 iret |=
compare( A1(0,0),u[0] );
851 iret |=
compare( A1(1,2),u[6] );
852 iret |=
compare( A1(2,3),u[11] );
856 iret |=
compare( A2(0,0),w[0] );
857 iret |=
compare( A2(1,0),w[1] );
858 iret |=
compare( A2(2,0),w[3] );
859 iret |=
compare( A2(2,2),w[5] );
864 iret |=
compare( A3(0,0),u[0] );
865 iret |=
compare( A3(0,1),u[1] );
866 iret |=
compare( A3(0,2),u[2] );
867 iret |=
compare( A3(1,2),u[5] );
868 iret |=
compare( A3(2,3),u[8] );
874 iret |=
compare( S1(0,0),w[0] );
875 iret |=
compare( S1(1,0),w[1] );
876 iret |=
compare( S1(1,1),w[2] );
877 iret |=
compare( S1(2,0),w[3] );
878 iret |=
compare( S1(2,1),w[4] );
879 iret |=
compare( S1(2,2),w[5] );
882 iret |=
compare( S2(0,0),w[0] );
883 iret |=
compare( S2(1,0),w[1] );
884 iret |=
compare( S2(2,0),w[2] );
885 iret |=
compare( S2(1,1),w[3] );
886 iret |=
compare( S2(2,1),w[4] );
887 iret |=
compare( S2(2,2),w[5] );
890 double * pA1 = A1.
begin();
891 for (
int i = 0; i< 12; ++i)
892 iret |=
compare( pA1[i],u[i] );
894 double * pS1 = S1.
begin();
895 for (
int i = 0; i< 6; ++i)
896 iret |=
compare( pS1[i],w[i] );
900 std::vector<double> vu(u,u+12);
901 std::vector<double> vw(w,w+6);
904 iret |=
compare( B1(0,0),u[0] );
905 iret |=
compare( B1(1,2),u[6] );
906 iret |=
compare( B1(2,3),0.0 );
909 iret |=
compare( B1(0,0),vu[0] );
910 iret |=
compare( B1(1,2),vu[6] );
911 iret |=
compare( B1(2,3),vu[11] );
914 iret |=
compare( B1(0,0),w[0] );
915 iret |=
compare( B1(1,0),w[1] );
916 iret |=
compare( B1(2,0),w[3] );
917 iret |=
compare( B1(2,2),w[5] );
921 for (
unsigned int i = 0; i < v1.
kSize; ++i)
922 iret |=
compare( v1[i],vu[i] );
926 for (
unsigned int i = 0; i < vw.size(); ++i)
927 iret |=
compare( v1[i],vw[i] );
938 double a[6] = {1,2,3,4,5,6};
939 double w[9] = {10,2,3,4,50,6,7,8,90};
947 iret |=
compare( A==B,
true,
"transp");
956 iret |=
compare( Z==Y,
true,
"mult");
958 for (
int i = 0; i< 9; ++i) {
960 double a = Z.
apply(i);
963 iret |=
compare(a,Y.apply(i),
"index");
970 iret |=
compare( Z==Y,
true,
"complex mult");
990 for (
int i = 0; i < m.
kRows ; ++i)
991 for (
int j = 0; j < m.
kCols ; ++j)
999 double r1 =
Dot(a1, A * a2 );
1000 double r2 =
Dot(a1, a1) *
Dot(a2,a2 );
1001 iret |=
compare(r1,r2,
"tensor prod");
1004 r1 =
Dot(a1, A * a2 )/2;
1005 r2 =
Dot(a1, a1) *
Dot(a2,a2 );
1006 iret |=
compare(r1,r2,
"tensor prod");
1010 r1 =
Dot(a1, A * a2 )/2;
1011 r2 =
Dot(a1, a1) *
Dot(a2,a2 );
1012 iret |=
compare(r1,r2,
"tensor prod");
1015 r1 =
Dot(a1, A * a2 );
1016 r2 =
Dot(a1, a1) *
Dot(a2,a2 );
1017 iret |=
compare(r1,r2,
"tensor prod");
1027 for (
int i = 0; i < 7; ++i) {
1028 for (
int j = 0; j <= i; ++j) {
1030 S(i,j) = 10*
double(std::rand())/(RAND_MAX);
1032 S(i,j) = 2*
double(std::rand())/(RAND_MAX)-1;
1037 iret |=
compare(ifail,0,
"sym7x7 inversion");
1039 for (
int i = 0; i < 7; ++i)
1040 iret |=
compare(Id(i,i),1.,
"inv result");
1043 for (
int i = 0; i < 7; ++i)
1044 for (
int j = 0; j <i; ++j)
1047 iret |=
compare(sum < 1.
E-10,
true,
"inv off diag");
1051 for (
int i = 0; i < 7; ++i) {
1052 for (
int j = 0; j < 7; ++j) {
1054 M(i,j) = 10*
double(std::rand())/(RAND_MAX);
1056 M(i,j) = 2*
double(std::rand())/(RAND_MAX)-1;
1061 iret |=
compare(ifail,0,
"7x7 inversion");
1063 for (
int i = 0; i < 7; ++i)
1064 iret |=
compare(Id(i,i),1.,
"inv result");
1067 for (
int i = 0; i < 7; ++i)
1068 for (
int j = 0; j <i; ++j)
1071 iret |=
compare(sum < 1.
E-10,
true,
"inv off diag");
1082 for (
int i = 0; i < 7; ++i) {
1083 for (
int j = 0; j <= i; ++j) {
1085 S(i,j) = 10*float(std::rand())/(RAND_MAX);
1087 S(i,j) = 2*float(std::rand())/(RAND_MAX)-1;
1092 iret |=
compare(ifail,0,
"sym7x7 inversion");
1097 for (
int i = 0; i < 7; ++i)
1098 iret |=
compare(Id(i,i),
float(1.),
"inv sym result");
1101 for (
int i = 0; i < 7; ++i)
1102 for (
int j = 0; j <i; ++j)
1105 iret |=
compare(sum < 1.
E-5,
true,
"inv sym off diag");
1109 for (
int i = 0; i < 7; ++i) {
1110 for (
int j = 0; j < 7; ++j) {
1112 M(i,j) = 10*float(std::rand())/(RAND_MAX);
1114 M(i,j) = 2*float(std::rand())/(RAND_MAX)-1;
1119 iret |=
compare(ifail,0,
"7x7 inversion");
1124 for (
int i = 0; i < 7; ++i)
1125 iret |=
compare(Id(i,i),
float(1.),
"inv result");
1128 for (
int i = 0; i < 7; ++i)
1129 for (
int j = 0; j <i; ++j)
1132 iret |=
compare(sum < 1.
E-5,
true,
"inv off diag");
1145 double d1[6]={1,2,3,4,5,6};
1146 double d2[6]={1,2,5,3,4,6};
1158 if (iret) std::cout <<
"m1+= m2" << m1 << std::endl;
1165 if (iret)std::cout <<
"m1 + 3\n" << m1 <<
" \n " << m3 << std::endl;
1170 if (iret) std::cout <<
"m1-= m2\n" << m1 <<
" \n " << m3 << std::endl;
1175 if (iret) std::cout <<
"m1-= 3\n" << m1 <<
" \n " << m3 << std::endl;
1181 if (iret) std::cout <<
"m1*= 2\n" << m1 <<
"\n" << m3 << std::endl;
1187 if (iret) std::cout <<
"m1*= m2\n" << m1 <<
" \n " << m3 << std::endl;
1192 if (iret) std::cout <<
"m1/=2\n" << m1 <<
" \n " << m3 << std::endl;
1199 if (iret) std::cout <<
"m2 += a*m1\n" << m2 <<
"\n " << m3 << std::endl;
1208 m3 = m1 + (m1 * m2);
1211 if (iret) std::cout <<
"m1 += m1*m2\n" << m1 <<
"\n " << m3 << std::endl;
1213 m3 = m1 - (m1 * m2);
1216 if (iret) std::cout <<
"m1 -= m1*m2\n" << m1 <<
" \n " << m3 << std::endl;
1218 m3 = m1 * (m1 * m2);
1221 if (iret) std::cout <<
"m1 *= m1*m2\n" << m1 <<
"\n " << m3 << std::endl;
1233 m4 = (m1*m2) + (m1*m3);
1237 if (iret) std::cout <<
"m5 = m1*m3\n" << m4 <<
"\n " << m5 << std::endl;
1240 m4 = (m1*m2) - (m1*m3);
1244 if (iret) std::cout <<
"m5 -= m1*m3\n" << m4 <<
"\n " << m5 << std::endl;
1247 m4 = (m1+m2) * (m1-m3);
1252 if (iret) std::cout <<
"m5= m5*(m1-m3) \n" << m4 <<
" \n " << m5 << std::endl;
1280 v3 = v1 - (v1 + v2);
1301 ms3 = ms1 + (ms1 + ms2);
1303 iret |=
compare(ms1==ms3,
true);
1305 ms3 = ms1 - (ms1 + ms2);
1307 iret |=
compare(ms1==ms3,
true);
1316 iret |=
compare(ms3==ms4,
true);
1321 iret |=
compare(ms3==ms4,
true);
1332 double d1[4]={4,6,3,4};
1333 double d2[4]={2,3,1,4};
1341 for (
int i = 0; i < 4; ++i)
1346 for (
int i = 0; i < 4; ++i)
1374 double m[] = { 100, .15, 2.3, 0.01, .01, 1.};
1381 iret |=
compare(ifail==0,
true,
"inversion");
1389 for (
int i = 0; i <
n; ++i) {
1390 for (
int j = 0; j <
n; ++j) {
1398 iret |=
compare(prod, 1.,
"max dev diagonal");
1399 iret |=
compare(vmax, 0.,
"max dev offdiag ",10);
1408 iret |=
compare( (ifail==0),
true,
"solve chol");
1412 for (
int i = 0; i < 3; ++i)
1413 iret |=
compare(v2[i], vec[i],
"v2 ==vec");
1422 double a[9] = { 1,-2,3,4,-5,6,-7,8,9};
1423 double b[9] = { 1,-1,0,0,2,0,-1,0,3};
1437 iret |=
compare(R1 == R2,
true);
1438 iret |=
compare(R == R1,
true);
1460 iret |=
compare(v1 == v2,
true);
1469 if (test##N() == 0) std::cerr << " Test " << itest << " OK " << std::endl; \
1470 else { std::cerr << " Test " << itest << " FAILED " << std::endl; \
1511 if (ret) std::cerr <<
"test SMatrix:\t FAILED !!! " << std::endl;
1512 else std::cerr <<
"test SMatrix: \t OK " << std::endl;
T Dot(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Vector dot product.
T Similarity(const SMatrix< T, D, D, R > &lhs, const SVector< T, D > &rhs)
Similarity Vector - Matrix Product: v^T * A * v returning a scalar value of type T ...
SubVector SubRow(unsigned int therow, unsigned int col0=0) const
return a slice of therow as a vector starting at the colum value col0 until col0+N, where N is the size of the vector (SubVector::kSize ) Condition col0+N <= D2
void SetDiagonal(const Vector &v)
Set the diagonal elements from a Vector Require that vector implements kSize since a check (staticall...
SMatrix< T, D1, D2, R > InverseChol(int &ifail) const
Invert of a symmetric positive defined Matrix using Choleski decomposition.
SubVector Sub(unsigned int row) const
return a subvector of size N starting at the value row where N is the size of the returned vector (Su...
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidian norm) Compute : .
Expr< BinaryOp< MulOp< T >, SMatrix< T, D, D2, R1 >, SMatrix< T, D, D2, R2 >, T >, T, D, D2, typename AddPolicy< T, D, D2, R1, R2 >::RepType > Times(const SMatrix< T, D, D2, R1 > &lhs, const SMatrix< T, D, D2, R2 > &rhs)
Element by element matrix multiplication C(i,j) = A(i,j)*B(i,j) returning a matrix expression...
Expr< TransposeOp< SMatrix< T, D1, D2, R >, T, D1, D2 >, T, D2, D1, typename TranspPolicy< T, D1, D2, R >::RepType > Transpose(const SMatrix< T, D1, D2, R > &rhs)
Matrix Transpose B(i,j) = A(j,i) returning a matrix expression.
return no. of matrix rows
bool Invert()
Invert a square Matrix ( this method changes the current matrix).
bool SolveChol(SMatrix< T, D, D, MatRepSym< T, D > > &mat, SVector< T, D > &vec)
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
SVector< T, D1 > Diagonal() const
return diagonal elements of a matrix as a Vector.
bool Det2(T &det) const
determinant of square Matrix via Dfact.
bool Det(T &det)
determinant of square Matrix via Dfact.
static const double x2[5]
SMatrix: a generic fixed size D1 x D2 Matrix class.
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
SVector< T, D1 > Col(unsigned int thecol) const
return a full Matrix column as a vector (copy the content in a new vector)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void SetElements(InputIterator begin, InputIterator end)
set vector elements copying the values iterator size must match vector size
iterator begin()
STL iterator interface.
unsigned int r1[N_CITIES]
SubVector SubCol(unsigned int thecol, unsigned int row0=0) const
return a slice of the column as a vector starting at the row value row0 until row0+Dsub.
SMatrix< T, D1, D2, R > & Place_in_row(const SVector< T, D > &rhs, unsigned int row, unsigned int col)
place a vector in a Matrix row
return no. of matrix columns
Expr< TensorMulOp< SVector< T, D1 >, SVector< T, D2 > >, T, D1, D2 > TensorProd(const SVector< T, D1 > &lhs, const SVector< T, D2 > &rhs)
Tensor Vector Product : M(i,j) = v(i) * v(j) returning a matrix expression.
T Mag2(const SVector< T, D > &rhs)
Vector magnitude square Template to compute .
SVector< T, D1 *(D2+1)/2 > UpperBlock() const
return the upper Triangular block of the matrices (including the diagonal) as a vector of sizes N = D...
SVector< T, 3 > Cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Vector Cross Product (only for 3-dim vectors) .
Expr< BinaryOp< DivOp< T >, SMatrix< T, D, D2, R1 >, SMatrix< T, D, D2, R2 >, T >, T, D, D2, typename AddPolicy< T, D, D2, R1, R2 >::RepType > Div(const SMatrix< T, D, D2, R1 > &lhs, const SMatrix< T, D, D2, R2 > &rhs)
Division (element wise) of two matrices of the same dimensions: C(i,j) = A(i,j) / B(i...
SVector< T, D > & Place_at(const SVector< T, D2 > &rhs, unsigned int row)
place a sub-vector starting from the given position
SubMatrix Sub(unsigned int row0, unsigned int col0) const
return a submatrix with the upper left corner at the values (row0, col0) and with sizes N1...
T Trace() const
return the trace of a matrix Sum of the diagonal elements
SMatrix< T, D1, D2, R > & Place_at(const SMatrix< T, D3, D4, R2 > &rhs, unsigned int row, unsigned int col)
place a matrix in this matrix
SVector< T, D2 > Row(unsigned int therow) const
return a full Matrix row as a vector (copy the content in a new vector)
SMatrix< T, D1, D2, R > Inverse(int &ifail) const
Invert a square Matrix and returns a new matrix.
const T Square(const T &x)
square Template function to compute , for any type T returning a type T
int compare(T a, T b, const std::string &s="", double tol=1)
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
std::complex< float_v > Z
SMatrix< T, D1, D2, R > & Place_in_col(const SVector< T, D > &rhs, unsigned int row, unsigned int col)
place a vector in a Matrix column
void SetElements(InputIterator begin, InputIterator end, bool triang=false, bool lower=true)
Set matrix elements with STL iterator interface.
unsigned int r2[N_CITIES]
SVector: a generic fixed size Vector class.
iterator end()
STL iterator interface.