| 1 |  | 
|---|
| 2 | #include <stat/libEF.h> | 
|---|
| 3 | #include <estim/merger.h> | 
|---|
| 4 |  | 
|---|
| 5 | using namespace bdm; | 
|---|
| 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 | 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; f1.set_rv ( xy ); | 
|---|
| 21 | enorm<fsqmat> f2; f1.set_rv ( xy ); | 
|---|
| 22 |  | 
|---|
| 23 | mat R1 ( "0.5 0.48; 0.48 0.5" ); | 
|---|
| 24 | mat R2 ( "0.5 0; 0 0.1" ); | 
|---|
| 25 | f1.set_parameters ( "1 1", R1); | 
|---|
| 26 | f2.set_parameters ( "1 1",mat ( "0.5 0; 0 0.1" ) ); | 
|---|
| 27 |  | 
|---|
| 28 | Array<mpdf* > A ( 2 ); | 
|---|
| 29 | mepdf A1(&f1); | 
|---|
| 30 | mepdf A2(&f2); | 
|---|
| 31 | A ( 0 ) =&A1; | 
|---|
| 32 | A ( 1 ) =&A2; | 
|---|
| 33 |  | 
|---|
| 34 | int Npoints=100; | 
|---|
| 35 | mat x_grid(1,Npoints); | 
|---|
| 36 | x_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); | 
|---|
| 37 | mat y_grid(1,Npoints); | 
|---|
| 38 | y_grid.set_row(0,linspace ( -2.0, 4.0, Npoints )); | 
|---|
| 39 |  | 
|---|
| 40 | mat Grid (2,Npoints*Npoints); | 
|---|
| 41 | Grid.set_submatrix ( 0,0, kron(x_grid,ones(1,Npoints)) ); | 
|---|
| 42 | Grid.set_submatrix ( 1,0, kron(ones(1,Npoints), y_grid) ); | 
|---|
| 43 |  | 
|---|
| 44 | merger M ( A ); | 
|---|
| 45 | enorm<fsqmat> g0; g0.set_rv(xy); | 
|---|
| 46 | g0.set_parameters(vec("1 1"),mat("10 0; 0 10")); | 
|---|
| 47 |  | 
|---|
| 48 | M.set_parameters(1e8,400,1); | 
|---|
| 49 | M.merge(&g0); | 
|---|
| 50 |  | 
|---|
| 51 | MixEF &MM = M._Mix(); | 
|---|
| 52 | emix* MP = MM.epredictor(); //xy | 
|---|
| 53 |  | 
|---|
| 54 | vec Res1 = M.evallog_m(Grid); | 
|---|
| 55 | mat Res2 = (MP)->evallog_M(Grid); | 
|---|
| 56 |  | 
|---|
| 57 | it_file it("merger_2d_test.it"); | 
|---|
| 58 | it << Name("Npoints") << Npoints; | 
|---|
| 59 | it << Name("Grid") << Grid; | 
|---|
| 60 | it << Name("Res1") << Res1; | 
|---|
| 61 | it << Name("Res2") << Res2; | 
|---|
| 62 | it << Name("S1") << f1.evallog_m(Grid); | 
|---|
| 63 | it << Name("S2") << f2.evallog_m(Grid); | 
|---|
| 64 | cout << ((enorm<ldmat>*)(MP->_Coms(0)))->_R().to_mat() << endl; | 
|---|
| 65 | } | 
|---|