root/tests/merger_iter_test.cpp @ 190

Revision 190, 1.3 kB (checked in by smidl, 16 years ago)

adaptation of merger for changes and creation of datalink class

Line 
1#include <itpp/itbase.h>
2#include <stat/libEF.h>
3#include <estim/merger.h>
4
5using namespace itpp;
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 ( x );
22               
23        f1.set_parameters ( "0 0",mat ( "0.5 0; 0 0.5" ) );
24        f2.set_parameters ( "3",mat ( "0.5" ) );
25       
26        Array<mpdf* > A ( 2 );
27        mepdf A1(f1);
28        mepdf A2(f2);
29        A ( 0 ) =&A1;
30        A ( 1 ) =&A2;
31       
32        int Npoints=100;
33        mat x_grid(1,Npoints);
34        x_grid.set_row(0,linspace ( -2.0, 4.0, Npoints ));
35        mat y_grid(1,Npoints);
36        y_grid.set_row(0,linspace ( -2.0, 4.0, Npoints ));
37       
38        mat Grid (2,Npoints*Npoints);
39        Grid.set_submatrix ( 0,0, kron(x_grid,ones(1,Npoints)) );
40        Grid.set_submatrix ( 1,0, kron(ones(1,Npoints), y_grid) );
41       
42        merger M ( A );
43        enorm<fsqmat> g0(xy);
44        g0.set_parameters(vec("1 1"),mat("1 0; 0 1"));
45       
46        M.set_parameters(1.2,200,2);
47        M.merge(&g0);
48       
49        MixEF &MM = M._Mix();
50        epdf* MP = MM.predictor(xy);
51       
52        vec Res1 = M.evalpdflog_m(Grid);
53        mat Res2 = ((emix*)MP)->evalpdflog_M(Grid);
54       
55        it_file it("merger_iter_test.it");
56        it << Name("Npoints") << Npoints;
57        it << Name("Grid") << Grid;
58        it << Name("Res1") << Res1;
59        it << Name("Res2") << Res2;
60}
Note: See TracBrowser for help on using the browser.