Show
Ignore:
Timestamp:
06/09/10 14:00:40 (14 years ago)
Author:
mido
Message:

astyle applied all over the library

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • library/tests/stresssuite/kalman_stress.cpp

    r722 r1064  
    1010 
    1111TEST ( kalman_stress ) { 
    12         // Kalman filter 
    13         mat A, B, C, D, R, Q, P0; 
    14         vec mu0; 
    15         mat Mu0;; 
    16         // input from Matlab 
    17         it_file fin ( "kalman_stress.it" ); 
     12    // Kalman filter 
     13    mat A, B, C, D, R, Q, P0; 
     14    vec mu0; 
     15    mat Mu0;; 
     16    // input from Matlab 
     17    it_file fin ( "kalman_stress.it" ); 
    1818 
    19         mat Dt; 
    20         int Ndat; 
     19    mat Dt; 
     20    int Ndat; 
    2121 
    22         bool xxx = fin.seek ( "d" ); 
    23         if ( !xxx ) { 
    24                 bdm_error ( "kalman_stress.it not found" ); 
    25         } 
    26         fin >> Dt; 
    27         fin.seek ( "A" ); 
    28         fin >> A; 
    29         fin.seek ( "B" ); 
    30         fin >> B; 
    31         fin.seek ( "C" ); 
    32         fin >> C; 
    33         fin.seek ( "D" ); 
    34         fin >> D; 
    35         fin.seek ( "R" ); 
    36         fin >> R; 
    37         fin.seek ( "Q" ); 
    38         fin >> Q; 
    39         fin.seek ( "P0" ); 
    40         fin >> P0; 
    41         fin.seek ( "mu0" ); 
    42         fin >> Mu0; 
    43         mu0 = Mu0.get_col ( 0 ); 
     22    bool xxx = fin.seek ( "d" ); 
     23    if ( !xxx ) { 
     24        bdm_error ( "kalman_stress.it not found" ); 
     25    } 
     26    fin >> Dt; 
     27    fin.seek ( "A" ); 
     28    fin >> A; 
     29    fin.seek ( "B" ); 
     30    fin >> B; 
     31    fin.seek ( "C" ); 
     32    fin >> C; 
     33    fin.seek ( "D" ); 
     34    fin >> D; 
     35    fin.seek ( "R" ); 
     36    fin >> R; 
     37    fin.seek ( "Q" ); 
     38    fin >> Q; 
     39    fin.seek ( "P0" ); 
     40    fin >> P0; 
     41    fin.seek ( "mu0" ); 
     42    fin >> Mu0; 
     43    mu0 = Mu0.get_col ( 0 ); 
    4444 
    45         Ndat = Dt.cols(); 
    46         int dimx = A.rows(); 
     45    Ndat = Dt.cols(); 
     46    int dimx = A.rows(); 
    4747 
    48         // Prepare for Kalman filters in BDM: 
    49         RV rx ( "{x }", vec_1 ( A.cols() ) ); 
    50         RV ru ( "{u }", vec_1 ( B.cols() ) ); 
    51         RV ry ( "{y }", vec_1 ( C.rows() ) ); 
     48    // Prepare for Kalman filters in BDM: 
     49    RV rx ( "{x }", vec_1 ( A.cols() ) ); 
     50    RV ru ( "{u }", vec_1 ( B.cols() ) ); 
     51    RV ry ( "{y }", vec_1 ( C.rows() ) ); 
    5252 
    5353//      // LDMAT 
     
    5959//      Xt.set_col( 0,KFep.mean() ); 
    6060 
    61         //Chol 
    62         KalmanCh KF; 
    63         KF.set_parameters ( A, B, C, D, chmat ( Q ), chmat ( R ) ); 
    64         KF.set_statistics ( mu0, chmat ( P0 ) ); //prediction! 
    65         KF.set_evalll ( false ); 
    66         KF.validate(); 
    67         const epdf& KFep = KF.posterior(); 
    68         mat Xt ( dimx, Ndat ); 
    69         Xt.set_col ( 0, KFep.mean() ); 
     61    //Chol 
     62    KalmanCh KF; 
     63    KF.set_parameters ( A, B, C, D, chmat ( Q ), chmat ( R ) ); 
     64    KF.set_statistics ( mu0, chmat ( P0 ) ); //prediction! 
     65    KF.set_evalll ( false ); 
     66    KF.validate(); 
     67    const epdf& KFep = KF.posterior(); 
     68    mat Xt ( dimx, Ndat ); 
     69    Xt.set_col ( 0, KFep.mean() ); 
    7070 
    71         // FULL 
    72         KalmanFull KF2; 
    73         KF2.set_parameters ( A, B, C, D,  Q, R ); 
    74         KF2.set_statistics ( mu0, P0 ); 
    75         KF2.set_evalll ( false ); 
    76         KF2.validate(); 
    77         mat Xt2 ( dimx, Ndat ); 
    78         Xt2.set_col ( 0, mu0 ); 
     71    // FULL 
     72    KalmanFull KF2; 
     73    KF2.set_parameters ( A, B, C, D,  Q, R ); 
     74    KF2.set_statistics ( mu0, P0 ); 
     75    KF2.set_evalll ( false ); 
     76    KF2.validate(); 
     77    mat Xt2 ( dimx, Ndat ); 
     78    Xt2.set_col ( 0, mu0 ); 
    7979 
    8080 
    81         // EKF 
    82         shared_ptr<bilinfn> fxu = new bilinfn ( A, B ); 
    83         shared_ptr<bilinfn> hxu = new bilinfn ( C, D ); 
    84         EKFCh KFE; 
    85         KFE.set_parameters ( fxu, hxu, Q, R ); 
    86         KFE.set_statistics ( mu0, chmat ( P0 ) ); 
    87         KFE.set_evalll ( false ); 
    88         KFE.validate(); 
    89         const epdf& KFEep = KFE.posterior(); 
    90         mat XtE ( dimx, Ndat ); 
    91         XtE.set_col ( 0, KFEep.mean() ); 
     81    // EKF 
     82    shared_ptr<bilinfn> fxu = new bilinfn ( A, B ); 
     83    shared_ptr<bilinfn> hxu = new bilinfn ( C, D ); 
     84    EKFCh KFE; 
     85    KFE.set_parameters ( fxu, hxu, Q, R ); 
     86    KFE.set_statistics ( mu0, chmat ( P0 ) ); 
     87    KFE.set_evalll ( false ); 
     88    KFE.validate(); 
     89    const epdf& KFEep = KFE.posterior(); 
     90    mat XtE ( dimx, Ndat ); 
     91    XtE.set_col ( 0, KFEep.mean() ); 
    9292 
    93         //test performance of each filter 
    94         Real_Timer tt; 
    95         vec exec_times ( 3 ); // KF, KF2, KFE 
     93    //test performance of each filter 
     94    Real_Timer tt; 
     95    vec exec_times ( 3 ); // KF, KF2, KFE 
    9696 
    97         vec dt; 
    98         tt.tic(); 
    99         for ( int t = 1; t < Ndat; t++ ) { 
    100                 dt = Dt.get_col ( t ); 
    101                 KF.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
    102                 Xt.set_col ( t, KFep.mean() ); 
    103         } 
    104         exec_times ( 0 ) = tt.toc(); 
     97    vec dt; 
     98    tt.tic(); 
     99    for ( int t = 1; t < Ndat; t++ ) { 
     100        dt = Dt.get_col ( t ); 
     101        KF.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
     102        Xt.set_col ( t, KFep.mean() ); 
     103    } 
     104    exec_times ( 0 ) = tt.toc(); 
    105105 
    106         tt.tic(); 
    107         for ( int t = 1; t < Ndat; t++ ) { 
    108                 dt = Dt.get_col ( t ); 
    109                 KF2.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
    110                 Xt2.set_col ( t, KF2.posterior().mean() ); 
    111         } 
    112         exec_times ( 1 ) = tt.toc(); 
     106    tt.tic(); 
     107    for ( int t = 1; t < Ndat; t++ ) { 
     108        dt = Dt.get_col ( t ); 
     109        KF2.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
     110        Xt2.set_col ( t, KF2.posterior().mean() ); 
     111    } 
     112    exec_times ( 1 ) = tt.toc(); 
    113113 
    114         tt.tic(); 
    115         for ( int t = 1; t < Ndat; t++ ) { 
    116                 dt = Dt.get_col ( t ); 
    117                 KFE.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
    118                 XtE.set_col ( t, KFEep.mean() ); 
    119         } 
    120         exec_times ( 2 ) = tt.toc(); 
     114    tt.tic(); 
     115    for ( int t = 1; t < Ndat; t++ ) { 
     116        dt = Dt.get_col ( t ); 
     117        KFE.bayes ( dt.get ( 0, C.rows() - 1 ), dt.get ( C.rows(), dt.length() - 1 ) ); 
     118        XtE.set_col ( t, KFEep.mean() ); 
     119    } 
     120    exec_times ( 2 ) = tt.toc(); 
    121121 
    122122 
    123         it_file fou ( "kalman_stress_res.it" ); 
    124         fou << Name ( "xth" ) << Xt; 
    125         fou << Name ( "xth2" ) << Xt2; 
    126         fou << Name ( "xthE" ) << XtE; 
    127         fou << Name ( "exec_times" ) << exec_times; 
     123    it_file fou ( "kalman_stress_res.it" ); 
     124    fou << Name ( "xth" ) << Xt; 
     125    fou << Name ( "xth2" ) << Xt2; 
     126    fou << Name ( "xthE" ) << XtE; 
     127    fou << Name ( "exec_times" ) << exec_times; 
    128128}