18 cout <<
"x: " << x << endl;
19 cout <<
"y: " << y << endl;
27 cout <<
"A: " << endl << A << endl;
37 cout <<
"A: " << endl << A << endl;
40 cout <<
"x: " << x << endl;
43 cout <<
"y: " << y << endl;
50 A(0,0) = A(0,1) = A(1,0) = 1;
54 cout <<
"A: " << endl << A << endl;
63 cout <<
"A^-1: " << endl << A << endl;
66 cout <<
"A^-1 * B: " << endl << A *
B << endl;
73 A(0,0) = A(0,1) = A(1,0) = 1;
75 cout <<
" A: " << endl << A << endl;
78 cout <<
"x: " << x << endl;
81 cout <<
" (x+1)^T * (A+1) * (x+1): " <<
product(x+1,A+1) << endl;
88 A(0,0) = A(0,1) = A(1,1) = A(2,2) = 4.;
90 cout <<
"A: " << endl << A << endl;
92 cout <<
" x: " << x << endl;
94 cout <<
" a: " <<
a << endl;
97 cout <<
" y: " << y << endl;
100 cout <<
" b: " << b << endl;
107 A(0,0) = A(0,1) = A(1,1) = A(2,0) = A(3,1) = 4.;
108 cout <<
"A: " << endl << A << endl;
111 S(0,0) = S(0,1) = S(1,1) = S(0,2) = 1.;
112 cout <<
" S: " << endl << S << endl;
115 cout <<
" C: " << endl << C << endl;
126 cout <<
"x * y: " << endl <<
times(x, -y) << endl;
129 cout <<
"x += z - y: " << endl << x << endl;
132 cout <<
"sqrt(z): " << endl << sqrt(z) << endl;
135 cout <<
"2 * y: " << endl << 2 * y << endl;
138 cout <<
"fabs(-z + 3*x): " << endl <<
fabs(-z + 3*x) << endl;
145 A(0,0) = A(1,1) = A(0,2) = 5.;
147 cout <<
"A: " << endl << A << endl;
152 cout <<
"dot(x,y): " <<
dot(x,y) << endl;
154 cout <<
"mag(x): " <<
mag(x) << endl;
156 cout <<
"cross(x,y): " <<
cross(x,y) << endl;
158 cout <<
"unit(x): " <<
unit(x) << endl;
161 cout <<
"x + y: " << x+y << endl;
163 cout <<
"x * y: " << x * -y << endl;
165 cout <<
"x += z - y: " << x << endl;
168 cout <<
"sqrt(z): " << sqrt(z) << endl;
171 cout <<
"2 * y: " << 2 * y << endl;
174 cout <<
"fabs(-z + 3*x): " <<
fabs(-z + 3*x) << endl;
179 cout <<
"a: " <<
a << endl;
182 for(
unsigned int i=0; i<1000000; ++i) {
184 VtVector
a(1.,2.,3.);
185 VtVector b(4.,5.,6.);
186 VtVector c(8.,9.,10.);
188 VtVector
d =
a*(-1) + b;
189 VtVector
d =
a + b + c;
193 A(0,0) = A(1,1) = A(2,2) = 4.;
202 cout <<
" y: " << y << endl;
208 A(0,0) = A(1,1) = A(2,2) = 4.;
212 B(0,1) =
B(1,0) =
B(1,1) =
B(0,2) = 1.;
216 C(0,2) = C(1,2) = C(2,2) = 2.;
219 VtMatrix D = A +
B + C + A +
B + C;
220 cout <<
" D: " << D << endl;
224 VtSymMatrix VA(3,2.);
225 VA(0,0) = VA(0,1) = VA(1,0) = 1;
230 cout <<
" A^-1: " << VA << endl;
235 A(0,0) = A(0,1) = A(1,0) = 1;
238 B(0,1) =
B(1,0) =
B(1,1) =
B(2,2) = 1.;
241 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2.;
242 cout <<
" C: " << C << endl;
248 cout <<
" (x+y)^T * (A+B+C) * (x+y): " << (A+
B+C).
product(x+y) << endl;
254 a[0] = 1.;
a[1] = 2.;
a[2] = 3.;
256 b[0] = 4.; b[1] = 5.; b[2] = 6.;
258 c[0] = 8.; c[1] = 9.; c[2] = 10.;
261 cout <<
"d: " <<
d << endl;
264 cout <<
"d: " <<
d << endl;
266 cout <<
"d -= b + c: " <<
d << endl;
267 cout <<
"dot(a,b): " <<
dot(
a,b) << endl;
268 cout <<
"dot(a+b,c+d): " <<
dot(
a+b,c+
d) << endl;
269 cout <<
"dot(a*b,c+d): " <<
dot(
a*b,c+
d) << endl;
270 cout <<
"dot(a*b+c,c+d): " <<
dot(
a*b+c,c+
d) << endl;
272 cout <<
"mag2(a) " <<
mag2(
a) << endl;
273 cout <<
"mag(a) " <<
mag(
a) << endl;
274 cout <<
"mag2(a+b+c)" <<
mag2(
a+b+c) << endl;
275 cout <<
"mag(a+b+c) " <<
mag(
a+b+c) << endl;
295 A(0,0) = A(1,1) = A(2,0) = A(2,2) = 5.;
298 cout <<
"C: " << endl << C << endl;
303 A(0,0) = A(1,1) = A(2,2) = 4.;
312 cout <<
" y: " << y << endl;
318 A(0,0) = A(1,1) = A(2,2) = 4.;
322 B(0,1) =
B(1,0) =
B(1,1) =
B(0,2) = 1.;
326 C(0,2) = C(1,2) = C(2,2) = 2.;
330 cout <<
"D: " << endl << D << endl;
333 cout <<
"E: " << endl << E << endl;
339 cout <<
" x: " << x << endl;
343 cout <<
" y: " << y << endl;
346 S(0,0) = S(1,0) = S(2,0) = 1.;
347 cout <<
" S: " << endl << S << endl;
349 cout <<
" C: " << endl << C << endl;
353 A(0,0) = A(0,1) = A(1,0) = 1;
358 cout <<
"Determinant: " << det << endl;
359 cout <<
"A again: " << endl << A << endl;
362 cout <<
"A^-1: " << endl << A << endl;
367 cout <<
"x: " << x << endl;
368 cout <<
" x^T * A * x: " <<
product(x+1,A+1) << endl;
372 cout <<
"B: " << endl <<
B << endl;
374 cout <<
"A/=B: " << endl << A << endl;
377 cout <<
"y: " << y << endl;
379 cout <<
"y/=x: " << y << endl;
385 A(0,0) = A(0,1) = A(1,0) = 1;
386 A(1,1) = A(2,2) = 3.;
389 B(0,1) =
B(1,0) =
B(1,1) =
B(2,2) = 1.;
393 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2.;
394 C(0,0) = C(1,1) = C(2,2) = 3;
401 cout <<
" (x+y)^T * (A+B+C) * (x+y): " <<
product(A+
B+C,x+y) << endl;
409 cout <<
"x: " << x << endl;
416 cout <<
"A: " << endl << A << endl;
424 cout <<
"x: " << x << endl;
434 cout <<
"A: " << endl << A << endl;
440 B(0,0) =
B(1,1) = 2.;
442 cout <<
"A: " << A << endl;
447 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2.;
448 C(0,0) = C(1,1) = C(2,2) = 3;
453 cout <<
"Dfact(C): " << det << endl;
454 cout <<
"C after: " << endl << C << endl;
459 C(0,1) = C(1,0) = C(2,1) = C(0,2) = C(3,1) = C(2,3) = 2.;
460 C(0,0) = C(1,1) = C(2,2) = C(3,3) = 3;
463 Dinv<SMatrix<float,4>,4,4>(C);
464 cout <<
"C after: " << endl << C << endl;
467 cout <<
"D = B * C: " << endl << D << endl;
472 C(0,0) = C(1,1) = C(0,1) = 5.;
475 cout <<
" C: " << endl << C << endl;
477 cout <<
"C after: " << endl << C << endl;
479 cout <<
" D: " << endl << D << endl;
480 }
else { cerr <<
" inversion failed! " << endl; }
485 C(0,1) = C(1,1) = C(0,2) = C(2,2) = 5.;
488 cout <<
" C: " << endl << C << endl;
490 cout <<
"C after: " << endl << C << endl;
492 cout <<
"D: " << endl << D << endl;
493 }
else { cerr <<
" inversion failed! " << endl; }
498 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2;
501 C(0,0) = C(1,1) = C(2,2) = C(3,3) = 3;
505 cout <<
" C: " << endl << C << endl;
508 cout <<
"C after: " << endl << C << endl;
510 cout.setf(ios::fixed);
511 cout <<
"D: " << endl << D << endl;
512 }
else { cerr <<
" inversion failed! " << endl; }
514 cout <<
"C+B: " << endl << C+
B << endl;
Expr< BinaryOp< MulOp< T >, SMatrix< T, D, D2 >, SMatrix< T, D, D2 >, T >, T, D, D2 > times(const SMatrix< T, D, D2 > &lhs, const SMatrix< T, D, D2 > &rhs)
Definition: BinaryOperators.hh:533
T mag(const SVector< T, D > &rhs)
Definition: Functions.hh:216
SVector< T, 3 > cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Definition: Functions.hh:283
T dot(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Definition: Functions.hh:132
SVector< T, D > unit(const SVector< T, D > &rhs)
Definition: Functions.hh:341
T mag2(const SVector< T, D > &rhs)
Definition: Functions.hh:195
T product(const SMatrix< T, D > &lhs, const SVector< T, D > &rhs)
Definition: MatrixFunctions.hh:451
void d()
Definition: RecDispEX.C:381
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
void a()
Definition: check_aligned.C:59
Definition: SMatrix.hh:53
SMatrix< T, D1, D2 > & place_in_col(const SVector< T, D > &rhs, const unsigned int row, const unsigned int col)
place a vector in a Matrix column
SVector< T, D1 > col(const unsigned int thecol) const
return a Matrix column as a vector
bool invert()
invert square Matrix via Dinv
bool sinvert()
invert symmetric, pos. def. Matrix via Dsinv
SMatrix< T, D1, D2 > & place_in_row(const SVector< T, D > &rhs, const unsigned int row, const unsigned int col)
place a vector in a Matrix row
SVector< T, D2 > row(const unsigned int therow) const
return a Matrix row as a vector
SMatrix< T, D1, D2 > & place_at(const SMatrix< T, D3, D4 > &rhs, const unsigned int row, const unsigned int col)
place a matrix in this matrix
Definition: SVector.hh:51
SVector< T, D > & place_at(const SVector< T, D2 > &rhs, const unsigned int row)
place a sub-vector starting at <row>