DiffEq - Modern C++ ODE Integration Library 1.0.0
High-performance C++ library for solving ODEs with async signal processing
Loading...
Searching...
No Matches
test_rk4_only.cpp
1#include <diffeq.hpp>
2#include <iostream>
3#include <vector>
4
5void exponential_decay(double t, const std::vector<double>& y, std::vector<double>& dydt) {
6 dydt[0] = -y[0];
7}
8
9int main() {
10 std::cout << "Testing RK4 only..." << std::endl;
11
12 try {
13 std::vector<double> y = {1.0};
14 auto integrator = diffeq::RK4Integrator<std::vector<double>>(exponential_decay);
15 integrator.set_time(0.0);
16 integrator.integrate(y, 0.1, 1.0);
17 std::cout << "RK4 result: " << y[0] << " (expected: " << std::exp(-1.0) << ")" << std::endl;
18 std::cout << "[PASS] RK4 test passed!" << std::endl;
19} catch (const std::exception& e) {
20 std::cout << "[FAIL] RK4 test failed: " << e.what() << std::endl;
21 return 1;
22 }
23
24 return 0;
25}
Classical 4th-order Runge-Kutta integrator.
Definition rk4.hpp:19
Modern C++ ODE Integration Library with Real-time Signal Processing.