root/tests/merger_iter_test.cpp @ 254

Revision 254, 1.4 kB (checked in by smidl, 15 years ago)

create namespace bdm

Line 
1#include <itpp/itbase.h>
2#include <stat/libEF.h>
3#include <estim/merger.h>
4
5using namespace bdm;
6
7//These lines are needed for use of cout and endl
8using std::cout;
9using std::endl;
10
11int main() {
12
13        RNG_randomize();
14       
15        RV x ( "{x }","1" );
16        RV y ( "{y }","1" );
17
18        RV xy=x; xy.add(y);
19       
20        enorm<fsqmat> f1 ( xy );
21        enorm<fsqmat> f2 ( xy );
22        enorm<fsqmat> f3(y);
23               
24        f1.set_parameters ( "4 3",mat ( "0.4 0.3; 0.3 0.4" ) );
25        f2.set_parameters ( "1 3",mat ( "0.3 -0.2; -0.2 0.3" ) );
26        f3.set_parameters ( "2",mat("0.4") );
27       
28        Array<mpdf* > A ( 3 );
29        mepdf A1(&f1);
30        mepdf A2(&f2);
31        mepdf A3(&f3);
32        A ( 0 ) =&A1;
33        A ( 1 ) =&A2;
34        A ( 2 ) =&A3;
35       
36        int Npoints=100;
37        mat x_grid(1,Npoints);
38        x_grid.set_row(0,linspace ( -2.0, 4.0, Npoints ));
39        mat y_grid(1,Npoints);
40        y_grid.set_row(0,linspace ( -2.0, 4.0, Npoints ));
41       
42        mat Grid (2,Npoints*Npoints);
43        Grid.set_submatrix ( 0,0, kron(x_grid,ones(1,Npoints)) );
44        Grid.set_submatrix ( 1,0, kron(ones(1,Npoints), y_grid) );
45       
46        merger M ( A );
47        enorm<fsqmat> g0(xy);
48        g0.set_parameters(vec("4 4"),mat("1 0; 0 1"));
49       
50        M.set_parameters(1.2,400,5);
51        M.merge(&g0);
52       
53        MixEF &MM = M._Mix();
54        epdf* MP = MM.predictor(xy);
55       
56        vec Res1 = M.evallog_m(Grid);
57        mat Res2 = ((emix*)MP)->evallog_M(Grid);
58       
59        it_file it("merger_iter_test.it");
60        it << Name("Npoints") << Npoints;
61        it << Name("Grid") << Grid;
62        it << Name("Res1") << Res1;
63        it << Name("Res2") << Res2;
64}
Note: See TracBrowser for help on using the browser.