Changeset 583 for library/tests/test_kalman.cpp
- Timestamp:
- 08/27/09 15:39:31 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
library/tests/test_kalman.cpp
r565 r583 61 61 KalmanCh KF; 62 62 KF.set_parameters ( A, B, C, D, chmat ( R ), chmat ( Q ) ); 63 KF.set_ est( mu0, chmat ( P0 ) ); //prediction!63 KF.set_statistics ( mu0, chmat ( P0 ) ); //prediction! 64 64 const epdf& KFep = KF.posterior(); 65 65 mat Xt ( dimx, Ndat ); 66 66 Xt.set_col ( 0, KFep.mean() ); 67 67 68 //69 // FSQMAT70 Kalman<ldmat> KFf;71 KFf.set_parameters ( A, B, C, D, ldmat ( R ), ldmat ( Q ) );72 KFf.set_est ( mu0, ldmat ( P0 ) );73 const epdf& KFfep = KFf.posterior();74 mat Xtf ( dimx, Ndat );75 Xtf.set_col ( 0, KFfep.mean() );76 77 68 // FULL 78 KalmanFull KF2 ( A, B, C, D, R, Q, P0, mu0 ); 69 KalmanFull KF2; 70 KF2.set_parameters( A, B, C, D, R, Q); 71 KF2.set_statistics( mu0, P0 ); 79 72 mat Xt2 ( dimx, Ndat ); 80 73 Xt2.set_col ( 0, mu0 ); … … 86 79 EKFCh KFE; 87 80 KFE.set_parameters ( fxu, hxu, Q, R ); 88 KFE.set_ est( mu0, chmat ( P0 ) );81 KFE.set_statistics ( mu0, chmat ( P0 ) ); 89 82 const epdf& KFEep = KFE.posterior(); 90 83 mat XtE ( dimx, Ndat ); … … 93 86 //test performance of each filter 94 87 Real_Timer tt; 95 vec exec_times ( 4 ); // KF, KFfKF2, KFE88 vec exec_times ( 3 ); // KF, KF2, KFE 96 89 97 90 tt.tic(); … … 104 97 tt.tic(); 105 98 for ( int t = 1; t < Ndat; t++ ) { 106 KF f.bayes ( Dt.get_col ( t ) );107 Xt f.set_col ( t, KFfep.mean() );99 KF2.bayes ( Dt.get_col ( t ) ); 100 Xt2.set_col ( t, KF2.posterior().mean() ); 108 101 } 109 102 exec_times ( 1 ) = tt.toc(); 110 111 tt.tic();112 for ( int t = 1; t < Ndat; t++ ) {113 KF2.bayes ( Dt.get_col ( t ) );114 Xt2.set_col ( t, KF2.mu );115 }116 exec_times ( 2 ) = tt.toc();117 103 118 104 tt.tic(); … … 121 107 XtE.set_col ( t, KFEep.mean() ); 122 108 } 123 exec_times ( 3) = tt.toc();109 exec_times ( 2 ) = tt.toc(); 124 110 125 111 126 112 it_file fou ( "testKF_res.it" ); 127 113 fou << Name ( "xth" ) << Xt; 128 fou << Name ( "xthf" ) << Xtf;129 114 fou << Name ( "xth2" ) << Xt2; 130 115 fou << Name ( "xthE" ) << XtE;