root/library/tests/ldmat_test.cpp @ 386

Revision 386, 1.2 kB (checked in by mido, 15 years ago)

possibly broken? 4th part

  • Property svn:eol-style set to native
Line 
1
2#include <math/square_mat.h>
3
4using namespace itpp;
5
6//These lines are needed for use of cout and endl
7using std::cout;
8using std::endl;
9
10int main() {
11        // Kalman filter
12        mat A0 = randu(3,3);
13        mat A = A0*A0.T();
14       
15        //Test constructor
16        ldmat LD(A);
17   cout << "Testing constructors:" << endl
18       << "A = " << A << endl
19       << "LD.to_mat() = " << LD.to_mat() << endl << endl;
20       
21   //Test inversion
22        ldmat iLD(3);
23        LD.inv(iLD);
24   cout << "inv(A) = " << inv(A) <<endl
25        << "inv(LD).to_mat() = " << iLD.to_mat() <<endl <<endl;
26       
27   //Test logdet
28   cout << "logdet(A) = " << log(det(A)) << endl
29                        << "logdet(LD) = " << LD.logdet() << endl <<endl;
30                               
31   //Test add
32   ldmat LD2(LD);
33   LD2.add(LD);
34   cout << "A+A = " << A+A << endl
35                        <<      "LD2.add(LD) = " << LD2.to_mat() << endl <<endl;
36                               
37        vec v=randu(3);
38   //Test qform
39   cout << "vAv' = " << v*(A*v) << endl
40                        <<      "qform(LD,v) = " << LD.qform(v) << endl <<endl;
41       
42   //Test invqform
43   cout << "v inv(A)v' = " << v*(inv(A)*v) << endl
44                        <<      "invqform(LD,v) = " << LD.invqform(v) << endl <<endl;
45                               
46   //Test opupdate
47   LD2=LD;
48   LD2.opupdt(v,1.0);
49   cout << "A+vv' = " << A+outer_product(v,v) << endl
50                        <<      "opupdt(LD,v) = " << LD2.to_mat() << endl <<endl;
51                               
52}
Note: See TracBrowser for help on using the browser.