23 cout << std::boolalpha << std::endl <<
"FAILED COMPARISON: " << what << std::endl << a <<
" != " << b << std::endl;
25 if (std::is_floating_point<T>::value) {
26 cout << std::scientific << std::setprecision(16) <<
"difference: " << std::abs(a - b) <<
" ( " 27 << std::abs(a - b) / tolerance <<
" ulps)" << std::endl
28 <<
" tolerance: " << tolerance <<
" (" << ulps <<
" ulps)" << std::endl;
33 typename std::enable_if<!std::is_floating_point<T>::value,
int>
::type compare(
T a,
T b,
const std::string &s =
"",
37 return a == b ? 0 : 1;
41 typename std::enable_if<std::is_floating_point<T>::value,
int>
::type compare(
T a,
T b,
const std::string &s =
"",
50 if (abs(a * b) > tol * tol) tol *=
T(0.5) * (abs(a) + abs(b));
52 if (abs(a - b) >
tol) {
64 std::cout <<
"x: " << x << std::endl;
65 std::cout <<
"y: " << y << std::endl;
84 std::cout <<
"A: " << std::endl << A << std::endl;
89 std::cout <<
"z: " << std::endl << z << std::endl;
91 #ifdef TEST_STATIC_CHECK 99 float m[4] = {1, 2, 3, 4};
105 std::cout <<
"sm: " << std::endl << sm << std::endl;
108 std::vector<float> vm(sm.
begin(), sm.
end());
115 std::cout <<
"Test STL interface for SVector failed" << std::endl;
119 std::cout <<
"Test STL interface for SMatrix failed" << std::endl;
126 std::cout <<
"3x3 Identity\n" << i3 << std::endl;
129 std::cout <<
"2x3 Identity\n" << i23 << std::endl;
132 std::cout <<
"Sym matrix Identity\n" << is3 << std::endl;
136 std::cout <<
"4x3 Identity\n" << A << std::endl;
138 std::vector<float>
v(6);
139 for (
int i = 0; i < 6; ++i) v[i] =
double(i + 1);
141 std::cout << s3 << std::endl;
150 A(0, 0) =
A(1, 0) = 1;
152 A(1, 1) =
A(2, 2) = 2;
153 std::cout <<
"A: " << std::endl << A << std::endl;
156 std::cout <<
"x: " << x << std::endl;
159 std::cout <<
"y: " << y << std::endl;
169 A(0, 0) =
A(0, 1) =
A(1, 0) = 1;
170 A(1, 1) =
A(2, 2) = 2;
173 std::cout <<
"A: " << std::endl << A << std::endl;
177 std::cout <<
"Determinant: " << det << std::endl;
179 std::cout <<
"A again: " << std::endl << A << std::endl;
183 std::cout <<
"A^-1: " << std::endl << A << std::endl;
186 std::cout <<
"A^-1 * B: " << std::endl << A * B << std::endl;
196 A(0, 0) =
A(0, 1) =
A(1, 0) = 1;
197 A(1, 1) =
A(2, 2) = 2;
198 std::cout <<
" A: " << std::endl << A << std::endl;
201 std::cout <<
"x: " << x << std::endl;
204 std::cout <<
" (x+1)^T * (A+1) * (x+1): " <<
Similarity(x + 1, A + 1) << std::endl;
214 A(0, 0) =
A(0, 1) =
A(1, 1) =
A(2, 2) = 4.;
216 std::cout <<
"A: " << std::endl << A << std::endl;
218 std::cout <<
" x: " << x << std::endl;
220 std::cout <<
" a: " << a << std::endl;
223 std::cout <<
" y: " << y << std::endl;
226 std::cout <<
" b: " << b << std::endl;
236 A(0, 0) =
A(0, 1) =
A(1, 1) =
A(2, 0) =
A(3, 1) = 4.;
237 std::cout <<
"A: " << std::endl << A << std::endl;
240 S(0, 0) =
S(0, 1) =
S(1, 1) =
S(0, 2) = 1.;
241 std::cout <<
" S: " << std::endl << S << std::endl;
244 std::cout <<
" C: " << std::endl << C << std::endl;
267 std::cout <<
"x\n" << x <<
"y\n" << y <<
"z\n" << z << std::endl;
270 std::cout <<
"x * (- y) : " << std::endl <<
Times(x, -y) << std::endl;
273 std::cout <<
"x += z - y: " << std::endl << x << std::endl;
276 std::cout <<
"sqrt(z): " << std::endl <<
sqrt(z) << std::endl;
279 std::cout <<
"2 * y: " << std::endl << 2 * y << std::endl;
284 std::cout <<
"fabs(3*x -z): " << std::endl <<
fabs(3 * x - z) << std::endl;
288 std::cout <<
" fabs(-z+3*x) " << std::endl <<
fabs(ztmp) << std::endl;
304 std::cout <<
"A: " << std::endl << A << std::endl;
309 std::cout <<
"dot(x,y): " <<
Dot(x, y) << std::endl;
311 std::cout <<
"mag(x): " <<
Mag(x) << std::endl;
313 std::cout <<
"cross(x,y): " <<
Cross(x, y) << std::endl;
315 std::cout <<
"unit(x): " <<
Unit(x) << std::endl;
318 std::cout <<
"x + y: " << x + y << std::endl;
320 std::cout <<
"x + y(0) " << (x +
y)(0) << std::endl;
322 std::cout <<
"x * -y: " << x * -y << std::endl;
324 std::cout <<
"x += z - y: " << x << std::endl;
327 std::cout <<
"sqrt(z): " <<
sqrt(z) << std::endl;
330 std::cout <<
"2 * y: " << 2 * y << std::endl;
333 std::cout <<
"fabs(-z + 3*x): " <<
fabs(-z + 3 * x) << std::endl;
338 std::cout <<
"a: " << a << std::endl;
342 std::cout << x2 << std::endl;
351 A(0, 0) =
A(0, 1) =
A(1, 0) = 1;
352 A(1, 1) =
A(2, 2) = 2;
356 std::cout <<
"Determinant: " << det << std::endl;
361 std::cout <<
"inversion failed\n";
364 std::cout <<
"A^-1: " << std::endl << Ainv << std::endl;
367 std::cout <<
"A^-1 * A: " << std::endl << Ainv * A << std::endl;
376 double d[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
379 std::cout <<
"A: " << A << std::endl;
384 std::cout <<
" v23 = " << v23 <<
" \tv69 = " << v69 << std::endl;
385 iret |=
compare(
Dot(v23, v69),
double(2 * 6 + 3 * 9));
391 std::cout <<
" subA1 = " << subA1 <<
" \nsubA2 = " << subA2 << std::endl;
392 iret |=
compare(subA1(0, 0), subA2(1, 0));
393 iret |=
compare(subA1(0, 1), subA2(1, 1));
396 std::cout <<
" diagonal = " << diag << std::endl;
397 iret |=
compare(
Mag2(diag),
double(1 + 5 * 5 + 9 * 9));
401 std::cout <<
" B = " << B << std::endl;
403 #ifdef UNSUPPORTED_TEMPLATE_EXPRESSION 412 std::cout <<
" vU = " << vU <<
" \tvL = " << vL << std::endl;
418 std::cout <<
" sub vU = " << subV << std::endl;
420 iret |=
compare(vU[2], subV[1]);
429 iret |=
compare(static_cast<int>(C == D), 1);
434 iret |=
compare(static_cast<int>(C == C2), 1);
435 iret |=
compare(static_cast<int>(D == D2), 1);
444 double dSym[15] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
445 double d3[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
446 double d2[10] = {10, 1, 4, 5, 8, 2, 3, 6, 7, 9};
470 std::cout << m4 << std::endl;
471 std::cout << m5 << std::endl;
472 std::cout << m6 << std::endl;
475 iret |=
compare(m4 == m5,
true);
476 iret |=
compare(m4 == m6,
true);
490 std::cout <<
"S\n" << S << std::endl;
493 std::cout <<
"S\n" << a * S << std::endl;
505 double d1 =
std::sqrt(IS1(1, 0) * IS1(1, 0) + IS1(0, 1) * IS1(0, 1));
508 iret |=
compare(d1 < 1
E-6,
true,
"inversion1");
522 iret |=
compare(mS2(0, 1),
S(0, 1) - 1);
524 iret |=
compare(mS2(0, 1),
S(0, 1));
550 iret |=
compare(v2[1], v[1] + a);
552 iret |=
compare(v3[1], v[1] + a);
556 iret |=
compare(v2[1], v[1] - a);
558 iret |=
compare(v3[1], a - v[1]);
562 iret |=
compare(v2[1], b * v[1] + a);
564 iret |=
compare(v3[1], b * v[1] + a);
566 iret |=
compare(v2[1], b * v[1] - a);
568 iret |=
compare(v3[1], a - b * v[1]);
571 iret |=
compare(v2[1], a * v[1] / b);
577 iret |=
compare(v2[1], a * v[1]);
579 iret |=
compare(v3[1], b * v[1]);
581 iret |=
compare(v2[1], v[1] / b);
594 iret |=
compare(m2(1, 0),
m(1, 0) + a);
596 iret |=
compare(m3(1, 0),
m(1, 0) + a);
597 iret |=
compare(m3(0, 0), m2(0, 0));
600 iret |=
compare(m2(1, 0),
m(1, 0) - a);
602 iret |=
compare(m3(1, 0), a -
m(1, 0));
606 iret |=
compare(m2(1, 0), b *
m(1, 0) + a);
608 iret |=
compare(m3(1, 0), b *
m(1, 0) + a);
610 iret |=
compare(m2(1, 0), b *
m(1, 0) - a);
612 iret |=
compare(m3(1, 0), a - b *
m(1, 0));
615 iret |=
compare(m2(1, 0), a *
m(1, 0) / b);
626 iret |=
compare(m2(1, 0), a *
m(1, 0));
628 iret |=
compare(m3(1, 0), b *
m(1, 0));
630 iret |=
compare(m2(1, 0),
m(1, 0) / b);
644 iret |=
compare(s2(1, 0), s(1, 0) + a);
646 iret |=
compare(s3(1, 0), s(1, 0) + a);
647 iret |=
compare(s3(0, 0), s2(0, 0));
650 iret |=
compare(s2(1, 0), s(1, 0) - a);
652 iret |=
compare(s3(1, 0), a - s(1, 0));
656 iret |=
compare(s2(1, 0), b * s(1, 0) + a);
658 iret |=
compare(s3(1, 0), b * s(1, 0) + a);
660 iret |=
compare(s2(1, 0), b * s(1, 0) - a);
662 iret |=
compare(s3(1, 0), a - b * s(1, 0));
665 iret |=
compare(s2(1, 0), a * s(1, 0) / b);
675 iret |=
compare(s2(1, 0), a * s(1, 0),
"a*(r+t)");
677 iret |=
compare(s3(1, 0), b * s(1, 0),
"(t+r)*b");
679 iret |=
compare(s2(1, 0), s(1, 0) / b,
"(r+t)/b");
699 double u[6] = {1, 2, 3, 4, 5, 6};
712 iret |=
compare(
A(1, 0), -2 * U(0, 0));
713 iret |=
compare(
A(1, 1), -2 * U(0, 1));
714 iret |=
compare(
A(2, 1), -2 * U(1, 1));
715 iret |=
compare(
A(2, 2), -2 * U(1, 2));
755 #ifdef TEST_STATIC_CHECK 802 SMatrix<double, 2, 3, MatRepStd<double, 2, 3>> sA = A.
Sub<
SMatrix<double, 2, 3, MatRepStd<double, 2, 3>>>(1, 0);
819 #ifdef TEST_STATIC_CHECK 827 #ifdef TEST_STATIC_CHECK 834 iret |=
compare(sA(1, 1), v[1]);
836 iret |=
compare(sB(0, 0), v[0]);
842 iret |=
compare(sAt.Trace(), v[0] + v[1]);
852 double u[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
853 double w[6] = {1, 2, 3, 4, 5, 6};
856 iret |=
compare(A1(0, 0), u[0]);
857 iret |=
compare(A1(1, 2), u[6]);
858 iret |=
compare(A1(2, 3), u[11]);
862 iret |=
compare(A2(0, 0), w[0]);
863 iret |=
compare(A2(1, 0), w[1]);
864 iret |=
compare(A2(2, 0), w[3]);
865 iret |=
compare(A2(2, 2), w[5]);
870 iret |=
compare(A3(0, 0), u[0]);
871 iret |=
compare(A3(0, 1), u[1]);
872 iret |=
compare(A3(0, 2), u[2]);
873 iret |=
compare(A3(1, 2), u[5]);
874 iret |=
compare(A3(2, 3), u[8]);
879 iret |=
compare(S1(0, 0), w[0]);
880 iret |=
compare(S1(1, 0), w[1]);
881 iret |=
compare(S1(1, 1), w[2]);
882 iret |=
compare(S1(2, 0), w[3]);
883 iret |=
compare(S1(2, 1), w[4]);
884 iret |=
compare(S1(2, 2), w[5]);
887 iret |=
compare(S2(0, 0), w[0]);
888 iret |=
compare(S2(1, 0), w[1]);
889 iret |=
compare(S2(2, 0), w[2]);
890 iret |=
compare(S2(1, 1), w[3]);
891 iret |=
compare(S2(2, 1), w[4]);
892 iret |=
compare(S2(2, 2), w[5]);
895 double *pA1 = A1.
begin();
896 for (
int i = 0; i < 12; ++i) iret |=
compare(pA1[i], u[i]);
898 double *pS1 = S1.
begin();
899 for (
int i = 0; i < 6; ++i) iret |=
compare(pS1[i], w[i]);
902 std::vector<double> vu(u, u + 12);
903 std::vector<double> vw(w, w + 6);
906 iret |=
compare(B1(0, 0), u[0]);
907 iret |=
compare(B1(1, 2), u[6]);
908 iret |=
compare(B1(2, 3), 0.0);
911 iret |=
compare(B1(0, 0), vu[0]);
912 iret |=
compare(B1(1, 2), vu[6]);
913 iret |=
compare(B1(2, 3), vu[11]);
916 iret |=
compare(B1(0, 0), w[0]);
917 iret |=
compare(B1(1, 0), w[1]);
918 iret |=
compare(B1(2, 0), w[3]);
919 iret |=
compare(B1(2, 2), w[5]);
923 for (
unsigned int i = 0; i < v1.
kSize; ++i) iret |=
compare(v1[i], vu[i]);
927 for (
unsigned int i = 0; i < vw.size(); ++i) iret |=
compare(v1[i], vw[i]);
937 double a[6] = {1, 2, 3, 4, 5, 6};
938 double w[9] = {10, 2, 3, 4, 50, 6, 7, 8, 90};
946 iret |=
compare(A == B,
true,
"transp");
955 iret |=
compare(Z == Y,
true,
"mult");
957 for (
int i = 0; i < 9; ++i) {
959 double a = Z.
apply(i);
962 iret |=
compare(a, Y.apply(i),
"index");
966 Z = (A + W) * (B + Y);
967 Y = (A + W) * (B + Y);
969 iret |=
compare(Z == Y,
true,
"complex mult");
987 for (
int i = 0; i < m.
kRows; ++i)
988 for (
int j = 0; j < m.
kCols; ++j) iret |=
compare(
m(i, j), v1(i) * v2(j));
995 double r1 =
Dot(a1, A * a2);
996 double r2 =
Dot(a1, a1) *
Dot(a2, a2);
997 iret |=
compare(r1, r2,
"tensor prod");
1000 r1 =
Dot(a1, A * a2) / 2;
1001 r2 =
Dot(a1, a1) *
Dot(a2, a2);
1002 iret |=
compare(r1, r2,
"tensor prod");
1005 r1 =
Dot(a1, A * a2) / 2;
1006 r2 =
Dot(a1, a1) *
Dot(a2, a2);
1007 iret |=
compare(r1, r2,
"tensor prod");
1010 r1 =
Dot(a1, A * a2);
1011 r2 =
Dot(a1, a1) *
Dot(a2, a2);
1012 iret |=
compare(r1, r2,
"tensor prod");
1023 for (
int i = 0; i < 7; ++i) {
1024 for (
int j = 0; j <= i; ++j) {
1026 S(i, j) = 10 * double(std::rand()) / (RAND_MAX);
1028 S(i, j) = 2 * double(std::rand()) / (RAND_MAX)-1;
1033 iret |=
compare(ifail, 0,
"sym7x7 inversion");
1036 for (
int i = 0; i < 7; ++i)
1037 for (
int j = 0; j < 7; ++j)
1040 iret |=
compare(Id(i, j), i == j ? 1.0 : 0.0,
"sym7x7 inversion result", 50000);
1044 for (
int i = 0; i < 7; ++i) {
1045 for (
int j = 0; j < 7; ++j) {
1047 M(i, j) = 10 * double(std::rand()) / (RAND_MAX);
1049 M(i, j) = 2 * double(std::rand()) / (RAND_MAX)-1;
1054 iret |=
compare(ifail, 0,
"7x7 inversion");
1057 for (
int i = 0; i < 7; ++i)
1058 for (
int j = 0; j < 7; ++j)
1061 iret |=
compare(Id(i, j), i == j ? 1.0 : 0.0,
"sym7x7 inversion result", 50000);
1072 for (
int i = 0; i < 7; ++i) {
1073 for (
int j = 0; j <= i; ++j) {
1075 S(i, j) = 10 * float(std::rand()) / (RAND_MAX);
1077 S(i, j) = 2 * float(std::rand()) / (RAND_MAX)-1;
1082 iret |=
compare(ifail, 0,
"sym7x7 inversion");
1087 for (
int i = 0; i < 7; ++i)
1088 for (
int j = 0; j < 7; ++j)
1091 iret |=
compare(Id(i, j), i == j ? 1.0
f : 0.0
f,
"sym7x7 inversion result", 50000);
1095 for (
int i = 0; i < 7; ++i) {
1096 for (
int j = 0; j < 7; ++j) {
1098 M(i, j) = 10 * float(std::rand()) / (RAND_MAX);
1100 M(i, j) = 2 * float(std::rand()) / (RAND_MAX)-1;
1105 iret |=
compare(ifail, 0,
"7x7 inversion");
1110 for (
int i = 0; i < 7; ++i)
1111 for (
int j = 0; j < 7; ++j)
1114 iret |=
compare(Id(i, j), i == j ? 1.0f : 0.0f,
"sym7x7 inversion result", 50000);
1125 double d1[6] = {1, 2, 3, 4, 5, 6};
1126 double d2[6] = {1, 2, 5, 3, 4, 6};
1137 if (iret) std::cout <<
"m1+= m2" << m1 << std::endl;
1139 iret |=
compare(m1 == m3,
true);
1143 iret |=
compare(m1 == m3,
true);
1144 if (iret) std::cout <<
"m1 + 3\n" << m1 <<
" \n " << m3 << std::endl;
1148 iret |=
compare(m1 == m3,
true);
1149 if (iret) std::cout <<
"m1-= m2\n" << m1 <<
" \n " << m3 << std::endl;
1153 iret |=
compare(m1 == m3,
true);
1154 if (iret) std::cout <<
"m1-= 3\n" << m1 <<
" \n " << m3 << std::endl;
1158 iret |=
compare(m1 == m3,
true);
1159 if (iret) std::cout <<
"m1*= 2\n" << m1 <<
"\n" << m3 << std::endl;
1164 iret |=
compare(m1 == m3,
true);
1165 if (iret) std::cout <<
"m1*= m2\n" << m1 <<
" \n " << m3 << std::endl;
1169 iret |=
compare(m1 == m3,
true);
1170 if (iret) std::cout <<
"m1/=2\n" << m1 <<
" \n " << m3 << std::endl;
1176 iret |=
compare(m2 == m3,
true);
1177 if (iret) std::cout <<
"m2 += a*m1\n" << m2 <<
"\n " << m3 << std::endl;
1184 m3 = m1 + (m1 * m2);
1186 iret |=
compare(m1 == m3,
true);
1187 if (iret) std::cout <<
"m1 += m1*m2\n" << m1 <<
"\n " << m3 << std::endl;
1189 m3 = m1 - (m1 * m2);
1191 iret |=
compare(m1 == m3,
true);
1192 if (iret) std::cout <<
"m1 -= m1*m2\n" << m1 <<
" \n " << m3 << std::endl;
1194 m3 = m1 * (m1 * m2);
1196 iret |=
compare(m1 == m3,
true);
1197 if (iret) std::cout <<
"m1 *= m1*m2\n" << m1 <<
"\n " << m3 << std::endl;
1209 m4 = (m1 * m2) + (m1 * m3);
1212 iret |=
compare(m4 == m5,
true);
1213 if (iret) std::cout <<
"m5 = m1*m3\n" << m4 <<
"\n " << m5 << std::endl;
1215 m4 = (m1 * m2) - (m1 * m3);
1218 iret |=
compare(m4 == m5,
true);
1219 if (iret) std::cout <<
"m5 -= m1*m3\n" << m4 <<
"\n " << m5 << std::endl;
1221 m4 = (m1 + m2) * (m1 - m3);
1223 m5 = m5 * (m1 - m3);
1224 iret |=
compare(m4 == m5,
true);
1226 if (iret) std::cout <<
"m5= m5*(m1-m3) \n" << m4 <<
" \n " << m5 << std::endl;
1235 iret |=
compare(v1 == v3,
true);
1239 iret |=
compare(v1 == v3,
true);
1241 v3 = v1 + (v1 + v2);
1243 iret |=
compare(v1 == v3,
true);
1247 iret |=
compare(v1 == v3,
true);
1251 iret |=
compare(v1 == v3,
true);
1253 v3 = v1 - (v1 + v2);
1255 iret |=
compare(v1 == v3,
true);
1259 iret |=
compare(v1 == v3,
true);
1263 iret |=
compare(v1 == v3,
true);
1274 ms3 = ms1 + (ms1 + ms2);
1276 iret |=
compare(ms1 == ms3,
true);
1278 ms3 = ms1 - (ms1 + ms2);
1280 iret |=
compare(ms1 == ms3,
true);
1283 ms3 = ms1 + a * ms2;
1288 iret |=
compare(ms3 == ms4,
true);
1290 ms3 = ms1 - a * ms2;
1293 iret |=
compare(ms3 == ms4,
true);
1305 double d1[4] = {4, 6, 3, 4};
1306 double d2[4] = {2, 3, 1, 4};
1330 iret |=
compare(m1(0, 0), 2.);
1334 iret |=
compare(m1(0, 0), 2.);
1344 double m[] = {100, .15, 2.3, 0.01, .01, 1.};
1351 iret |=
compare(ifail == 0,
true,
"inversion");
1359 for (
int i = 0; i <
n; ++i) {
1360 for (
int j = 0; j <
n; ++j) {
1364 if (std::abs(
mid(i, j)) > vmax) vmax = std::abs(
mid(i, j));
1368 iret |=
compare(prod, 1.,
"max dev diagonal");
1369 iret |=
compare(vmax, 0.,
"max dev offdiag ", 10);
1378 iret |=
compare((ifail == 0),
true,
"solve chol");
1382 for (
int i = 0; i < 3; ++i) iret |=
compare(v2[i], vec[i],
"v2 ==vec");
1391 double a[9] = {1, -2, 3, 4, -5, 6, -7, 8, 9};
1392 double b[9] = {1, -1, 0, 0, 2, 0, -1, 0, 3};
1406 iret |=
compare(R1 == R2,
true);
1407 iret |=
compare(R == R1,
true);
1429 iret |=
compare(v1 == v2,
true);
1436 if (test##N() == 0) \ 1437 std::cerr << " Test " << itest << " OK " << std::endl; \ 1439 std::cerr << " Test " << itest << " FAILED " << std::endl; \ 1481 std::cerr <<
"test SMatrix:\t FAILED !!! " << std::endl;
1483 std::cerr <<
"test SMatrix: \t OK " << std::endl;
SMatrix< T, D1, D2, R > InverseChol(int &ifail) const
Invert of a symmetric positive defined Matrix using Choleski decomposition.
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 ...
void SetDiagonal(const Vector &v)
Set the diagonal elements from a Vector Require that vector implements kSize since a check (staticall...
return no. of matrix rows
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t mid
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.
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)
SVector< T, D2 > Row(unsigned int therow) const
return a full Matrix row as a vector (copy the content in a new vector)
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.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
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
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.
return no. of matrix columns
RooArgSet S(const RooAbsArg &v1)
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.
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...
unsigned int r1[N_CITIES]
SVector< T, D1 > Diagonal() const
return diagonal elements of a matrix as a Vector.
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
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 .
bool Det2(T &det) const
determinant of square Matrix via Dfact.
SMatrix< T, D1, D2, R > Inverse(int &ifail) const
Invert a square Matrix and returns a new matrix.
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...
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...
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
T Trace() const
return the trace of a matrix Sum of the diagonal elements
SVector< T, D > & Place_at(const SVector< T, D2 > &rhs, unsigned int row)
place a sub-vector starting from the given position
you should not use this method at all Int_t Int_t z
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
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
const T Square(const T &x)
square Template function to compute , for any type T returning a type T
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
std::enable_if<!std::is_floating_point< T >::value, int >::type compare(T a, T b, const std::string &s="", int ulps=10)
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.
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...
void compare_fail(T a, T b, int ulps, T tolerance, const std::string &what)
SVector< T, D1 > Col(unsigned int thecol) const
return a full Matrix column as a vector (copy the content in a new vector)
unsigned int r2[N_CITIES]
SVector: a generic fixed size Vector class.
iterator end()
STL iterator interface.