#include #include #include #include "JAcoustics/JModel.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * Test application for acoustics model. */ int main(int argc, char **argv) { using namespace std; using namespace JPP; double precision; int debug; try { JParser<> zap("Test application for acoustics model."); zap['e'] = make_field(precision) = 1e-32; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JModel A; const double tx [] = { 0.001, 0.002 }; const double ty [] = { 0.001, 0.002 }; const double tx2[] = { 0.00001, 0.00002 }; const double ty2[] = { 0.00001, 0.00002 }; const double toe[] = { 1.1, 2.2 }; A.string[3] = JMODEL::JString(tx[0], ty[0], tx2[0], ty2[0]); A.string[5] = JMODEL::JString(tx[1], ty[1], tx2[1], ty2[1]); A.emission[14][1234] = JMODEL::JEmission(toe[0]); A.emission[18][1235] = JMODEL::JEmission(toe[1]); DEBUG(A << endl); { A.setOption(JMODEL::FIT_EMITTERS_ONLY_t); ASSERT(A.getN() == 2, "Test number of parameters option = " << A.getOption()); ASSERT(A[0] == toe[0], "Test index 0."); ASSERT(A[1] == toe[1], "Test index 1."); } { A.setOption(JMODEL::FIT_EMITTERS_AND_STRINGS_1st_ORDER_t); ASSERT(A.getN() == 6, "Test number of parameters option = " << A.getOption()); ASSERT(A[0] == toe[0], "Test index 0."); ASSERT(A[1] == toe[1], "Test index 1."); ASSERT(A[2] == tx [0], "Test index 2."); ASSERT(A[3] == ty [0], "Test index 3."); ASSERT(A[4] == tx [1], "Test index 4."); ASSERT(A[5] == ty [1], "Test index 5."); } { A.setOption(JMODEL::FIT_EMITTERS_AND_STRINGS_2nd_ORDER_t); ASSERT(A.getN() == 10, "Test number of parameters option = " << A.getOption()); ASSERT(A[0] == toe[0], "Test index 0."); ASSERT(A[1] == toe[1], "Test index 1."); ASSERT(A[2] == tx [0], "Test index 2."); ASSERT(A[3] == ty [0], "Test index 3."); ASSERT(A[4] == tx2[0], "Test index 4."); ASSERT(A[5] == ty2[0], "Test index 5."); ASSERT(A[6] == tx [1], "Test index 6."); ASSERT(A[7] == ty [1], "Test index 7."); ASSERT(A[8] == tx2[1], "Test index 8."); ASSERT(A[9] == ty2[1], "Test index 9."); } JModel B(A); ASSERT(A == B, "Test equality of two models."); ASSERT(A + A == 2*A, "Test arithmetics of model."); B.reset(); ASSERT(B.string .size() == 2, "Test size after reset of model."); ASSERT(B.emission.size() == 2, "Test size after reset of model."); ASSERT(B.string[3] == JMODEL::JString(), "Test contents after reset of model."); ASSERT(B.string[5] == JMODEL::JString(), "Test contents after reset of model."); ASSERT(B.emission[14][1234] == JMODEL::JEmission(), "Test contents after reset of model."); ASSERT(B.emission[18][1235] == JMODEL::JEmission(), "Test contents after reset of model."); DEBUG(A - A << endl); ASSERT(A - A != JModel(), "Test arithmetics of model."); ASSERT(A - A == B, "Test arithmetics of model."); A.clear(); ASSERT(A == JModel(), "Test clear of model."); return 0; }