[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 | |
---|
[198] | 13 | RNG_randomize(); |
---|
[190] | 14 | |
---|
[188] | 15 | RV x ( "{x }","1" ); |
---|
| 16 | RV y ( "{y }","1" ); |
---|
| 17 | |
---|
| 18 | RV xy=x; xy.add(y); |
---|
| 19 | |
---|
[190] | 20 | enorm<fsqmat> f1 ( xy ); |
---|
[198] | 21 | enorm<fsqmat> f2 ( xy ); |
---|
| 22 | enorm<fsqmat> f3(y); |
---|
[190] | 23 | |
---|
[198] | 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") ); |
---|
[188] | 27 | |
---|
[198] | 28 | Array<mpdf* > A ( 3 ); |
---|
[203] | 29 | mepdf A1(&f1); |
---|
| 30 | mepdf A2(&f2); |
---|
| 31 | mepdf A3(&f3); |
---|
[190] | 32 | A ( 0 ) =&A1; |
---|
| 33 | A ( 1 ) =&A2; |
---|
[198] | 34 | A ( 2 ) =&A3; |
---|
[188] | 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); |
---|
[198] | 48 | g0.set_parameters(vec("4 4"),mat("1 0; 0 1")); |
---|
[188] | 49 | |
---|
[198] | 50 | M.set_parameters(1.2,400,5); |
---|
[188] | 51 | M.merge(&g0); |
---|
| 52 | |
---|
| 53 | MixEF &MM = M._Mix(); |
---|
| 54 | epdf* MP = MM.predictor(xy); |
---|
| 55 | |
---|
[211] | 56 | vec Res1 = M.evallog_m(Grid); |
---|
| 57 | mat Res2 = ((emix*)MP)->evallog_M(Grid); |
---|
[188] | 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 | } |
---|