Skip to content
Snippets Groups Projects
Commit d7ad69b6 authored by Elias Pipping's avatar Elias Pipping Committed by Elias Pipping
Browse files

Use std::abs; Fix resulting assertion failures

parent 292b903e
No related branches found
No related tags found
No related merge requests found
...@@ -132,7 +132,7 @@ template <class MyConvexProblemTypeTEMPLATE> class MyBlockProblem { ...@@ -132,7 +132,7 @@ template <class MyConvexProblemTypeTEMPLATE> class MyBlockProblem {
psi.subDiff(0, D); psi.subDiff(0, D);
if (D[1] > 0) { if (D[1] > 0) {
// NOTE: Numerical instability can actually get us here // NOTE: Numerical instability can actually get us here
assert(abs(D[1]) < 1e-15); assert(std::abs(D[1]) < 1e-15);
return 0; return 0;
} }
......
...@@ -476,13 +476,15 @@ int main(int argc, char *argv[]) { ...@@ -476,13 +476,15 @@ int main(int argc, char *argv[]) {
double ret1 = double ret1 =
compute_state_update_bisection(h, unorm, L, s4_old[i][0]); compute_state_update_bisection(h, unorm, L, s4_old[i][0]);
assert(abs(1.0 / h * ret1 - (s4_old[i] - unorm / L) / h - assert(std::abs(1.0 / h * ret1 - (s4_old[i] - unorm / L) / h -
exp(-ret1)) < 1e-12); exp(-ret1)) < 1e-11);
double ret2 = double ret2 =
compute_state_update_lambert(h, unorm, L, s4_old[i][0]); compute_state_update_lambert(h, unorm, L, s4_old[i][0]);
assert(abs(1.0 / h * ret2 - (s4_old[i] - unorm / L) / h - assert(std::abs(1.0 / h * ret2 - (s4_old[i] - unorm / L) / h -
exp(-ret2)) < 1e-12); exp(-ret2)) < 1e-11);
assert(abs(ret2 - ret1) < 1e-14);
assert(std::abs(ret2 - ret1) < 1e-14);
(*s4_new)[i][0] = ret1; (*s4_new)[i][0] = ret1;
} }
...@@ -540,13 +542,13 @@ int main(int argc, char *argv[]) { ...@@ -540,13 +542,13 @@ int main(int argc, char *argv[]) {
double ret1 = double ret1 =
compute_state_update_bisection(h, unorm, L, s5_old[i][0]); compute_state_update_bisection(h, unorm, L, s5_old[i][0]);
assert(abs(1.0 / h * ret1 - (s5_old[i] - unorm / L) / h - assert(std::abs(1.0 / h * ret1 - (s5_old[i] - unorm / L) / h -
exp(-ret1)) < 1e-12); exp(-ret1)) < 1e-12);
double ret2 = double ret2 =
compute_state_update_lambert(h, unorm, L, s5_old[i][0]); compute_state_update_lambert(h, unorm, L, s5_old[i][0]);
assert(abs(1.0 / h * ret2 - (s5_old[i] - unorm / L) / h - assert(std::abs(1.0 / h * ret2 - (s5_old[i] - unorm / L) / h -
exp(-ret2)) < 1e-12); exp(-ret2)) < 1e-12);
assert(abs(ret2 - ret1) < 1e-14); assert(std::abs(ret2 - ret1) < 1e-14);
(*s5_new)[i][0] = ret1; (*s5_new)[i][0] = ret1;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment