#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.emitter[14][1234] = JMODEL::JEmitter(toe[0]); A.emitter[18][1235] = JMODEL::JEmitter(toe[1]); DEBUG(A << endl); { JMODEL::setOption(JMODEL::fit_emitters_only_t); ASSERT(A.getN() == 2, "Test number of parameters option = " << JMODEL::getOption()); ASSERT(A[0] == toe[0], "Test index 0."); ASSERT(A[1] == toe[1], "Test index 1."); } { JMODEL::setOption(JMODEL::fit_emitters_and_strings_1st_order_t); ASSERT(A.getN() == 6, "Test number of parameters option = " << JMODEL::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."); } { JMODEL::setOption(JMODEL::fit_emitters_and_strings_2nd_order_t); ASSERT(A.getN() == 10, "Test number of parameters option = " << JMODEL::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.emitter.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.emitter[14][1234] == JMODEL::JEmitter(), "Test contents after reset of model."); ASSERT(B.emitter[18][1235] == JMODEL::JEmitter(), "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; }