13 {
14
15#ifdef XXX
18 cout << "x: " << x << endl;
19 cout << "y: " << y << endl;
20
23
27 cout << "A: " << endl << A << endl;
28
29 return 0;
30#endif
31
32#ifdef XXX
34 A(0,0) = A(1,0) = 1;
35 A(0,1) = 3;
36 A(1,1) = A(2,2) = 2;
37 cout << "A: " << endl << A << endl;
38
40 cout << "x: " << x << endl;
41
43 cout << "y: " << y << endl;
44
45 return 0;
46#endif
47
48#ifdef XXX1
50 A(0,0) = A(0,1) = A(1,0) = 1;
51 A(1,1) = A(2,2) = 2;
52
54 cout << "A: " << endl << A << endl;
55
56
57
58
59
60
61
63 cout << "A^-1: " << endl << A << endl;
64
65
66 cout << "A^-1 * B: " << endl << A * B << endl;
67
68 return 0;
69#endif
70
71#ifdef XXX
73 A(0,0) = A(0,1) = A(1,0) = 1;
74 A(1,1) = A(2,2) = 2;
75 cout << " A: " << endl << A << endl;
76
78 cout << "x: " << x << endl;
79
80
81 cout <<
" (x+1)^T * (A+1) * (x+1): " <<
product(x+1,A+1) << endl;
82
83 return 0;
84#endif
85
86#ifdef XXX
88 A(0,0) = A(0,1) = A(1,1) = A(2,2) = 4.;
89 A(2,3) = 1.;
90 cout << "A: " << endl << A << endl;
92 cout << " x: " << x << endl;
94 cout <<
" a: " <<
a << endl;
96
97 cout << " y: " << y << endl;
98
100 cout << " b: " << b << endl;
101
102 return 0;
103#endif
104
105#ifdef XXX
107 A(0,0) = A(0,1) = A(1,1) = A(2,0) = A(3,1) = 4.;
108 cout << "A: " << endl << A << endl;
109
111 S(0,0) = S(0,1) = S(1,1) = S(0,2) = 1.;
112 cout << " S: " << endl << S << endl;
113
115 cout << " C: " << endl << C << endl;
116
117 return 0;
118#endif
119
120#ifdef XXX
124
125
126 cout <<
"x * y: " << endl <<
times(x, -y) << endl;
127
128 x += z - y;
129 cout << "x += z - y: " << endl << x << endl;
130
131
132 cout << "sqrt(z): " << endl << sqrt(z) << endl;
133
134
135 cout << "2 * y: " << endl << 2 * y << endl;
136
137
138 cout <<
"fabs(-z + 3*x): " << endl <<
fabs(-z + 3*x) << endl;
139
140 return 0;
141#endif
142
143#ifdef XXX
145 A(0,0) = A(1,1) = A(0,2) = 5.;
146
147 cout << "A: " << endl << A << endl;
148
151
152 cout <<
"dot(x,y): " <<
dot(x,y) << endl;
153
154 cout <<
"mag(x): " <<
mag(x) << endl;
155
156 cout <<
"cross(x,y): " <<
cross(x,y) << endl;
157
158 cout <<
"unit(x): " <<
unit(x) << endl;
159
161 cout << "x + y: " << x+y << endl;
162
163 cout << "x * y: " << x * -y << endl;
164 x += z - y;
165 cout << "x += z - y: " << x << endl;
166
167
168 cout << "sqrt(z): " << sqrt(z) << endl;
169
170
171 cout << "2 * y: " << 2 * y << endl;
172
173
174 cout <<
"fabs(-z + 3*x): " <<
fabs(-z + 3*x) << endl;
175
179 cout <<
"a: " <<
a << endl;
180#endif
181
182 for(unsigned int i=0; i<1000000; ++i) {
183#ifdef XXX
184 VtVector
a(1.,2.,3.);
185 VtVector b(4.,5.,6.);
186 VtVector c(8.,9.,10.);
187
188 VtVector
d =
a*(-1) + b;
189 VtVector
d =
a + b + c;
190#endif
191#ifdef XXX
192 VtMatrix A(4,3);
193 A(0,0) = A(1,1) = A(2,2) = 4.;
194 A(2,3) = 1.;
196
197
198
199
200
202 cout << " y: " << y << endl;
203 exit(0);
204#endif
205#ifdef XXX
206
207 VtMatrix A(3,3);
208 A(0,0) = A(1,1) = A(2,2) = 4.;
209
210
211 VtMatrix B(3,3);
212 B(0,1) = B(1,0) = B(1,1) = B(0,2) = 1.;
213
214
215 VtMatrix C(3,3);
216 C(0,2) = C(1,2) = C(2,2) = 2.;
217
218
219 VtMatrix D = A + B + C + A + B + C;
220 cout << " D: " << D << endl;
221 exit(0);
222#endif
223#ifdef XXX
224 VtSymMatrix VA(3,2.);
225 VA(0,0) = VA(0,1) = VA(1,0) = 1;
226
227
228 VA.det();
229 VA.VtDsinv();
230 cout << " A^-1: " << VA << endl;
231#endif
232#ifdef XXX
233
234 VtSymMatrix A(3,3.);
235 A(0,0) = A(0,1) = A(1,0) = 1;
236
237 VtSymMatrix B(3,3);
238 B(0,1) = B(1,0) = B(1,1) = B(2,2) = 1.;
239
240 VtSymMatrix C(3,3);
241 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2.;
242 cout << " C: " << C << endl;
243 VtVector x(1,2,3);
244
245 VtVector y(4,5,6);
246
248 cout <<
" (x+y)^T * (A+B+C) * (x+y): " << (A+B+C).
product(x+y) << endl;
249 exit(0);
250#endif
251#ifdef XXX
252
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.;
259
261 cout <<
"d: " <<
d << endl;
262 exit(0);
263
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;
271
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;
276
277
278
279
280
281
284
285
286
287
288
289
290
291
292
295 A(0,0) = A(1,1) = A(2,0) = A(2,2) = 5.;
297
298 cout << "C: " << endl << C << endl;
299#endif
300
301#ifdef XXX
303 A(0,0) = A(1,1) = A(2,2) = 4.;
304 A(2,3) = 1.;
305
307
309
311
312 cout << " y: " << y << endl;
313 exit(0);
314#endif
315#ifdef XXX
316
318 A(0,0) = A(1,1) = A(2,2) = 4.;
319
320
322 B(0,1) = B(1,0) = B(1,1) = B(0,2) = 1.;
323
324
326 C(0,2) = C(1,2) = C(2,2) = 2.;
327
328
330 cout << "D: " << endl << D << endl;
331 exit(0);
333 cout << "E: " << endl << E << endl;
334
335#endif
336
337#ifdef XXX
339 cout << " x: " << x << endl;
340
341
343 cout << " y: " << y << endl;
344
346 S(0,0) = S(1,0) = S(2,0) = 1.;
347 cout << " S: " << endl << S << endl;
349 cout << " C: " << endl << C << endl;
350#endif
351#ifdef XXX
353 A(0,0) = A(0,1) = A(1,0) = 1;
354 A(1,1) = A(2,2) = 2;
355
356 double det = 0.;
358 cout << "Determinant: " << det << endl;
359 cout << "A again: " << endl << A << endl;
360 exit(0);
362 cout << "A^-1: " << endl << A << endl;
363 exit(0);
364#endif
365#ifdef XXX
367 cout << "x: " << x << endl;
368 cout <<
" x^T * A * x: " <<
product(x+1,A+1) << endl;
369
370
372 cout << "B: " << endl << B << endl;
373 A /= B + 1;
374 cout << "A/=B: " << endl << A << endl;
375
377 cout << "y: " << y << endl;
378 y /= x;
379 cout << "y/=x: " << y << endl;
380 exit(0);
381#endif
382#ifdef XXX
383
385 A(0,0) = A(0,1) = A(1,0) = 1;
386 A(1,1) = A(2,2) = 3.;
387
389 B(0,1) = B(1,0) = B(1,1) = B(2,2) = 1.;
390 B(0,0) = 3;
391
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;
395
397
399
401 cout <<
" (x+y)^T * (A+B+C) * (x+y): " <<
product(A+B+C,x+y) << endl;
402 exit(0);
403#endif
404#ifdef XXX
407
409 cout << "x: " << x << endl;
412
413
414
416 cout << "A: " << endl << A << endl;
417 exit(0);
418#endif
419#ifdef XXX
420 VtVector x(4);
421 VtVector y(1,2);
422
424 cout << "x: " << x << endl;
425 exit(0);
426#endif
427#ifdef XXX
430
431
432
434 cout << "A: " << endl << A << endl;
435 exit(0);
436#endif
437#ifdef XXX
438 VtMatrix A(4,3);
439 VtMatrix B(2,2);
440 B(0,0) = B(1,1) = 2.;
442 cout << "A: " << A << endl;
443 exit(0);
444#endif
445#ifdef XXX
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;
449
450 float det = 0.;
451
453 cout << "Dfact(C): " << det << endl;
454 cout << "C after: " << endl << C << endl;
455 exit(0);
456#endif
457#ifdef XXX
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;
461
462
463 Dinv<SMatrix<float,4>,4,4>(C);
464 cout << "C after: " << endl << C << endl;
466
467 cout << "D = B * C: " << endl << D << endl;
468 exit(0);
469#endif
470#ifdef XXX
472 C(0,0) = C(1,1) = C(0,1) = 5.;
473 C(1,0) = 1;
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; }
481 exit(0);
482#endif
483#ifdef XXX
485 C(0,1) = C(1,1) = C(0,2) = C(2,2) = 5.;
486 C(0,0) = 10;
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; }
494 exit(0);
495#endif
496#ifdef XXX
498 C(0,1) = C(1,0) = C(2,1) = C(0,2) = 2;
499 C(3,1) = 2;
500 C(2,3) = 2.;
501 C(0,0) = C(1,1) = C(2,2) = C(3,3) = 3;
502
503
505 cout << " C: " << endl << C << endl;
506
508 cout << "C after: " << endl << C << endl;
510 cout.setf(ios::fixed);
511 cout << "D: " << endl << D << endl;
512 } else { cerr << " inversion failed! " << endl; }
513
514 cout << "C+B: " << endl << C+B << endl;
515 exit(0);
516#endif
517 }
518
519 return 0;
520}
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
T dot(const SVector< T, D > &lhs, const SVector< T, D > &rhs)
Definition: Functions.hh:132
SVector< T, 3 > cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Definition: Functions.hh:283
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_at(const SMatrix< T, D3, D4 > &rhs, const unsigned int row, const unsigned int col)
place a matrix in this matrix
bool invert()
invert square Matrix via Dinv
SVector< T, D2 > row(const unsigned int therow) const
return a Matrix row as a vector
bool sinvert()
invert symmetric, pos. def. Matrix via Dsinv
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
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, D1 > col(const unsigned int thecol) const
return a Matrix column as a vector
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>