Revision 82, 1.2 kB
(checked in by smidl, 17 years ago)
|
testy ld chmat a ui
|
-
Property svn:eol-style set to
native
|
Line | |
---|
1 | #include <itpp/itbase.h> |
---|
2 | #include <math/chmat.h> |
---|
3 | |
---|
4 | using namespace itpp; |
---|
5 | |
---|
6 | //These lines are needed for use of cout and endl |
---|
7 | using std::cout; |
---|
8 | using std::endl; |
---|
9 | |
---|
10 | int main() { |
---|
11 | // Kalman filter |
---|
12 | mat A0 = randu(3,3); |
---|
13 | mat A = A0*A0.T(); |
---|
14 | |
---|
15 | //Test constructor |
---|
16 | chmat Ch(A); |
---|
17 | cout << "Testing constructors:" << endl |
---|
18 | << "A = " << A << endl |
---|
19 | << "Ch.to_mat() = " << Ch.to_mat() << endl << endl; |
---|
20 | |
---|
21 | //Test inversion |
---|
22 | chmat iCh(3); |
---|
23 | Ch.inv(iCh); |
---|
24 | cout << "inv(A) = " << inv(A) <<endl |
---|
25 | << "inv(Ch).to_mat() = " << iCh.to_mat() <<endl <<endl; |
---|
26 | |
---|
27 | //Test logdet |
---|
28 | cout << "logdet(A) = " << log(det(A)) << endl |
---|
29 | << "logdet(Ch) = " << Ch.logdet() << endl <<endl; |
---|
30 | |
---|
31 | //Test add |
---|
32 | chmat Ch2(Ch); |
---|
33 | Ch2.add(Ch); |
---|
34 | cout << "A+A = " << A+A << endl |
---|
35 | << "Ch2.add(Ch) = " << Ch2.to_mat() << endl <<endl; |
---|
36 | |
---|
37 | vec v=randu(3); |
---|
38 | //Test qform |
---|
39 | cout << "vAv' = " << v*(A*v) << endl |
---|
40 | << "qform(Ch,v) = " << Ch.qform(v) << endl <<endl; |
---|
41 | |
---|
42 | //Test invqform |
---|
43 | cout << "v inv(A)v' = " << v*(inv(A)*v) << endl |
---|
44 | << "invqform(Ch,v) = " << Ch.invqform(v) << endl <<endl; |
---|
45 | |
---|
46 | //Test opupdate |
---|
47 | Ch2=Ch; |
---|
48 | Ch2.opupdt(v,1.0); |
---|
49 | cout << "A+vv' = " << A+outer_product(v,v) << endl |
---|
50 | << "opupdt(Ch,v) = " << Ch2.to_mat() << endl <<endl; |
---|
51 | |
---|
52 | } |
---|