2 mat-test.cc -- test Matrix
4 source file of the Flower Library
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
12 #include "flower-test.hh"
13 #include "choleski.hh"
19 Matrix
m(N
,N
), q(N
,N
);
22 for (int i
=0; i
< N
; i
++) {
24 for (int j
=0; j
< N
; j
++) {
26 q(i
,j
) = (abs(i
-j
) > 3) ?0 :i
-j
;
30 cout
<< "v: " << String(v
);
31 cout
<< "m: " << String(m
);
32 cout
<< "q: " << String(q
);
33 cout
<< "m*q; " << String(m
*q
);
34 cout
<< "m*m: " << String(m
*m
);
36 cout
<< "m: " << String(m
);
37 cout
<< "q.band " << q
.band_i() << endl
;
39 cout
<< "q(B): " << q
;
42 cout
<< "q + q " << sum
;
44 cout
<< "q*q: " << q
*q
;
47 Matrix
hilbert(N
,N
), h2(hilbert
);
48 for (int i
=0; i
< N
; i
++) {
49 for (int j
=0; j
< N
; j
++) {
50 hilbert(i
,j
) = 1/Real(i
+j
+1);
51 h2 (i
,j
) = (abs(i
-j
) > 3) ?0 : hilbert(i
,j
);
55 Choleski_decomposition
ch(h2
);
56 cout
<< "red Hilbert " << h2
;
57 cout
<< "choleski " << ch
.L
;
58 Matrix T
=ch
.L
.transposed();
60 cout
<< "L * L^T" << ch
.L
* T
;
61 cout
<< "H2^{-1} * H2" << h2
* ch
.inverse();