Skip to content

Commit 2245224

Browse files
authored
Merge branch 'main' into cursor/set-timeout-limits-for-difficult-tests-4ae4
2 parents e5245fc + d136ea9 commit 2245224

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+505
-507
lines changed

examples/advanced_integrators_usage.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,37 @@ void demonstrate_exponential_decay() {
8282
// Test all integrators
8383
{
8484
std::vector<double> y = {1.0};
85-
diffeq::integrators::ode::RK4Integrator<std::vector<double>> integrator(exponential_decay);
85+
diffeq::RK4Integrator<std::vector<double>> integrator(exponential_decay);
8686
time_integrator(integrator, y, t_start, dt, t_end, "RK4");
8787
}
8888

8989
{
9090
std::vector<double> y = {1.0};
91-
diffeq::integrators::ode::RK23Integrator<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
91+
diffeq::RK23Integrator<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
9292
time_integrator(integrator, y, t_start, dt, t_end, "RK23");
9393
}
9494

9595
{
9696
std::vector<double> y = {1.0};
97-
diffeq::integrators::ode::RK45Integrator<std::vector<double>> integrator(exponential_decay, 1e-8, 1e-12);
97+
diffeq::RK45Integrator<std::vector<double>> integrator(exponential_decay, 1e-8, 1e-12);
9898
time_integrator(integrator, y, t_start, dt, t_end, "RK45");
9999
}
100100

101101
{
102102
std::vector<double> y = {1.0};
103-
diffeq::integrators::ode::DOP853Integrator<std::vector<double>> integrator(exponential_decay, 1e-3, 1e-6);
103+
diffeq::DOP853Integrator<std::vector<double>> integrator(exponential_decay, 1e-3, 1e-6);
104104
time_integrator(integrator, y, t_start, dt, t_end, "DOP853");
105105
}
106106

107107
{
108108
std::vector<double> y = {1.0};
109-
diffeq::integrators::ode::BDFIntegrator<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
109+
diffeq::BDFIntegrator<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
110110
time_integrator(integrator, y, t_start, dt, t_end, "BDF");
111111
}
112112

113113
{
114114
std::vector<double> y = {1.0};
115-
diffeq::integrators::ode::LSODA<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
115+
diffeq::LSODAIntegrator<std::vector<double>> integrator(exponential_decay, 1e-6, 1e-9);
116116
time_integrator(integrator, y, t_start, dt, t_end, "LSODA");
117117
}
118118
}
@@ -127,7 +127,7 @@ void demonstrate_van_der_pol() {
127127

128128
{
129129
std::vector<double> y = {1.0, 0.0};
130-
diffeq::integrators::ode::RK4Integrator<std::vector<double>> integrator(
130+
diffeq::RK4Integrator<std::vector<double>> integrator(
131131
[&vdp](double t, const std::vector<double>& y, std::vector<double>& dydt) {
132132
vdp(t, y, dydt);
133133
});
@@ -136,7 +136,7 @@ void demonstrate_van_der_pol() {
136136

137137
{
138138
std::vector<double> y = {1.0, 0.0};
139-
diffeq::integrators::ode::RK45Integrator<std::vector<double>> integrator(
139+
diffeq::RK45Integrator<std::vector<double>> integrator(
140140
[&vdp](double t, const std::vector<double>& y, std::vector<double>& dydt) {
141141
vdp(t, y, dydt);
142142
}, 1e-6, 1e-9);
@@ -155,7 +155,7 @@ void demonstrate_van_der_pol() {
155155

156156
{
157157
std::vector<double> y = {1.0, 0.0};
158-
diffeq::integrators::ode::BDFIntegrator<std::vector<double>> integrator(
158+
diffeq::BDFIntegrator<std::vector<double>> integrator(
159159
[&vdp](double t, const std::vector<double>& y, std::vector<double>& dydt) {
160160
vdp(t, y, dydt);
161161
}, 1e-6, 1e-9);
@@ -164,13 +164,13 @@ void demonstrate_van_der_pol() {
164164

165165
{
166166
std::vector<double> y = {1.0, 0.0};
167-
diffeq::integrators::ode::LSODA<std::vector<double>> integrator(
167+
diffeq::LSODAIntegrator<std::vector<double>> integrator(
168168
[&vdp](double t, const std::vector<double>& y, std::vector<double>& dydt) {
169169
vdp(t, y, dydt);
170170
}, 1e-6, 1e-9);
171171
double timing = time_integrator(integrator, y, t_start, dt, t_end, "LSODA");
172172
std::cout << " Final method: " <<
173-
(integrator.get_current_method() == diffeq::integrators::ode::LSODA<std::vector<double>>::MethodType::ADAMS ?
173+
(integrator.get_current_method() == diffeq::LSODAIntegrator<std::vector<double>>::MethodType::ADAMS ?
174174
"Adams (non-stiff)" : "BDF (stiff)") << std::endl;
175175
}
176176
}
@@ -185,25 +185,25 @@ void demonstrate_lorenz_system() {
185185

186186
{
187187
std::vector<double> y = {1.0, 1.0, 1.0};
188-
diffeq::integrators::ode::RK4Integrator<std::vector<double>> integrator(lorenz_system);
188+
diffeq::RK4Integrator<std::vector<double>> integrator(lorenz_system);
189189
time_integrator(integrator, y, t_start, dt, t_end, "RK4");
190190
}
191191

192192
{
193193
std::vector<double> y = {1.0, 1.0, 1.0};
194-
diffeq::integrators::ode::RK45Integrator<std::vector<double>> integrator(lorenz_system, 1e-8, 1e-12);
194+
diffeq::RK45Integrator<std::vector<double>> integrator(lorenz_system, 1e-8, 1e-12);
195195
time_integrator(integrator, y, t_start, dt, t_end, "RK45");
196196
}
197197

198198
{
199199
std::vector<double> y = {1.0, 1.0, 1.0};
200-
diffeq::integrators::ode::DOP853Integrator<std::vector<double>> integrator(lorenz_system, 1e-3, 1e-6);
200+
diffeq::DOP853Integrator<std::vector<double>> integrator(lorenz_system, 1e-3, 1e-6);
201201
time_integrator(integrator, y, t_start, dt, t_end, "DOP853");
202202
}
203203

204204
{
205205
std::vector<double> y = {1.0, 1.0, 1.0};
206-
diffeq::integrators::ode::LSODA<std::vector<double>> integrator(lorenz_system, 1e-8, 1e-12);
206+
diffeq::LSODAIntegrator<std::vector<double>> integrator(lorenz_system, 1e-8, 1e-12);
207207
time_integrator(integrator, y, t_start, dt, t_end, "LSODA");
208208
}
209209
}
@@ -232,18 +232,18 @@ void demonstrate_stiff_robertson() {
232232

233233
try {
234234
std::vector<double> y = {1.0, 0.0, 0.0};
235-
diffeq::integrators::ode::BDFIntegrator<std::vector<double>> integrator(robertson_kinetics, 1e-6, 1e-9);
235+
diffeq::BDFIntegrator<std::vector<double>> integrator(robertson_kinetics, 1e-6, 1e-9);
236236
time_integrator(integrator, y, t_start, dt, t_end, "BDF");
237237
} catch (const std::exception& e) {
238238
std::cout << std::setw(15) << "BDF" << ": Failed - " << e.what() << std::endl;
239239
}
240240

241241
try {
242242
std::vector<double> y = {1.0, 0.0, 0.0};
243-
diffeq::integrators::ode::LSODA<std::vector<double>> integrator(robertson_kinetics, 1e-6, 1e-9);
243+
diffeq::LSODAIntegrator<std::vector<double>> integrator(robertson_kinetics, 1e-6, 1e-9);
244244
double timing = time_integrator(integrator, y, t_start, dt, t_end, "LSODA");
245245
std::cout << " Final method: " <<
246-
(integrator.get_current_method() == diffeq::integrators::ode::LSODA<std::vector<double>>::MethodType::ADAMS ?
246+
(integrator.get_current_method() == diffeq::LSODAIntegrator<std::vector<double>>::MethodType::ADAMS ?
247247
"Adams (non-stiff)" : "BDF (stiff)") << std::endl;
248248
} catch (const std::exception& e) {
249249
std::cout << std::setw(15) << "LSODA" << ": Failed - " << e.what() << std::endl;
@@ -265,7 +265,7 @@ void demonstrate_adaptive_features() {
265265

266266
for (auto [rtol, atol] : tolerances) {
267267
std::vector<double> y = {1.0};
268-
diffeq::integrators::ode::RK45Integrator<std::vector<double>> integrator(exponential_decay, rtol, atol);
268+
diffeq::RK45Integrator<std::vector<double>> integrator(exponential_decay, rtol, atol);
269269

270270
std::cout << "Tolerances: rtol = " << rtol << ", atol = " << atol << std::endl;
271271
time_integrator(integrator, y, t_start, dt, t_end, "RK45");

examples/interface_usage_demo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ void demonstrate_usage(StateType initial_state) {
191191
auto signal_aware_ode = interface->make_signal_aware_ode(portfolio_ode);
192192

193193
// Create integrator and run
194-
auto integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<StateType>>(signal_aware_ode);
194+
auto integrator = std::make_unique<diffeq::RK45Integrator<StateType>>(signal_aware_ode);
195195

196196
// Simulate some signals during integration
197197
auto signal_proc = interface->get_signal_processor();
@@ -239,7 +239,7 @@ int main() {
239239
};
240240

241241
auto signal_aware_robot_ode = robotics_interface->make_signal_aware_ode(robot_ode);
242-
auto robot_integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(signal_aware_robot_ode);
242+
auto robot_integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(signal_aware_robot_ode);
243243

244244
std::vector<double> robot_state = {0.1, 0.0}; // [angle, angular_velocity]
245245
auto robot_signal_proc = robotics_interface->get_signal_processor();
@@ -274,7 +274,7 @@ int main() {
274274
};
275275

276276
auto signal_aware_chemical_ode = scientific_interface->make_signal_aware_ode(chemical_ode);
277-
auto chemical_integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(signal_aware_chemical_ode);
277+
auto chemical_integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(signal_aware_chemical_ode);
278278

279279
std::vector<double> chemical_state = {1.0, 0.0}; // [A, B]
280280
auto chemical_signal_proc = scientific_interface->get_signal_processor();

examples/parallelism_usage_demo.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void modern_parallel_integration_example() {
3838
// Use standard C++20 parallel execution
3939
std::for_each(std::execution::par, initial_conditions.begin(), initial_conditions.end(),
4040
[&](std::vector<double>& state) {
41-
auto integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(system);
41+
auto integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(system);
4242
integrator->step(state, 0.01); // Single integration step
4343
});
4444

@@ -96,7 +96,7 @@ void demonstrate_realtime_control() {
9696
std::for_each(std::execution::par, joint_states.begin(), joint_states.end(),
9797
[](std::vector<double>& state) {
9898
RobotArmSystem system;
99-
auto integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(system);
99+
auto integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(system);
100100
integrator->step(state, 0.001); // 1ms control timestep
101101
});
102102

@@ -111,7 +111,7 @@ void demonstrate_realtime_control() {
111111

112112
// Create integrator for robot dynamics
113113
auto robot_system = RobotArmSystem{};
114-
auto integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(robot_system);
114+
auto integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(robot_system);
115115

116116
// Initial state: [angle=0.1 rad, angular_velocity=0]
117117
std::vector<double> state = {0.1, 0.0};
@@ -267,7 +267,7 @@ void benchmark_hardware_targets() {
267267
const double t_final = 1.0;
268268

269269
auto system = ExponentialDecay{};
270-
auto integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(system);
270+
auto integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(system);
271271
std::vector<double> initial_state = {1.0};
272272

273273
// Sequential execution
@@ -284,7 +284,7 @@ void benchmark_hardware_targets() {
284284
std::vector<std::vector<double>> par_states(num_integrations, initial_state);
285285
std::for_each(std::execution::par, par_states.begin(), par_states.end(),
286286
[&](std::vector<double>& state) {
287-
auto local_integrator = std::make_unique<diffeq::integrators::ode::RK45Integrator<std::vector<double>>>(system);
287+
auto local_integrator = std::make_unique<diffeq::RK45Integrator<std::vector<double>>>(system);
288288
local_integrator->integrate(state, dt, t_final);
289289
});
290290
auto par_end = std::chrono::high_resolution_clock::now();

examples/quick_test.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ int main() {
2121
try {
2222
std::cout << "RK4 (fixed step): ";
2323
auto y = y0;
24-
auto integrator = diffeq::integrators::ode::RK4Integrator<std::vector<double>>(exponential_decay);
24+
auto integrator = diffeq::RK4Integrator<std::vector<double>>(exponential_decay);
2525
integrator.set_time(t_start);
2626
integrator.integrate(y, dt, t_end);
2727
std::cout << std::setprecision(6) << y[0] << std::endl;
@@ -32,7 +32,7 @@ int main() {
3232
try {
3333
std::cout << "RK23 (adaptive): ";
3434
auto y = y0;
35-
auto integrator = diffeq::integrators::ode::RK23Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
35+
auto integrator = diffeq::RK23Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
3636
integrator.set_time(t_start);
3737
integrator.integrate(y, dt, t_end);
3838
std::cout << std::setprecision(6) << y[0] << std::endl;
@@ -43,7 +43,7 @@ int main() {
4343
try {
4444
std::cout << "RK45 (adaptive): ";
4545
auto y = y0;
46-
auto integrator = diffeq::integrators::ode::RK45Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
46+
auto integrator = diffeq::RK45Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
4747
integrator.set_time(t_start);
4848
integrator.integrate(y, dt, t_end);
4949
std::cout << std::setprecision(6) << y[0] << std::endl;
@@ -54,7 +54,7 @@ int main() {
5454
try {
5555
std::cout << "DOP853 (high-acc): ";
5656
auto y = y0;
57-
auto integrator = diffeq::integrators::ode::DOP853Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
57+
auto integrator = diffeq::DOP853Integrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
5858
integrator.set_time(t_start);
5959
integrator.integrate(y, dt, t_end);
6060
std::cout << std::setprecision(6) << y[0] << std::endl;
@@ -65,7 +65,7 @@ int main() {
6565
try {
6666
std::cout << "BDF (stiff): ";
6767
auto y = y0;
68-
auto integrator = diffeq::integrators::ode::BDFIntegrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
68+
auto integrator = diffeq::BDFIntegrator<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
6969
integrator.set_time(t_start);
7070
integrator.integrate(y, dt, t_end);
7171
std::cout << std::setprecision(6) << y[0] << std::endl;
@@ -76,11 +76,11 @@ int main() {
7676
try {
7777
std::cout << "LSODA (automatic): ";
7878
auto y = y0;
79-
auto integrator = diffeq::integrators::ode::LSODA<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
79+
auto integrator = diffeq::LSODA<std::vector<double>>(exponential_decay, 1e-3, 1e-6);
8080
integrator.set_time(t_start);
8181
integrator.integrate(y, dt, t_end);
8282
std::cout << std::setprecision(6) << y[0] << " (Method: " <<
83-
(integrator.get_current_method() == diffeq::integrators::ode::LSODA<std::vector<double>>::MethodType::ADAMS ?
83+
(integrator.get_current_method() == diffeq::LSODA<std::vector<double>>::MethodType::ADAMS ?
8484
"Adams)" : "BDF)") << std::endl;
8585
} catch (const std::exception& e) {
8686
std::cout << "Failed: " << e.what() << std::endl;

examples/rk4_integrator_usage.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main() {
5050
std::cout << "\n1. Exponential Decay (dy/dt = -0.5*y)" << std::endl;
5151
std::cout << "-------------------------------------" << std::endl;
5252

53-
diffeq::integrators::ode::RK4Integrator<std::vector<double>, double> decay_integrator(exponential_decay);
53+
diffeq::RK4Integrator<std::vector<double>, double> decay_integrator(exponential_decay);
5454
std::vector<double> decay_state = {2.0}; // y(0) = 2
5555

5656
std::cout << "Time\tValue" << std::endl;
@@ -65,7 +65,7 @@ int main() {
6565
std::cout << "\n2. Lorenz Attractor (first 20 steps)" << std::endl;
6666
std::cout << "------------------------------------" << std::endl;
6767

68-
diffeq::integrators::ode::RK4Integrator<std::vector<double>, double> lorenz_integrator(lorenz_system);
68+
diffeq::RK4Integrator<std::vector<double>, double> lorenz_integrator(lorenz_system);
6969
std::vector<double> lorenz_state = {1.0, 1.0, 1.0}; // Initial conditions
7070

7171
std::cout << "Time\tX\t\tY\t\tZ" << std::endl;
@@ -85,7 +85,7 @@ int main() {
8585
std::cout << "\n3. Damped Harmonic Oscillator (float precision)" << std::endl;
8686
std::cout << "----------------------------------------------" << std::endl;
8787

88-
diffeq::integrators::ode::RK4Integrator<std::array<float, 2>, float> oscillator_integrator(damped_oscillator);
88+
diffeq::RK4Integrator<std::array<float, 2>, float> oscillator_integrator(damped_oscillator);
8989
std::array<float, 2> oscillator_state = {1.0f, 0.0f}; // x(0) = 1, v(0) = 0
9090

9191
std::cout << "Time\tPosition\tVelocity" << std::endl;
@@ -104,7 +104,7 @@ int main() {
104104
std::cout << "\n4. Polymorphic Usage" << std::endl;
105105
std::cout << "-------------------" << std::endl;
106106

107-
auto integrator = std::make_unique<diffeq::integrators::ode::RK4Integrator<std::vector<double>, double>>(exponential_decay);
107+
auto integrator = std::make_unique<diffeq::RK4Integrator<std::vector<double>, double>>(exponential_decay);
108108
AbstractIntegrator<std::vector<double>, double>* base_ptr = integrator.get();
109109

110110
std::vector<double> poly_state = {5.0};

examples/sde_demo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ int main() {
1414
gx[0] = 0.1 * x[0];
1515
};
1616

17-
auto problem = diffeq::sde::factory::make_sde_problem<std::vector<double>, double>(
17+
auto problem = diffeq::factory::make_sde_problem<std::vector<double>, double>(
1818
drift_func, diffusion_func, diffeq::sde::NoiseType::DIAGONAL_NOISE);
1919

2020
auto wiener = diffeq::sde::factory::make_wiener_process<std::vector<double>, double>(1, 12345);
2121
// auto integrator = diffeq::sde::factory::make_euler_maruyama_integrator<std::vector<double>, double>(problem, wiener);
22-
diffeq::sde::EulerMaruyamaIntegrator<std::vector<double>, double> integrator(problem, wiener);
22+
diffeq::EulerMaruyamaIntegrator<std::vector<double>, double> integrator(problem, wiener);
2323

2424
std::vector<double> state = {1.0}; // Initial condition
2525
double dt = 0.01;

0 commit comments

Comments
 (0)