From 90f6cedb9eae73fdf0c44c34874c7e67f39e02c2 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 7 Oct 2010 00:02:53 -0400 Subject: Add iteration count to Integrator. --- tests/BS23.cpp | 1 + tests/Euler.cpp | 9 +++++---- tests/HE12.cpp | 1 + tests/Heun.cpp | 9 +++++---- tests/Midpoint.cpp | 9 +++++---- tests/RK4.cpp | 9 +++++---- tests/RKF45.cpp | 1 + 7 files changed, 23 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/BS23.cpp b/tests/BS23.cpp index 15abd0c..7493345 100644 --- a/tests/BS23.cpp +++ b/tests/BS23.cpp @@ -26,6 +26,7 @@ main() << "Numerical: " << actual << std::endl << "Expected: " << expected << std::endl << "h: " << integrator.h() << std::endl + << "iterations: " << integrator.iterations() << std::endl << "rejections: " << integrator.rejections() << std::endl; double error = std::fabs(expected - actual)/expected; diff --git a/tests/Euler.cpp b/tests/Euler.cpp index 0a6e28e..62ecee7 100644 --- a/tests/Euler.cpp +++ b/tests/Euler.cpp @@ -23,15 +23,16 @@ main() double expected = std::exp(2.0); std::cout << std::setprecision(10) - << "Numerical: " << actual << std::endl - << "Expected: " << expected << std::endl; + << "Numerical: " << actual << std::endl + << "Expected: " << expected << std::endl + << "iterations: " << integrator.iterations() << std::endl; double error = std::fabs(expected - actual)/expected; if (error > 0.01) { - std::cerr << "Error: " << 100.0*error << "%" << std::endl; + std::cerr << "Error: " << 100.0*error << "%" << std::endl; return EXIT_FAILURE; } else { - std::cout << "Error: " << 100.0*error << "%" << std::endl; + std::cout << "Error: " << 100.0*error << "%" << std::endl; return EXIT_SUCCESS; } } diff --git a/tests/HE12.cpp b/tests/HE12.cpp index 511a8e0..9a22d20 100644 --- a/tests/HE12.cpp +++ b/tests/HE12.cpp @@ -26,6 +26,7 @@ main() << "Numerical: " << actual << std::endl << "Expected: " << expected << std::endl << "h: " << integrator.h() << std::endl + << "iterations: " << integrator.iterations() << std::endl << "rejections: " << integrator.rejections() << std::endl; double error = std::fabs(expected - actual)/expected; diff --git a/tests/Heun.cpp b/tests/Heun.cpp index 758524b..e8b4e6c 100644 --- a/tests/Heun.cpp +++ b/tests/Heun.cpp @@ -23,15 +23,16 @@ main() double expected = std::exp(2.0); std::cout << std::setprecision(10) - << "Numerical: " << actual << std::endl - << "Expected: " << expected << std::endl; + << "Numerical: " << actual << std::endl + << "Expected: " << expected << std::endl + << "iterations: " << integrator.iterations() << std::endl; double error = std::fabs(expected - actual)/expected; if (error > 1.4e-4) { - std::cerr << "Error: " << 100.0*error << "%" << std::endl; + std::cerr << "Error: " << 100.0*error << "%" << std::endl; return EXIT_FAILURE; } else { - std::cout << "Error: " << 100.0*error << "%" << std::endl; + std::cout << "Error: " << 100.0*error << "%" << std::endl; return EXIT_SUCCESS; } } diff --git a/tests/Midpoint.cpp b/tests/Midpoint.cpp index c16fb76..b544ed1 100644 --- a/tests/Midpoint.cpp +++ b/tests/Midpoint.cpp @@ -23,15 +23,16 @@ main() double expected = std::exp(2.0); std::cout << std::setprecision(10) - << "Numerical: " << actual << std::endl - << "Expected: " << expected << std::endl; + << "Numerical: " << actual << std::endl + << "Expected: " << expected << std::endl + << "iterations: " << integrator.iterations() << std::endl; double error = std::fabs(expected - actual)/expected; if (error > 1.4e-4) { - std::cerr << "Error: " << 100.0*error << "%" << std::endl; + std::cerr << "Error: " << 100.0*error << "%" << std::endl; return EXIT_FAILURE; } else { - std::cout << "Error: " << 100.0*error << "%" << std::endl; + std::cout << "Error: " << 100.0*error << "%" << std::endl; return EXIT_SUCCESS; } } diff --git a/tests/RK4.cpp b/tests/RK4.cpp index 2090a1e..4b667d4 100644 --- a/tests/RK4.cpp +++ b/tests/RK4.cpp @@ -23,15 +23,16 @@ main() double expected = std::exp(2.0); std::cout << std::setprecision(10) - << "Numerical: " << actual << std::endl - << "Expected: " << expected << std::endl; + << "Numerical: " << actual << std::endl + << "Expected: " << expected << std::endl + << "iterations: " << integrator.iterations() << std::endl; double error = std::fabs(expected - actual)/expected; if (error > 4.2e-8) { - std::cerr << "Error: " << 100.0*error << "%" << std::endl; + std::cerr << "Error: " << 100.0*error << "%" << std::endl; return EXIT_FAILURE; } else { - std::cout << "Error: " << 100.0*error << "%" << std::endl; + std::cout << "Error: " << 100.0*error << "%" << std::endl; return EXIT_SUCCESS; } } diff --git a/tests/RKF45.cpp b/tests/RKF45.cpp index 8b87216..1ac3e4f 100644 --- a/tests/RKF45.cpp +++ b/tests/RKF45.cpp @@ -26,6 +26,7 @@ main() << "Numerical: " << actual << std::endl << "Expected: " << expected << std::endl << "h: " << integrator.h() << std::endl + << "iterations: " << integrator.iterations() << std::endl << "rejections: " << integrator.rejections() << std::endl; double error = std::fabs(expected - actual)/expected; -- cgit v1.2.3