8 #define BOOST_TEST_DYN_LINK
9 #include <boost/test/unit_test.hpp>
10 #include "regression.hpp"
11 #include "Vector/vector_dist.hpp"
12 #include "DMatrix/EMatrix.hpp"
14 BOOST_AUTO_TEST_SUITE( Regression_test )
18 BOOST_AUTO_TEST_CASE ( Regression_local )
22 size_t bc[2]={PERIODIC,PERIODIC};
27 vectorType vd(2048,domain,bc,g);
31 auto it = vd.getDomainIterator();
35 double posx = (double)rand() / RAND_MAX;
36 double posy = (double)rand() / RAND_MAX;
38 vd.getPos(key)[0] = posx;
39 vd.getPos(key)[1] = posy;
42 vd.template getProp<scalar>(key) = sin(posx*posy);
47 auto it2 = vd.getDomainIterator();
48 auto NN = vd.getCellList(0.1);
82 BOOST_AUTO_TEST_CASE ( Regression_without_domain_initialization)
86 size_t bc[2]={PERIODIC,PERIODIC};
92 vectorType vd_orig(1024,domain,bc,g);
94 vectorType vd_test(vd_orig.getDecomposition(), 200);
100 std::cout<<
"Running regression test with "<<N_prc<<
" procs.\n";
103 const int scalar = 0;
107 auto it = vd_orig.getDomainIterator();
111 double posx = (double)rand() / RAND_MAX;
112 double posy = (double)rand() / RAND_MAX;
114 vd_orig.getPos(key)[0] = posx;
115 vd_orig.getPos(key)[1] = posy;
118 vd_orig.template getProp<scalar>(key) = sin(posx*posy);
126 auto it = vd_test.getDomainIterator();
130 double posx = (double)rand() / RAND_MAX;
131 double posy = (double)rand() / RAND_MAX;
133 vd_test.getPos(key)[0] = posx;
134 vd_test.getPos(key)[1] = posy;
136 vd_test.template getProp<scalar>(key) = 0.0;
145 double max_err = -1.0;
148 auto it = vd_test.getDomainIterator();
153 double val = model.eval(pos);
154 double actual = sin(pos[0]*pos[1]);
155 double err = std::abs(actual - val);
156 if (err > max_err) max_err = err;
158 vd_test.template getProp<scalar>(key) = val;
162 vd_test.ghost_get<scalar>();
168 std::cout <<
"Maximum error: " << max_err <<
"\n";
170 double tolerance = 1e-5;
172 if (std::abs(max_err) < tolerance)
183 BOOST_AUTO_TEST_SUITE_END()
This class represent an N-dimensional box.
void execute()
Execute all the requests.
size_t getProcessUnitID()
Get the process unit id.
size_t getProcessingUnits()
Get the total number of processors.
void max(T &num)
Get the maximum number across all processors (or reduction with infinity norm)
Implementation of VCluster class.