summaryrefslogtreecommitdiffstats
path: root/tests/RK4.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/RK4.cpp')
-rw-r--r--tests/RK4.cpp25
1 files changed, 25 insertions, 0 deletions
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;
+}