.. _program_listing_file_examples_test_rk4_only.cpp: Program Listing for File test_rk4_only.cpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``examples/test_rk4_only.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include #include #include void exponential_decay(double t, const std::vector& y, std::vector& dydt) { dydt[0] = -y[0]; } int main() { std::cout << "Testing RK4 only..." << std::endl; try { std::vector y = {1.0}; auto integrator = diffeq::RK4Integrator>(exponential_decay); integrator.set_time(0.0); integrator.integrate(y, 0.1, 1.0); std::cout << "RK4 result: " << y[0] << " (expected: " << std::exp(-1.0) << ")" << std::endl; std::cout << "[PASS] RK4 test passed!" << std::endl; } catch (const std::exception& e) { std::cout << "[FAIL] RK4 test failed: " << e.what() << std::endl; return 1; } return 0; }