Show
Ignore:
Timestamp:
11/13/09 16:11:31 (15 years ago)
Author:
mido
Message:

astyler run over all test sources
general_suite added
cleanup of \test directory finished

Location:
library/tests/testsuite
Files:
15 modified

Legend:

Unmodified
Added
Removed
  • library/tests/testsuite/LQG_test.cpp

    r717 r722  
    55using namespace bdm; 
    66 
    7 TEST(LQG_test) { 
     7TEST ( LQG_test ) { 
    88        LQG reg; 
    9         shared_ptr<StateSpace<fsqmat> > stsp=new StateSpace<fsqmat>; 
     9        shared_ptr<StateSpace<fsqmat> > stsp = new StateSpace<fsqmat>; 
    1010        // 2 x 1 x 1 
    11         stsp-> set_parameters(eye(2), ones(2,1), ones(1,2), ones(1,1), /* Q,R */ eye(2), eye(1)); 
    12         reg.set_system(stsp); // A, B, C 
    13         reg.set_control_parameters(eye(1), eye(1),  vec_1(1.0), 6); //Qy, Qu, horizon 
     11        stsp-> set_parameters ( eye ( 2 ), ones ( 2, 1 ), ones ( 1, 2 ), ones ( 1, 1 ), /* Q,R */ eye ( 2 ), eye ( 1 ) ); 
     12        reg.set_system ( stsp ); // A, B, C 
     13        reg.set_control_parameters ( eye ( 1 ), eye ( 1 ),  vec_1 ( 1.0 ), 6 ); //Qy, Qu, horizon 
    1414 
    1515        reg.redesign(); 
    16         double reg_apply=reg.ctrlaction("0.5, 1.1","0.0")(0); /*convert vec to double*/ 
    17         CHECK_CLOSE(reg_apply, -0.248528137234392, 0.0001); 
     16        double reg_apply = reg.ctrlaction ( "0.5, 1.1", "0.0" ) ( 0 ); /*convert vec to double*/ 
     17        CHECK_CLOSE ( reg_apply, -0.248528137234392, 0.0001 ); 
    1818} 
    1919 
    20 TEST(to_state_test) { 
     20TEST ( to_state_test ) { 
    2121        mlnorm<fsqmat> ml; 
    22         mat A="1.1, 2.3"; 
    23         ml.set_parameters(A, vec_1(1.3), eye(1)); 
    24         RV yr=RV("y",1); 
    25         RV ur=RV("u",1); 
    26         ml.set_rv(yr); 
    27         yr.t_plus(-1); 
    28         ml.set_rvc(concat(yr, ur)); 
    29          
    30         shared_ptr<StateCanonical > Stsp=new StateCanonical; 
    31         Stsp->connect_mlnorm(ml); 
    32          
    33         /* results from  
     22        mat A = "1.1, 2.3"; 
     23        ml.set_parameters ( A, vec_1 ( 1.3 ), eye ( 1 ) ); 
     24        RV yr = RV ( "y", 1 ); 
     25        RV ur = RV ( "u", 1 ); 
     26        ml.set_rv ( yr ); 
     27        yr.t_plus ( -1 ); 
     28        ml.set_rvc ( concat ( yr, ur ) ); 
     29 
     30        shared_ptr<StateCanonical > Stsp = new StateCanonical; 
     31        Stsp->connect_mlnorm ( ml ); 
     32 
     33        /* results from 
    3434        [A,B,C,D]=tf2ss([2.3 0],[1 -1.1]) 
    3535        */ 
    36         CHECK_CLOSE_EX(Stsp->_A().get_row(0), vec("1.1"), 0.0001); 
    37         CHECK_CLOSE_EX(Stsp->_C().get_row(0), vec("2.53"), 0.0001); 
    38         CHECK_CLOSE_EX(Stsp->_D().get_row(0), vec("2.30"), 0.0001); 
     36        CHECK_CLOSE_EX ( Stsp->_A().get_row ( 0 ), vec ( "1.1" ), 0.0001 ); 
     37        CHECK_CLOSE_EX ( Stsp->_C().get_row ( 0 ), vec ( "2.53" ), 0.0001 ); 
     38        CHECK_CLOSE_EX ( Stsp->_D().get_row ( 0 ), vec ( "2.30" ), 0.0001 ); 
    3939} 
    4040 
    41 TEST(to_state_arx_test) { 
     41TEST ( to_state_arx_test ) { 
    4242        mlnorm<fsqmat> ml; 
    43         mat A="1.1, 2.3"; 
    44         ml.set_parameters(A, vec_1(1.3), eye(1)); 
    45         RV yr=RV("y",1); 
    46         RV ur=RV("u",1); 
    47         ml.set_rv(yr); 
    48         yr.t_plus(-1); 
    49         ml.set_rvc(concat(yr, ur)); 
    50          
    51         shared_ptr<StateFromARX> Stsp=new StateFromARX; 
    52         Stsp->connect_mlnorm(ml); 
    53          
    54         /* results from  
     43        mat A = "1.1, 2.3"; 
     44        ml.set_parameters ( A, vec_1 ( 1.3 ), eye ( 1 ) ); 
     45        RV yr = RV ( "y", 1 ); 
     46        RV ur = RV ( "u", 1 ); 
     47        ml.set_rv ( yr ); 
     48        yr.t_plus ( -1 ); 
     49        ml.set_rvc ( concat ( yr, ur ) ); 
     50 
     51        shared_ptr<StateFromARX> Stsp = new StateFromARX; 
     52        Stsp->connect_mlnorm ( ml ); 
     53 
     54        /* results from 
    5555        [A,B,C,D]=tf2ss([2.3 0],[1 -1.1]) 
    5656        */ 
     
    5858} 
    5959 
    60 TEST(arx_LQG_test){ 
     60TEST ( arx_LQG_test ) { 
    6161        mlnorm<fsqmat> ml; 
    62         mat A="1.81, -.8189, .00468, .00438"; 
    63         ml.set_parameters(A, vec_1(0.0), 0.00001*eye(1)); 
    64         RV yr=RV("y",1); 
    65         RV ur=RV("u",1); 
    66         RV rgr = yr.copy_t(-1); 
    67         rgr.add(yr.copy_t(-2)); 
    68         rgr.add(yr.copy_t(-2)); 
    69         rgr.add(ur.copy_t(-2)); 
    70         rgr.add(ur.copy_t(-1)); 
    71          
    72         ml.set_rv(yr); 
    73         ml.set_rvc(rgr); 
     62        mat A = "1.81, -.8189, .00468, .00438"; 
     63        ml.set_parameters ( A, vec_1 ( 0.0 ), 0.00001*eye ( 1 ) ); 
     64        RV yr = RV ( "y", 1 ); 
     65        RV ur = RV ( "u", 1 ); 
     66        RV rgr = yr.copy_t ( -1 ); 
     67        rgr.add ( yr.copy_t ( -2 ) ); 
     68        rgr.add ( yr.copy_t ( -2 ) ); 
     69        rgr.add ( ur.copy_t ( -2 ) ); 
     70        rgr.add ( ur.copy_t ( -1 ) ); 
     71 
     72        ml.set_rv ( yr ); 
     73        ml.set_rvc ( rgr ); 
    7474        ml.validate(); 
    75          
    76         shared_ptr<StateCanonical > Stsp=new StateCanonical; 
    77         Stsp->connect_mlnorm(ml); 
    78          
     75 
     76        shared_ptr<StateCanonical > Stsp = new StateCanonical; 
     77        Stsp->connect_mlnorm ( ml ); 
     78 
    7979        LQG L; 
    80         L.set_system(Stsp); 
    81         L.set_control_parameters(eye(1), eye(1), vec_1(0.0), 100); 
     80        L.set_system ( Stsp ); 
     81        L.set_control_parameters ( eye ( 1 ), eye ( 1 ), vec_1 ( 0.0 ), 100 ); 
    8282        L.validate(); 
    83          
     83 
    8484        L.redesign(); 
    85         cout << L.to_string()<<endl; 
     85        cout << L.to_string() << endl; 
    8686} 
  • library/tests/testsuite/arx_straux_test.cpp

    r717 r722  
    88        UIFile F ( "arx_straux_test.cfg" ); 
    99 
    10         Setting &tests=F.getRoot() ["tests"]; 
    11         for ( int i=0;i<tests.getLength(); i++ ) { 
     10        Setting &tests = F.getRoot() ["tests"]; 
     11        for ( int i = 0; i < tests.getLength(); i++ ) { 
    1212                mat A; 
    1313                mat B; 
    1414                ivec o1_ok; 
    15                 UI::get ( A,tests[i],"A",UI::compulsory ); 
    16                 UI::get ( B,tests[i],"B",UI::compulsory ); 
    17                 UI::get ( o1_ok,tests[i],"o1",UI::compulsory ); 
     15                UI::get ( A, tests[i], "A", UI::compulsory ); 
     16                UI::get ( B, tests[i], "B", UI::compulsory ); 
     17                UI::get ( o1_ok, tests[i], "o1", UI::compulsory ); 
    1818 
    1919//when updateing matrices do not forget to update CHECK_EQUAL below!!! 
    2020 
    21                 ldmat Ld0 ( 3 ); Ld0.ldform ( A,ones ( A.rows() ) ); 
    22                 ldmat Ld1 ( 3 ); Ld1.ldform ( A+B,ones ( A.rows() ) ); 
     21                ldmat Ld0 ( 3 ); 
     22                Ld0.ldform ( A, ones ( A.rows() ) ); 
     23                ldmat Ld1 ( 3 ); 
     24                Ld1.ldform ( A + B, ones ( A.rows() ) ); 
    2325 
    2426 
     
    2729                int nrep = 5;         // nrep: number of random repetions of structure estimation 
    2830                double lambda   = 0.9; 
    29                 int k=2; 
     31                int k = 2; 
    3032 
    3133//[strout, rgrsout, statistics] = 
     
    3335//          order_k); 
    3436                Array<str_aux> o2; 
    35                 ivec o1 = straux1 ( Ld1,20, Ld0, 10,  belief, nbest, nrep, lambda, k, o2 ); 
     37                ivec o1 = straux1 ( Ld1, 20, Ld0, 10,  belief, nbest, nrep, lambda, k, o2 ); 
    3638 
    3739//o1 is messed up in matlab's straux 
  • library/tests/testsuite/datalink_test.cpp

    r717 r722  
    9191        RV a = RV ( "{dl_a }" ); 
    9292        RV b = RV ( "{dlb }" ); 
    93         RV ab=concat(a,b); 
     93        RV ab = concat ( a, b ); 
    9494        RV aa = a; 
    95         a.t_plus(-1); 
    96         aa.add(a);  
     95        a.t_plus ( -1 ); 
     96        aa.add ( a ); 
    9797 
    98          
     98 
    9999        datalink_buffered dl; 
    100         dl.set_connection ( concat(aa,b), ab); 
     100        dl.set_connection ( concat ( aa, b ), ab ); 
    101101 
    102102        vec val_up ( "1 2" ); 
    103         dl.step(val_up); 
    104         val_up="3 4"; 
    105          
    106          
     103        dl.step ( val_up ); 
     104        val_up = "3 4"; 
     105 
     106 
    107107        vec p = dl.pushdown ( val_up ); 
    108108        vec exp_p = " 3, 1, 4 "; 
  • library/tests/testsuite/datasource_test.cpp

    r717 r722  
    77 
    88TEST ( EpdfDS_test ) { 
    9         UIFile uif("epdfds.cfg"); 
     9        UIFile uif ( "epdfds.cfg" ); 
    1010 
    11         shared_ptr<EpdfDS> ds=UI::build<EpdfDS>(uif, "ds"); 
    12          
    13         vec mean = zeros(2); 
    14         vec dt = zeros(2); 
    15         for (int i=0; i<100; i++){ 
     11        shared_ptr<EpdfDS> ds = UI::build<EpdfDS> ( uif, "ds" ); 
     12 
     13        vec mean = zeros ( 2 ); 
     14        vec dt = zeros ( 2 ); 
     15        for ( int i = 0; i < 100; i++ ) { 
    1616                ds->step(); 
    17                 ds->getdata(dt); 
     17                ds->getdata ( dt ); 
    1818                mean += dt; 
    1919        } 
    20         CHECK_CLOSE_EX (  vec_2(1.0,2.0) ,mean/100, 1e-2); 
     20        CHECK_CLOSE_EX ( vec_2 ( 1.0, 2.0 ) , mean / 100, 1e-2 ); 
    2121} 
    2222 
    2323TEST ( PdfDS_test ) { 
    24         UIFile uif("pdfds.cfg"); 
     24        UIFile uif ( "pdfds.cfg" ); 
    2525 
    26         shared_ptr<PdfDS> ds=UI::build<PdfDS>(uif, "ds", UI::compulsory); 
    27          
    28         vec dt = zeros(2); 
    29         vec ut="1.0"; 
    30         ds->write(ut); 
    31         for (int i=0; i<100; i++){ 
     26        shared_ptr<PdfDS> ds = UI::build<PdfDS> ( uif, "ds", UI::compulsory ); 
     27 
     28        vec dt = zeros ( 2 ); 
     29        vec ut = "1.0"; 
     30        ds->write ( ut ); 
     31        for ( int i = 0; i < 100; i++ ) { 
    3232                ds->step(); 
    3333        } 
    34         ds->getdata(dt); 
    35         CHECK_CLOSE ( -0.2 , dt(0), 1e-4); 
     34        ds->getdata ( dt ); 
     35        CHECK_CLOSE ( -0.2 , dt ( 0 ), 1e-4 ); 
    3636 
    37         ut="2.0"; 
    38         ds->write(ut); 
    39         for (int i=0; i<100; i++){ 
     37        ut = "2.0"; 
     38        ds->write ( ut ); 
     39        for ( int i = 0; i < 100; i++ ) { 
    4040                ds->step(); 
    4141        } 
    42         ds->getdata(dt); 
    43         CHECK_CLOSE ( -0.4 , dt(0), 1e-4); 
     42        ds->getdata ( dt ); 
     43        CHECK_CLOSE ( -0.4 , dt ( 0 ), 1e-4 ); 
    4444} 
    4545 
    46 TEST(StateDS_test){ 
    47         RV y("y",1); 
    48         RV u("u",1); 
    49         RV x("x",2); 
    50          
     46TEST ( StateDS_test ) { 
     47        RV y ( "y", 1 ); 
     48        RV u ( "u", 1 ); 
     49        RV x ( "x", 2 ); 
     50 
    5151        shared_ptr<mlnorm<fsqmat> > IM = new mlnorm<fsqmat>; 
    52         IM->set_parameters(mat("1 2 0.5; 0 1 0.3"), zeros(2), fsqmat(1e-10*eye(2))); 
    53         IM->set_rv(x); 
    54         IM->set_rvc(concat(x.copy_t(-1), u)); 
     52        IM->set_parameters ( mat ( "1 2 0.5; 0 1 0.3" ), zeros ( 2 ), fsqmat ( 1e-10*eye ( 2 ) ) ); 
     53        IM->set_rv ( x ); 
     54        IM->set_rvc ( concat ( x.copy_t ( -1 ), u ) ); 
    5555        IM->validate(); 
    5656 
    5757        shared_ptr<mlnorm<fsqmat> > OM = new mlnorm<fsqmat>; 
    58         OM->set_parameters(mat("1 0"), zeros(1), fsqmat(1e-10*eye(1))); 
    59         OM->set_rv(y); 
    60         OM->set_rvc(x); 
     58        OM->set_parameters ( mat ( "1 0" ), zeros ( 1 ), fsqmat ( 1e-10*eye ( 1 ) ) ); 
     59        OM->set_rv ( y ); 
     60        OM->set_rvc ( x ); 
    6161        OM->validate(); 
    62          
     62 
    6363        StateDS sds; 
    64         sds.set_parameters(IM,OM); 
     64        sds.set_parameters ( IM, OM ); 
    6565        sds.validate(); 
    66          
    67         for (int t=1; t<10;t++){ 
    68                 sds.write(vec_1(double(t))); 
     66 
     67        for ( int t = 1; t < 10; t++ ) { 
     68                sds.write ( vec_1 ( double ( t ) ) ); 
    6969                sds.step(); 
    7070        } 
    7171 
    72         vec dt; sds.getdata(dt); 
    73         CHECK_CLOSE(vec("94.5, 94.5, 13.5, 9"), dt, 1e-2);       
     72        vec dt; 
     73        sds.getdata ( dt ); 
     74        CHECK_CLOSE ( vec ( "94.5, 94.5, 13.5, 9" ), dt, 1e-2 ); 
    7475} 
  • library/tests/testsuite/egiw_test.cpp

    r717 r722  
    4545        int n = 100; 
    4646        rectangular_support Sup; 
    47         Sup.set_parameters("{[-2.,4.], [1.,5.], [0.,2.]} ", n*ones_i(E.dimension())); 
    48          
    49         double summ = exp(E.evallog(Sup.first_vec())); 
     47        Sup.set_parameters ( "{[-2.,4.], [1.,5.], [0.,2.]} ", n*ones_i ( E.dimension() ) ); 
     48 
     49        double summ = exp ( E.evallog ( Sup.first_vec() ) ); 
    5050        // sum all likelihood at all points of support 
    5151        for ( int k = 1; k < Sup.points(); k++ ) { // ALL b 
    52                 summ += exp (E.evallog(Sup.next_vec())); 
     52                summ += exp ( E.evallog ( Sup.next_vec() ) ); 
    5353        } 
    5454 
    55         CHECK_CLOSE ( 1.0, summ*prod(Sup._steps()), 0.01 ); 
     55        CHECK_CLOSE ( 1.0, summ*prod ( Sup._steps() ), 0.01 ); 
    5656} 
    5757 
  • library/tests/testsuite/emix_test.cpp

    r721 r722  
    1313static void check_mean ( emix &distrib_obj, int nsamples, const vec &mean, double tolerance ); 
    1414 
    15 static void check_covariance ( emix &distrib_obj, int nsamples, const mat &R, double tolerance); 
     15static void check_covariance ( emix &distrib_obj, int nsamples, const mat &R, double tolerance ); 
    1616 
    1717TEST ( emix_test ) { 
     
    4646        pdf_ptr Ac = E1->condition ( y ); 
    4747 
    48         mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *>( Ac.get() ); 
    49         CHECK(wacnd); 
     48        mlnorm<ldmat> *wacnd = dynamic_cast<mlnorm<ldmat> *> ( Ac.get() ); 
     49        CHECK ( wacnd ); 
    5050        if ( wacnd ) { 
    5151                CHECK_CLOSE ( mat ( "-0.349953" ), wacnd->_A(), epsilon ); 
     
    8383 
    8484        mat observedR ( "0.740142 -0.259015; -0.259015 1.0302" ); 
    85         check_covariance ( M2, N, observedR, 2.0); 
     85        check_covariance ( M2, N, observedR, 2.0 ); 
    8686 
    8787        epdf_ptr Mg = M2.marginal ( y ); 
     
    9797static void check_mean ( emix &distrib_obj, int nsamples, const vec &mean, double tolerance ) { 
    9898        int tc = 0; 
    99         Array<vec> actual(CurrentContext::max_trial_count); 
     99        Array<vec> actual ( CurrentContext::max_trial_count ); 
    100100        do { 
    101101                mat smp = distrib_obj.sample_mat ( nsamples ); 
    102102                vec emu = sum ( smp, 2 ) / nsamples; 
    103                 actual( tc ) = emu; 
     103                actual ( tc ) = emu; 
    104104                ++tc; 
    105105        } while ( ( tc < CurrentContext::max_trial_count ) && 
    106                   !UnitTest::AreClose ( mean, actual( tc - 1 ), tolerance ) ); 
     106                  !UnitTest::AreClose ( mean, actual ( tc - 1 ), tolerance ) ); 
    107107        if ( ( tc == CurrentContext::max_trial_count ) && 
    108              ( !UnitTest::AreClose ( mean, actual( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
     108                ( !UnitTest::AreClose ( mean, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
    109109                UnitTest::MemoryOutStream stream; 
    110                 UnitTest::TestDetails details(*UnitTest::CurrentTest::Details(), __LINE__); 
     110                UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); 
    111111                stream << "Expected " << mean << " +/- " << tolerance << " but was " << actual; 
    112112 
     
    115115} 
    116116 
    117 static void check_covariance ( emix &distrib_obj, int nsamples, const mat &R, double tolerance) { 
     117static void check_covariance ( emix &distrib_obj, int nsamples, const mat &R, double tolerance ) { 
    118118        int tc = 0; 
    119         Array<mat> actual(CurrentContext::max_trial_count); 
     119        Array<mat> actual ( CurrentContext::max_trial_count ); 
    120120        do { 
    121121                mat smp = distrib_obj.sample_mat ( nsamples ); 
    122122                vec emu = sum ( smp, 2 ) / nsamples; 
    123123                mat er = ( smp * smp.T() ) / nsamples - outer_product ( emu, emu ); 
    124                 actual( tc ) = er; 
     124                actual ( tc ) = er; 
    125125                ++tc; 
    126126        } while ( ( tc < CurrentContext::max_trial_count ) && 
    127                   !UnitTest::AreClose ( R, actual( tc - 1 ), tolerance ) ); 
     127                  !UnitTest::AreClose ( R, actual ( tc - 1 ), tolerance ) ); 
    128128        if ( ( tc == CurrentContext::max_trial_count ) && 
    129              ( !UnitTest::AreClose ( R, actual( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
     129                ( !UnitTest::AreClose ( R, actual ( CurrentContext::max_trial_count - 1 ), tolerance ) ) ) { 
    130130                UnitTest::MemoryOutStream stream; 
    131                 UnitTest::TestDetails details(*UnitTest::CurrentTest::Details(), __LINE__); 
     131                UnitTest::TestDetails details ( *UnitTest::CurrentTest::Details(), __LINE__ ); 
    132132                stream << "Expected " << R << " +/- " << tolerance << " but was " << actual; 
    133133 
    134134                UnitTest::CurrentTest::Results()->OnTestFailure ( details, stream.GetText() ); 
    135        } 
     135        } 
    136136} 
  • library/tests/testsuite/epdf_test.cpp

    r717 r722  
    7676} 
    7777 
    78 TEST(dirich_test){ 
     78TEST ( dirich_test ) { 
    7979        epdf_harness::test_config ( "edirich.cfg" ); 
    8080} 
  • library/tests/testsuite/logger_test.cpp

    r721 r722  
    2222        } 
    2323 
    24         int sz = static_cast<int>(st.st_size); 
     24        int sz = static_cast<int> ( st.st_size ); 
    2525        if ( sz != st.st_size ) { 
    2626                std::string msg = fname; 
  • library/tests/testsuite/merger_test.cpp

    r717 r722  
    4747 
    4848        vec exp_f1 ( "-7.51551 -7.02066 " 
    49                      "-6.54622 -6.09219 " 
    50                      "-5.65856 -5.24534 " 
    51                      "-4.85252 -4.48011 -4.1281 " 
    52                      "-3.7965 -3.48531 -3.19452 " 
    53                      "-2.92414 -2.67417 -2.4446 -2.23544 -2.04668 " 
    54                      "-1.87833 -1.73039 -1.60285 -1.49572 -1.40899 -1.34267 -1.29676 -1.27125 -1.26615 -1.28145 -1.31717 -1.37328 -1.4498 -1.54673 -1.66407 -1.80181 -1.95996 " 
    55                      "-2.13851 -2.33747 -2.55683 -2.79661 " 
    56                      "-3.05678 -3.33737 -3.63836 -3.95975 " 
    57                      "-4.30155 -4.66376 " 
    58                      "-5.04638 -5.4494 -5.87282 " 
    59                      "-6.31665 -6.78089 " 
    60                      "-7.26554 -7.77059 " 
    61                      "-8.29604 -8.84191 " 
    62                      "-9.40818 -9.99485 " 
    63                      "-10.6019 " 
    64                      "-11.2294 -11.8773 " 
    65                      "-12.5456 " 
    66                      "-13.2343 -13.9434 " 
    67                      "-14.6729 " 
    68                      "-15.4229 " 
    69                      "-16.1932 -16.9839 " 
    70                      "-17.7951 " 
    71                      "-18.6266 " 
    72                      "-19.4786 " 
    73                      "-20.3509 " 
    74                      "-21.2437 " 
    75                      "-22.1569 " 
    76                      "-23.0905 " 
    77                      "-24.0444 " 
    78                      "-25.0188 " 
    79                      "-26.0136 " 
    80                      "-27.0288 " 
    81                      "-28.0644 " 
    82                      "-29.1205 " 
    83                      "-30.1969 " 
    84                      "-31.2937 " 
    85                      "-32.4109 " 
    86                      "-33.5486 " 
    87                      "-34.7066 " 
    88                      "-35.8851 " 
    89                      "-37.0839 " 
    90                      "-38.3032 " 
    91                      "-39.5429 " 
    92                      "-40.8029 " 
    93                      "-42.0834 " 
    94                      "-43.3843 " 
    95                      "-44.7056 " 
    96                      "-46.0473 " 
    97                      "-47.4094 " 
    98                      "-48.7919 " 
    99                      "-50.1948 " 
    100                      "-51.6182 " 
    101                      "-53.0619 " 
    102                      "-54.526 " 
    103                      "-56.0106 " 
    104                      "-57.5155" ); 
    105         CHECK_CLOSE(exp_f1, l_f1, epsilon); 
     49                     "-6.54622 -6.09219 " 
     50                     "-5.65856 -5.24534 " 
     51                     "-4.85252 -4.48011 -4.1281 " 
     52                     "-3.7965 -3.48531 -3.19452 " 
     53                     "-2.92414 -2.67417 -2.4446 -2.23544 -2.04668 " 
     54                     "-1.87833 -1.73039 -1.60285 -1.49572 -1.40899 -1.34267 -1.29676 -1.27125 -1.26615 -1.28145 -1.31717 -1.37328 -1.4498 -1.54673 -1.66407 -1.80181 -1.95996 " 
     55                     "-2.13851 -2.33747 -2.55683 -2.79661 " 
     56                     "-3.05678 -3.33737 -3.63836 -3.95975 " 
     57                     "-4.30155 -4.66376 " 
     58                     "-5.04638 -5.4494 -5.87282 " 
     59                     "-6.31665 -6.78089 " 
     60                     "-7.26554 -7.77059 " 
     61                     "-8.29604 -8.84191 " 
     62                     "-9.40818 -9.99485 " 
     63                     "-10.6019 " 
     64                     "-11.2294 -11.8773 " 
     65                     "-12.5456 " 
     66                     "-13.2343 -13.9434 " 
     67                     "-14.6729 " 
     68                     "-15.4229 " 
     69                     "-16.1932 -16.9839 " 
     70                     "-17.7951 " 
     71                     "-18.6266 " 
     72                     "-19.4786 " 
     73                     "-20.3509 " 
     74                     "-21.2437 " 
     75                     "-22.1569 " 
     76                     "-23.0905 " 
     77                     "-24.0444 " 
     78                     "-25.0188 " 
     79                     "-26.0136 " 
     80                     "-27.0288 " 
     81                     "-28.0644 " 
     82                     "-29.1205 " 
     83                     "-30.1969 " 
     84                     "-31.2937 " 
     85                     "-32.4109 " 
     86                     "-33.5486 " 
     87                     "-34.7066 " 
     88                     "-35.8851 " 
     89                     "-37.0839 " 
     90                     "-38.3032 " 
     91                     "-39.5429 " 
     92                     "-40.8029 " 
     93                     "-42.0834 " 
     94                     "-43.3843 " 
     95                     "-44.7056 " 
     96                     "-46.0473 " 
     97                     "-47.4094 " 
     98                     "-48.7919 " 
     99                     "-50.1948 " 
     100                     "-51.6182 " 
     101                     "-53.0619 " 
     102                     "-54.526 " 
     103                     "-56.0106 " 
     104                     "-57.5155" ); 
     105        CHECK_CLOSE ( exp_f1, l_f1, epsilon ); 
    106106 
    107107        vec exp_f2 ( "-13.3202 -13.0192 " 
    108                      "-12.7223 -12.4295 -12.1408 " 
    109                      "-11.8561 -11.5755 -11.299 -11.0266 " 
    110                      "-10.7582 -10.494 -10.2338 " 
    111                      "-9.97772 -9.7257 -9.47777 -9.23391 " 
    112                      "-8.99414 -8.75845 -8.52684 -8.29931 -8.07587 " 
    113                      "-7.8565 -7.64122 -7.43002 -7.22289 -7.01985 " 
    114                      "-6.82089 -6.62602 -6.43522 -6.2485 -6.06587 " 
    115                      "-5.88732 -5.71284 -5.54245 -5.37614 -5.21392 -5.05577 " 
    116                      "-4.9017 -4.75172 -4.60581 -4.46399 -4.32625 -4.19259 -4.06301 " 
    117                      "-3.93752 -3.8161 -3.69876 -3.58551 -3.47634 -3.37125 -3.27024 -3.17331 -3.08046 " 
    118                      "-2.99169 -2.90701 -2.8264 -2.74988 -2.67744 -2.60908 -2.5448 -2.4846 -2.42849 -2.37645 -2.3285 -2.28462 -2.24483 -2.20912 -2.17749 -2.14994 -2.12648 -2.10709 -2.09179 -2.08056 -2.07342 -2.07036 -2.07138 -2.07648 -2.08566 -2.09893 -2.11627 -2.1377 -2.16321 -2.1928 -2.22647 -2.26422 -2.30605 -2.35196 -2.40196 -2.45603 -2.51419 -2.57643 -2.64275 -2.71315 -2.78763 -2.8662 -2.94884 " 
    119                      "-3.03557 -3.12637 -3.22126 -3.32023" ); 
    120         CHECK_CLOSE(exp_f2, l_f2, epsilon); 
     108                     "-12.7223 -12.4295 -12.1408 " 
     109                     "-11.8561 -11.5755 -11.299 -11.0266 " 
     110                     "-10.7582 -10.494 -10.2338 " 
     111                     "-9.97772 -9.7257 -9.47777 -9.23391 " 
     112                     "-8.99414 -8.75845 -8.52684 -8.29931 -8.07587 " 
     113                     "-7.8565 -7.64122 -7.43002 -7.22289 -7.01985 " 
     114                     "-6.82089 -6.62602 -6.43522 -6.2485 -6.06587 " 
     115                     "-5.88732 -5.71284 -5.54245 -5.37614 -5.21392 -5.05577 " 
     116                     "-4.9017 -4.75172 -4.60581 -4.46399 -4.32625 -4.19259 -4.06301 " 
     117                     "-3.93752 -3.8161 -3.69876 -3.58551 -3.47634 -3.37125 -3.27024 -3.17331 -3.08046 " 
     118                     "-2.99169 -2.90701 -2.8264 -2.74988 -2.67744 -2.60908 -2.5448 -2.4846 -2.42849 -2.37645 -2.3285 -2.28462 -2.24483 -2.20912 -2.17749 -2.14994 -2.12648 -2.10709 -2.09179 -2.08056 -2.07342 -2.07036 -2.07138 -2.07648 -2.08566 -2.09893 -2.11627 -2.1377 -2.16321 -2.1928 -2.22647 -2.26422 -2.30605 -2.35196 -2.40196 -2.45603 -2.51419 -2.57643 -2.64275 -2.71315 -2.78763 -2.8662 -2.94884 " 
     119                     "-3.03557 -3.12637 -3.22126 -3.32023" ); 
     120        CHECK_CLOSE ( exp_f2, l_f2, epsilon ); 
    121121 
    122122        vec exp_m2 ( "-7.95304 -7.47281 -7.01175 " 
    123                      "-6.56987 -6.14716 " 
    124                      "-5.74362 -5.35927 " 
    125                      "-4.99408 -4.64808 -4.32125 -4.01359 " 
    126                      "-3.72511 -3.45581 -3.20568 " 
    127                      "-2.97473 -2.76295 -2.57035 -2.39692 -2.24267 -2.1076 " 
    128                      "-1.9917 -1.89498 -1.81743 -1.75905 -1.71986 -1.69984 -1.69899 -1.71732 -1.75483 -1.81151 -1.88736 -1.9824 " 
    129                      "-2.0966 -2.22999 -2.38255 -2.55428 -2.74519 -2.95528 " 
    130                      "-3.18454 -3.43298 -3.70059 -3.98738 " 
    131                      "-4.2008 -4.10829 -4.0211 " 
    132                      "-3.93921 -3.86263 -3.79137 -3.72542 -3.66478 -3.60945 -3.55944 -3.51473 -3.47534 -3.44126 -3.41249 -3.38903 -3.37088 -3.35805 -3.35053 -3.34831 -3.35141 -3.35983 -3.37355 -3.39259 -3.41693 -3.44659 -3.48156 -3.52185 -3.56744 -3.61835 -3.67457 -3.73609 -3.80294 -3.87509 -3.95255 " 
    133                      "-4.03533 -4.12342 -4.21682 -4.31553 -4.41955 -4.52889 -4.64353 -4.76349 -4.88876 " 
    134                      "-5.01934 -5.15524 -5.29644 -5.44296 -5.59479 -5.75193 -5.91438 " 
    135                      "-6.08214 -6.25522 -6.4336 -6.6173 -6.80631 " 
    136                      "-7.00064 -7.20027 -7.40522" ); 
    137         CHECK_CLOSE(exp_m2, m2, epsilon); 
     123                     "-6.56987 -6.14716 " 
     124                     "-5.74362 -5.35927 " 
     125                     "-4.99408 -4.64808 -4.32125 -4.01359 " 
     126                     "-3.72511 -3.45581 -3.20568 " 
     127                     "-2.97473 -2.76295 -2.57035 -2.39692 -2.24267 -2.1076 " 
     128                     "-1.9917 -1.89498 -1.81743 -1.75905 -1.71986 -1.69984 -1.69899 -1.71732 -1.75483 -1.81151 -1.88736 -1.9824 " 
     129                     "-2.0966 -2.22999 -2.38255 -2.55428 -2.74519 -2.95528 " 
     130                     "-3.18454 -3.43298 -3.70059 -3.98738 " 
     131                     "-4.2008 -4.10829 -4.0211 " 
     132                     "-3.93921 -3.86263 -3.79137 -3.72542 -3.66478 -3.60945 -3.55944 -3.51473 -3.47534 -3.44126 -3.41249 -3.38903 -3.37088 -3.35805 -3.35053 -3.34831 -3.35141 -3.35983 -3.37355 -3.39259 -3.41693 -3.44659 -3.48156 -3.52185 -3.56744 -3.61835 -3.67457 -3.73609 -3.80294 -3.87509 -3.95255 " 
     133                     "-4.03533 -4.12342 -4.21682 -4.31553 -4.41955 -4.52889 -4.64353 -4.76349 -4.88876 " 
     134                     "-5.01934 -5.15524 -5.29644 -5.44296 -5.59479 -5.75193 -5.91438 " 
     135                     "-6.08214 -6.25522 -6.4336 -6.6173 -6.80631 " 
     136                     "-7.00064 -7.20027 -7.40522" ); 
     137        CHECK_CLOSE ( exp_m2, m2, epsilon ); 
    138138} 
    139139 
     
    142142 
    143143        shared_ptr<merger_base> mb = 
    144                 UI::build<merger_base> ( in, "Merger", UI::compulsory ); 
     144            UI::build<merger_base> ( in, "Merger", UI::compulsory ); 
    145145 
    146146        pdf_array sources; 
     
    148148        mb->set_sources ( sources ); 
    149149 
    150         shared_ptr<rectangular_support> support =  
    151                 UI::build<rectangular_support> ( in, "Support", UI::compulsory ); 
    152         mb->set_support( *support ); 
     150        shared_ptr<rectangular_support> support = 
     151            UI::build<rectangular_support> ( in, "Support", UI::compulsory ); 
     152        mb->set_support ( *support ); 
    153153 
    154154        mb->merge(); 
  • library/tests/testsuite/randun_test.cpp

    r717 r722  
    55using namespace itpp; 
    66 
    7  TEST(test_randun) { 
     7TEST ( test_randun ) { 
    88        // matlab output obtained by 
    99        // >>clear all 
    1010        // >>randun(10); 
    11          vec matlab_out=" 0.695964974209650, 0.083321541586575, 0.385149445564090, 0.206731595660901, 0.537928272754852, 0.960480190795139, 0.790566693893898, 0.054424274738144, 0.708785523990535, 0.558301708920999"; 
     11        vec matlab_out = " 0.695964974209650, 0.083321541586575, 0.385149445564090, 0.206731595660901, 0.537928272754852, 0.960480190795139, 0.790566693893898, 0.054424274738144, 0.708785523990535, 0.558301708920999"; 
    1212 
    1313        //ASSUMING randun was not used yet! 
    14          vec x = randun(10); 
    15          CHECK_CLOSE(matlab_out, x, 1e-6); 
    16  } 
     14        vec x = randun ( 10 ); 
     15        CHECK_CLOSE ( matlab_out, x, 1e-6 ); 
     16} 
    1717 
  • library/tests/testsuite/rectangular_support_test.cpp

    r717 r722  
    2020        CHECK_EQUAL ( 200, rs.points() ); 
    2121 
    22         vec v = rs.get_vec ( ivec ( "1 2") ); 
    23         CHECK_CLOSE (vec ( "0.15 -0.75" ), v, epsilon ); 
     22        vec v = rs.get_vec ( ivec ( "1 2" ) ); 
     23        CHECK_CLOSE ( vec ( "0.15 -0.75" ), v, epsilon ); 
    2424} 
    2525 
  • library/tests/testsuite/rv_test.cpp

    r717 r722  
    88TEST ( rv_test ) { 
    99        RV::clear_all(); 
    10          
     10 
    1111        RV a = RV ( "{a_in_test_rv }", "3" ); 
    1212        CHECK ( a.equal ( a ) ); 
     
    133133                CHECK_EQUAL ( exp_bi[i], bi ( i ) ); 
    134134        } 
    135          
     135 
    136136        // check uniqueness 
    137         RV join=a; 
    138         join.add(b); 
    139         RV tmp=a; tmp.t_plus(1); 
    140         join.add(tmp); 
    141         tmp=b; tmp.t_plus(-1); 
    142         join.add(tmp); 
    143          
    144         CHECK_EQUAL(unique(join._ids()), vec_2(a.id(0), b.id(0))); // find only ids of a and b 
    145         CHECK_EQUAL(unique_complement(join._ids(), vec_1(a.id(0))), vec_1(b.id(0))); // complemnet of a in previous is b 
     137        RV join = a; 
     138        join.add ( b ); 
     139        RV tmp = a; 
     140        tmp.t_plus ( 1 ); 
     141        join.add ( tmp ); 
     142        tmp = b; 
     143        tmp.t_plus ( -1 ); 
     144        join.add ( tmp ); 
     145 
     146        CHECK_EQUAL ( unique ( join._ids() ), vec_2 ( a.id ( 0 ), b.id ( 0 ) ) ); // find only ids of a and b 
     147        CHECK_EQUAL ( unique_complement ( join._ids(), vec_1 ( a.id ( 0 ) ) ), vec_1 ( b.id ( 0 ) ) ); // complemnet of a in previous is b 
    146148 
    147149        //test if unique names work 
    148         RV uniq1("y",1); 
    149         RV uniq2("y",1); 
    150          
    151         CHECK_EQUAL(uniq1.id(0), uniq2.id(0)); 
    152          
     150        RV uniq1 ( "y", 1 ); 
     151        RV uniq2 ( "y", 1 ); 
     152 
     153        CHECK_EQUAL ( uniq1.id ( 0 ), uniq2.id ( 0 ) ); 
     154 
    153155        // check scalarname 
    154         CHECK_EQUAL("a_in_test_rv_2", abc.scalarname(2)); 
    155         CHECK_EQUAL("b_in_test_rv_0", abc.scalarname(3)); 
     156        CHECK_EQUAL ( "a_in_test_rv_2", abc.scalarname ( 2 ) ); 
     157        CHECK_EQUAL ( "b_in_test_rv_0", abc.scalarname ( 3 ) ); 
    156158} 
  • library/tests/testsuite/shared_ptr_test.cpp

    r717 r722  
    9393        bdm::shared_ptr<Foo> empty; 
    9494        try { 
    95                 Foo x(*empty); 
     95                Foo x ( *empty ); 
    9696                CHECK ( false ); 
    9797        } catch ( std::runtime_error &exc ) { 
  • library/tests/testsuite/testsuite.cpp

    r721 r722  
    55#include "itpp_ext.h" 
    66#include <string.h> 
     7#include "../general_suite.h" 
    78 
    8 using std::cout; 
    9 using std::cerr; 
    10 using std::endl; 
    11  
    12 using namespace itpp; 
    13  
    14 Array<const char *> selected_tests; 
    15  
    16 bool is_selected_test ( const UnitTest::Test *test ) { 
    17         bdm_assert_debug ( test, "NULL test" ); 
    18  
    19         if ( !selected_tests.length() ) { 
    20                 return true; 
    21         } 
    22  
    23         for ( int i = 0; i < selected_tests.length(); ++i ) { 
    24                 const char *n = test->m_details.testName; 
    25                 bdm_assert_debug ( n, "NULL test name" ); 
    26                 const char *sname = selected_tests ( i ); 
    27                 bdm_assert_debug ( sname, "NULL selected test name" ); 
    28                 if ( !strcmp ( n, sname ) ) { 
    29                         return true; 
    30                 } 
    31         } 
    32  
    33         return false; 
    34 } 
     9using namespace UnitTest; 
    3510 
    3611int main ( int argc, char const *argv[] ) { 
    3712        if ( argc > 1 ) { 
    38                 if ( !strcmp ( argv[1], "print" ) ) { 
    39                         UnitTest::Test* curTest = UnitTest::Test::GetTestList().GetHead(); 
    40  
    41                         while ( curTest != 0 ) { 
    42                                 const char *n = curTest->m_details.testName; 
    43                                 printf ( "%s\n", n ); 
    44                                 curTest = curTest->next; 
    45                         } 
    46                         return 0; 
    47                 } else { 
    48                         selected_tests.set_length ( argc - 1 ); 
    49                         const char **param = argv + 1; 
    50                         int i = 0; 
    51                         while ( *param ) { 
    52                                 selected_tests ( i ) = *param; 
    53                                 ++i; 
    54                                 ++param; 
    55                         } 
    56                 } 
     13                if ( !strcmp ( argv[1], "print" ) ) 
     14                        print_test_list(); 
     15                else 
     16                        pick_selected_tests ( argc, argv ); 
    5717        } else { 
    58                 cout << endl << "TESTSUITE - a program covering all BDM unit tests." << endl << endl  
    59                      << argv[0] << " ....................................... run all unit tests" << endl  
    60                      << argv[0] << " particular_test_1 particular_test_2 ... run selected unit tests" << endl  
     18                cout << endl << "TESTSUITE - a program covering all BDM unit tests." << endl << endl 
     19                     << argv[0] << " ....................................... run all unit tests" << endl 
     20                     << argv[0] << " particular_test_1 particular_test_2 ... run selected unit tests" << endl 
    6121                     << argv[0] << " print ................................. print all the implemented unit tests" << endl; 
    6222        } 
    6323 
    64         itpp::RNG_randomize(); 
    65  
    66         UnitTest::TestReporterStdout reporter; 
    67         UnitTest::TestRunner runner ( reporter ); 
    68         return runner.RunTestsIf ( UnitTest::Test::GetTestList(), 
    69                                    0, 
    70                                    is_selected_test, 
    71                                    0 ); 
     24        return run_selected_tests(); 
    7225} 
  • library/tests/testsuite/user_info_test.cpp

    r721 r722  
    3333        } 
    3434 
    35 string to_string()  const { 
     35        string to_string()  const { 
    3636                return name; 
    3737        } 
     
    6161        } 
    6262 
    63 string to_string()  const { 
     63        string to_string()  const { 
    6464                stringstream stream; 
    6565                stream << number; 
     
    7777        string manufacturer; 
    7878 
    79         Transport() : year( 1900 ), manufacturer( "unknown" ) { 
     79        Transport() : year ( 1900 ), manufacturer ( "unknown" ) { 
    8080        } 
    8181 
    8282        Transport ( int year, string manufacturer ) : 
    83                 year ( year ), manufacturer ( manufacturer ) { 
     83                        year ( year ), manufacturer ( manufacturer ) { 
    8484        } 
    8585 
     
    128128        } 
    129129 
    130 string to_string()  const { 
     130        string to_string()  const { 
    131131                stringstream stream; 
    132132                stream << "A car made in " << year << " by " << manufacturer << ", having " << kilometers << " kilometers on the clock."; 
     
    163163                int elights; 
    164164                if ( UI::get ( elights, set, "electricLights", UI::optional ) ) { 
    165                     electricLights = !!elights; 
     165                        electricLights = !!elights; 
    166166                } 
    167167 
     
    178178        } 
    179179 
    180 string to_string()  const { 
     180        string to_string()  const { 
    181181                stringstream stream; 
    182182                stream << "a bike made in " << year << " by " << manufacturer;