From 0cd6044f280d1987d9df2007cadb050f19ed933a Mon Sep 17 00:00:00 2001 From: jthorn Date: Thu, 16 Aug 2001 14:36:25 +0000 Subject: add some more tests, do them via *down* loops in (x,y,z) so we start in (+,+,+) quadrant ==> get some successful tests before hard stuff ==> help test the tests themselves git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinAnalysis/AHFinderDirect/trunk@265 f88db872-0e4f-0410-b76b-b9085cfa78c5 --- src/patch/test_coords2.cc | 174 +++++++++++++++++++++++++++++----------------- 1 file changed, 112 insertions(+), 62 deletions(-) diff --git a/src/patch/test_coords2.cc b/src/patch/test_coords2.cc index 0eb151b..f77d46d 100644 --- a/src/patch/test_coords2.cc +++ b/src/patch/test_coords2.cc @@ -17,13 +17,12 @@ using jtutil::degrees_of_radians; using namespace local_coords; // prototypes -void test_mu_nu_phi_to_3rd(bool verbose_flag); - -// global variables -// ... angle ranges for tests (degrees) -fp dang_min = -170; -fp dang_delta = 20; -fp dang_max = 170; +namespace { +void test_r_mu_nu (fp x, fp y, fp z); +void test_r_mu_phi(fp x, fp y, fp z); +void test_r_nu_phi(fp x, fp y, fp z); +void test_r_theta_phi(fp x, fp y, fp z); + }; //****************************************************************************** @@ -35,72 +34,123 @@ fp dang_max = 170; int main(int argc, const char *argv[]) { bool verbose_flag = (argc == 2) && STRING_EQUAL(argv[1], "--verbose"); +const fp xyz_minmax = 1.0; +const fp xyz_delta = 0.1; + + // these loops go *down* so we start in (+,+,+) quadrant + // ==> get some successful tests before hard stuff + // ==> help test the tests themselves + for (fp x = xyz_minmax ; fuzzy::GE(x,xyz_minmax) ; x -= xyz_delta) + { + for (fp y = xyz_minmax ; fuzzy::GE(y,xyz_minmax) ; y -= xyz_delta) + { + for (fp z = xyz_minmax ; fuzzy::GE(z,xyz_minmax) ; z -= xyz_delta) + { + // avoid places where angular coords might not be defined + if ( fuzzy::EQ(x,0.0) + || fuzzy::EQ(y,0.0) + || fuzzy::EQ(z,0.0) ) + then continue; -test_mu_nu_phi_to_3rd(verbose_flag); + if (verbose_flag) + printf("testing x=%g y=%g z=%g\n", x,y,z); + + test_r_mu_nu (x, y, z); + test_r_mu_phi(x, y, z); + test_r_nu_phi(x, y, z); + + test_r_theta_phi(x, y, z); + } + } + } +printf("all ok!\n"); return 0; } //****************************************************************************** -// ((mu,nu,phi)) --> the 3rd -void test_mu_nu_phi_to_3rd(bool verbose_flag) +namespace { +void test_r_mu_nu(fp x, fp y, fp z) { -printf("testing ((mu,nu,phi)) --> the 3rd...\n"); +fp r, mu, nu; +r_mu_nu_of_xyz(x,y,z, r,mu,nu); - for (fp drho = dang_min ; - fuzzy::LE(drho,dang_max) ; - drho += dang_delta) - { - for (fp dsigma = dang_min ; - fuzzy::LE(dsigma,dang_max) ; - dsigma += dang_delta) - { - const fp rho = radians_of_degrees(drho ); - const fp sigma = radians_of_degrees(dsigma); +const fp phi = phi_of_mu_nu(mu,nu); +assert( fuzzy::EQ(mu, mu_of_nu_phi(nu,phi)) ); +assert( fuzzy::EQ(nu, nu_of_mu_phi(mu,phi)) ); - // (mu,nu) --> phi --> (mu,nu) - { - const fp mu = rho; - const fp nu = sigma; - const fp phi = phi_of_mu_nu(mu,nu); - if (verbose_flag) - then printf(" mu=%g nu=%g ==> phi=%g\n", - degrees_of_radians(mu), - degrees_of_radians(nu), - degrees_of_radians(phi)); - assert( fuzzy::EQ(mu, mu_of_nu_phi(nu,phi)) ); - assert( fuzzy::EQ(nu, nu_of_mu_phi(mu,phi)) ); - } +fp xx, yy, zz; +xyz_of_r_mu_nu(r,mu,nu, xx,yy,zz); - // (mu,phi) --> nu --> (mu,phi) - { - const fp mu = rho; - const fp phi = sigma; - const fp nu = nu_of_mu_phi(mu,phi); - if (verbose_flag) - then printf(" mu=%g phi=%g ==> nu=%g\n", - degrees_of_radians(mu), - degrees_of_radians(phi), - degrees_of_radians(nu)); - assert( fuzzy::EQ(mu, mu_of_nu_phi(nu,phi)) ); - assert( fuzzy::EQ(phi, phi_of_mu_nu(mu,nu)) ); - } +assert( fuzzy::EQ(x, xx) ); +assert( fuzzy::EQ(y, yy) ); +assert( fuzzy::EQ(z, zz) ); +} + } - // (nu,phi) --> mu --> (nu,phi) - { - const fp nu = rho; - const fp phi = sigma; - const fp mu = mu_of_nu_phi(nu,phi); - if (verbose_flag) - then printf(" nu=%g phi=%g ==> mu=%g\n", - degrees_of_radians(nu), - degrees_of_radians(phi), - degrees_of_radians(mu)); - assert( fuzzy::EQ(nu, nu_of_mu_phi(mu,phi)) ); - assert( fuzzy::EQ(phi, phi_of_mu_nu(mu,nu)) ); - } +//************************************** - } - } +namespace { +void test_r_mu_phi(fp x, fp y, fp z) +{ +fp r, mu, phi; +r_mu_phi_of_xyz(x,y,z, r,mu,phi); + +const fp nu = nu_of_mu_phi(mu,phi); +assert( fuzzy::EQ(mu, mu_of_nu_phi(nu,phi)) ); +assert( fuzzy::EQ(phi, phi_of_mu_nu(mu,nu)) ); + +fp xx, yy, zz; +xyz_of_r_mu_phi(r,mu,phi, xx,yy,zz); + +assert( fuzzy::EQ(x, xx) ); +assert( fuzzy::EQ(y, yy) ); +assert( fuzzy::EQ(z, zz) ); +} + } + +//************************************** + +namespace { +void test_r_nu_phi(fp x, fp y, fp z) +{ +fp r, nu, phi; +r_nu_phi_of_xyz(x,y,z, r,nu,phi); + +const fp mu = mu_of_nu_phi(nu,phi); +assert( fuzzy::EQ(nu, nu_of_mu_phi(mu,phi)) ); +assert( fuzzy::EQ(phi, phi_of_mu_nu(mu,nu)) ); + +fp xx, yy, zz; +xyz_of_r_nu_phi(r,nu,phi, xx,yy,zz); + +assert( fuzzy::EQ(x, xx) ); +assert( fuzzy::EQ(y, yy) ); +assert( fuzzy::EQ(z, zz) ); +} + } + +//****************************************************************************** + +namespace { +void test_r_theta_phi(fp x, fp y, fp z) +{ +fp r, theta, phi; +r_theta_phi_of_xyz(x,y,z, r,theta,phi); + +fp mu, nu; +mu_nu_of_theta_phi(theta,phi, mu,nu); +fp theta2, phi2; +theta_phi_of_mu_nu(mu,nu, theta2,phi2); +assert( fuzzy::EQ(theta, theta2) ); +assert( fuzzy::EQ(phi, phi2) ); + +fp xx, yy, zz; +xyz_of_r_theta_phi(r,theta,phi, xx,yy,zz); + +assert( fuzzy::EQ(x, xx) ); +assert( fuzzy::EQ(y, yy) ); +assert( fuzzy::EQ(z, zz) ); } + } -- cgit v1.2.3