diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-04-02 18:29:33 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-04-02 18:29:33 -0400 |
commit | 671c86c079faa37386f59eb3c814dc837c4df4c5 (patch) | |
tree | 0cf5baa5bb9dc44a05c0b8ea78d867c17d8c1e49 /Carpet/Carpet | |
parent | c0c03fece68597fddfef57948334c5c99154f244 (diff) |
Replace abs() by fabs()
Replace calls to abs() with floating arguments by calls to fabs(), to ensure the results are not accidentally truncated to integer.
Diffstat (limited to 'Carpet/Carpet')
-rw-r--r-- | Carpet/Carpet/src/Evolve.cc | 6 | ||||
-rw-r--r-- | Carpet/Carpet/src/Recompose.cc | 2 | ||||
-rw-r--r-- | Carpet/Carpet/src/SetupGH.cc | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/Carpet/Carpet/src/Evolve.cc b/Carpet/Carpet/src/Evolve.cc index 8864ee9ee..4c97d13a9 100644 --- a/Carpet/Carpet/src/Evolve.cc +++ b/Carpet/Carpet/src/Evolve.cc @@ -110,15 +110,15 @@ namespace Carpet { timer.start(); CCTK_REAL const eps = pow(numeric_limits<CCTK_REAL>::epsilon(), CCTK_REAL(0.75)); - assert (abs (cctkGH->cctk_time - global_time) <= eps * global_time); + assert (fabs (cctkGH->cctk_time - global_time) <= eps * global_time); for (int ml=0; ml<mglevels; ++ml) { for (int rl=0; rl<reflevels; ++rl) { int const do_every = ipow (mgfact, ml) * (maxtimereflevelfact / timereffacts.AT(rl)); if (cctkGH->cctk_iteration % do_every == 0) { - // assert (abs (leveltimes.AT(ml).AT(rl) - global_time) <= + // assert (fabs (leveltimes.AT(ml).AT(rl) - global_time) <= // eps * global_time); - assert (abs (tt->get_time(ml,rl,0) - global_time) <= + assert (fabs (tt->get_time(ml,rl,0) - global_time) <= eps * global_time); } } diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index bedfb0364..703963f97 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -1441,7 +1441,7 @@ namespace Carpet { rvect rcost = cost (superreg); CCTK_REAL const rfact = pow (nprocs / prod(rcost), CCTK_REAL(1)/dim); rcost *= rfact; - assert (abs (prod (rcost) - nprocs) <= 1.0e-6); + assert (fabs (prod (rcost) - nprocs) <= 1.0e-6); if (recompose_verbose) cout << "SRMA shapes " << rcost << endl; // Choose a direction diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc index 47f9dcad1..4db6b8106 100644 --- a/Carpet/Carpet/src/SetupGH.cc +++ b/Carpet/Carpet/src/SetupGH.cc @@ -1837,7 +1837,7 @@ namespace Carpet { npoints = floor (real_npoints + static_cast<CCTK_REAL> (0.5)); // Check domain size - if (any (abs (rvect (npoints) - real_npoints) > + if (any (fabs (rvect (npoints) - real_npoints) > static_cast<CCTK_REAL> (0.001))) { CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, @@ -2100,7 +2100,7 @@ namespace Carpet { free (groupname); } - if (any(abs(rvect(sizes) - real_sizes) > static_cast<CCTK_REAL> (1.0e-8))) { + if (any(fabs(rvect(sizes) - real_sizes) > static_cast<CCTK_REAL> (1.0e-8))) { char * const groupname = CCTK_GroupName(group); CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING, "The shape of group \"%s\" scaled for convergence level %d with convergence factor %d is not integer", |