root/library/tests/stresssuite/merger_2d_stress.cpp @ 1457

Revision 1159, 1.8 kB (checked in by smidl, 14 years ago)

stresssuite fixes

Line 
1
2#include "stat/exp_family.h"
3#include "stat/merger.h"
4#include "../mat_checks.h"
5
6using namespace bdm;
7
8//These lines are needed for use of cout and endl
9using std::cout;
10using std::endl;
11
12TEST ( merger_2d_stress ) {
13
14    RNG_randomize();
15
16    RV x ( "{x }", "1" );
17    RV y ( "{y }", "1" );
18
19    RV xy = x;
20    xy.add ( y );
21
22    enorm_fsqmat_ptr f1;
23    f1->set_rv ( xy );
24    enorm_fsqmat_ptr f2;
25    f2->set_rv ( xy );
26
27    mat R1 ( "0.5 0.48; 0.48 0.5" );
28    mat R2 ( "0.5 0; 0 0.1" );
29    f1->set_parameters ( "1 1", R1 );
30    f2->set_parameters ( "1 1", mat ( "0.5 0; 0 0.1" ) );
31
32    pdf_array A ( 2 );
33    A ( 0 ) = f1;
34    A ( 1 ) = f2;
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_mix M ( A );
47    enorm<fsqmat> g0;
48    g0.set_rv ( xy );
49    g0.set_parameters ( vec ( "1 1" ), mat ( "10 0; 0 10" ) );
50
51    M.set_parameters ( 1 );
52    M.set_method ( LOGNORMAL, 1e8 );
53    M.set_support ( g0, 400 );
54    M.merge();
55
56    MixEF &MM = M._Mix();
57    emix* MP = MM.epredictor(); //xy
58
59    vec Res1;// = M.evallog_mat ( Grid );
60    mat Res2 = ( MP )->evallog_coms ( Grid );
61
62    it_file it ( "merger_2d_test.it" );
63    it << Name ( "Npoints" ) << Npoints;
64    it << Name ( "Grid" ) << Grid;
65    it << Name ( "Res1" ) << Res1;
66    it << Name ( "Res2" ) << Res2;
67    it << Name ( "S1" ) << f1->evallog_mat ( Grid );
68    it << Name ( "S2" ) << f2->evallog_mat ( Grid );
69//      cout << ( ( enorm<ldmat>* ) ( MP->_Coms ( 0 ).get() ) )->_R().to_mat() << endl;
70}
Note: See TracBrowser for help on using the browser.