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