summaryrefslogtreecommitdiffstats
path: root/tests/Euler.cpp
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-10-06 16:47:04 -0400
committerTavian Barnes <tavianator@gmail.com>2010-10-06 16:47:04 -0400
commit0f04e97fa748b6740da4c9512b596d7d3a2788c5 (patch)
treeeb03f2de5798c78e13c53b305758bf727403f872 /tests/Euler.cpp
parent2e25da27f14566000fb34d3859bfb470bf5fd1da (diff)
downloadvz-0f04e97fa748b6740da4c9512b596d7d3a2788c5.tar.xz
Add the Euler method.
Diffstat (limited to 'tests/Euler.cpp')
-rw-r--r--tests/Euler.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/Euler.cpp b/tests/Euler.cpp
new file mode 100644
index 0000000..5666cd8
--- /dev/null
+++ b/tests/Euler.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::EulerIntegrator integrator(f);
+ integrator.y(1.0).x(0.0).h(0.01);
+
+ integrator.integrate(2.0);
+
+ std::cout << integrator.y() << std::endl
+ << std::exp(2.0) << std::endl;
+
+ return EXIT_SUCCESS;
+}