Revision 384, 1.2 kB
(checked in by mido, 16 years ago)
|
possibly broken?
|
-
Property svn:eol-style set to
native
|
Rev | Line | |
---|
[262] | 1 | |
---|
[384] | 2 | #include "math/square_mat.h" |
---|
[87] | 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 | fsqmat Fsq(A); |
---|
| 17 | cout << "Testing constructors:" << endl |
---|
| 18 | << "A = " << A << endl |
---|
| 19 | << "Fsq.to_mat() = " << Fsq.to_mat() << endl << endl; |
---|
| 20 | |
---|
| 21 | //Test inversion |
---|
| 22 | fsqmat iFsq(3); |
---|
| 23 | Fsq.inv(iFsq); |
---|
| 24 | cout << "inv(A) = " << inv(A) <<endl |
---|
| 25 | << "inv(Fsq).to_mat() = " << iFsq.to_mat() <<endl <<endl; |
---|
| 26 | |
---|
| 27 | //Test logdet |
---|
| 28 | cout << "logdet(A) = " << log(det(A)) << endl |
---|
| 29 | << "logdet(Fsq) = " << Fsq.logdet() << endl <<endl; |
---|
| 30 | |
---|
| 31 | //Test add |
---|
| 32 | fsqmat Fsq2(Fsq); |
---|
| 33 | Fsq2.add(Fsq); |
---|
| 34 | cout << "A+A = " << A+A << endl |
---|
| 35 | << "Fsq2.add(Fsq) = " << Fsq2.to_mat() << endl <<endl; |
---|
| 36 | |
---|
| 37 | vec v=randu(3); |
---|
| 38 | //Test qform |
---|
| 39 | cout << "vAv' = " << v*(A*v) << endl |
---|
| 40 | << "qform(Fsq,v) = " << Fsq.qform(v) << endl <<endl; |
---|
| 41 | |
---|
| 42 | //Test invqform |
---|
| 43 | cout << "v inv(A)v' = " << v*(inv(A)*v) << endl |
---|
| 44 | << "invqform(Fsq,v) = " << Fsq.invqform(v) << endl <<endl; |
---|
| 45 | |
---|
| 46 | //Test opupdate |
---|
| 47 | Fsq2=Fsq; |
---|
| 48 | Fsq2.opupdt(v,1.0); |
---|
| 49 | cout << "A+vv' = " << A+outer_product(v,v) << endl |
---|
| 50 | << "opupdt(Fsq,v) = " << Fsq2.to_mat() << endl <<endl; |
---|
| 51 | |
---|
| 52 | } |
---|