summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-06 17:26:06 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-06 17:26:06 -0400
commitfa85e866aa876a50e735e6d84f5fa32e52fb2f0b (patch)
tree3758be8b09c812f936d07d8b58fb16e6996a80ef /tests
parent0f04e97fa748b6740da4c9512b596d7d3a2788c5 (diff)
downloadvz-fa85e866aa876a50e735e6d84f5fa32e52fb2f0b.tar.xz
Add the midpoint method.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am6
-rw-r--r--tests/Midpoint.cpp25
2 files changed, 29 insertions, 2 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a3d5a77..5f94aab 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -19,7 +19,9 @@
INCLUDES = -I$(top_srcdir)/src
-check_PROGRAMS = Euler-test
+check_PROGRAMS = Euler-test \
+ Midpoint-test
TESTS = $(check_PROGRAMS)
-Euler_test_SOURCES = Euler.cpp
+Euler_test_SOURCES = Euler.cpp
+Midpoint_test_SOURCES = Midpoint.cpp
diff --git a/tests/Midpoint.cpp b/tests/Midpoint.cpp
new file mode 100644
index 0000000..aea1885
--- /dev/null
+++ b/tests/Midpoint.cpp
@@ -0,0 +1,25 @@
+#include "vZ.hpp"
+#include <cmath>
+#include <cstdlib>
+#include <iostream>
+
+// y' = y (y == C*exp(t))
+double
+f(double t, double y)
+{
+ return y;
+}
+
+int
+main()
+{
+ vZ::MidpointIntegrator integrator(f);
+ integrator.y(1.0).x(0.0).h(0.02);
+
+ integrator.integrate(2.0);
+
+ std::cout << integrator.y() << std::endl
+ << std::exp(2.0) << std::endl;
+
+ return EXIT_SUCCESS;
+}