summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-06 17:57:48 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-06 17:57:48 -0400
commit39617c503faf08de1324516adc8ebb7150c218ca (patch)
treea9219fe89fada63a6c42ad6d1546f129c1237497 /tests
parentfa85e866aa876a50e735e6d84f5fa32e52fb2f0b (diff)
downloadvz-39617c503faf08de1324516adc8ebb7150c218ca.tar.xz
Add RK4.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/RK4.cpp25
2 files changed, 28 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5f94aab..edef1ae 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,8 +20,10 @@
INCLUDES = -I$(top_srcdir)/src
check_PROGRAMS = Euler-test \
- Midpoint-test
+ Midpoint-test \
+ RK4-test
TESTS = $(check_PROGRAMS)
Euler_test_SOURCES = Euler.cpp
Midpoint_test_SOURCES = Midpoint.cpp
+RK4_test_SOURCES = RK4.cpp
diff --git a/tests/RK4.cpp b/tests/RK4.cpp
new file mode 100644
index 0000000..8e0ca0a
--- /dev/null
+++ b/tests/RK4.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::RK4Integrator integrator(f);
+ integrator.y(1.0).x(0.0).h(0.04);
+
+ integrator.integrate(2.0);
+
+ std::cout << integrator.y() << std::endl
+ << std::exp(2.0) << std::endl;
+
+ return EXIT_SUCCESS;
+}