Skip to content

Commit 0d6609c

Browse files
committed
xmake build succeeds
1 parent d949ad9 commit 0d6609c

File tree

9 files changed

+184
-193
lines changed

9 files changed

+184
-193
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@
3737
*.out
3838
*.app
3939

40+
41+
4042
# debug information files
4143
*.dwo
4244

4345
# Build directories
4446
.xmake/
45-
.vscode/
4647
build/
4748

49+
# vscode config
50+
.vscode/
51+
4852
# Example executables
4953
simple_standard_parallelism
5054
standard_parallelism_demo

examples/parallelism_usage_demo.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void modern_parallel_integration_example() {
3939
std::for_each(std::execution::par, initial_conditions.begin(), initial_conditions.end(),
4040
[&](std::vector<double>& state) {
4141
auto integrator = diffeq::make_rk45<std::vector<double>>(system);
42-
integrator.step(state, 0.01); // Single integration step
42+
integrator->step(state, 0.01); // Single integration step
4343
});
4444

4545
auto end_time = std::chrono::high_resolution_clock::now();
@@ -97,7 +97,7 @@ void demonstrate_realtime_control() {
9797
[](std::vector<double>& state) {
9898
RobotArmSystem system;
9999
auto integrator = diffeq::make_rk45<std::vector<double>>(system);
100-
integrator.step(state, 0.001); // 1ms control timestep
100+
integrator->step(state, 0.001); // 1ms control timestep
101101
});
102102

103103
auto end_time = std::chrono::high_resolution_clock::now();
@@ -129,7 +129,7 @@ void demonstrate_realtime_control() {
129129
for (double t = 0.0; t < simulation_time; t += dt) {
130130
// Execute control step asynchronously
131131
auto control_future = std::async(std::launch::async, [&, t]() {
132-
integrator.step(state, dt);
132+
integrator->step(state, dt);
133133
});
134134

135135
// Simulate sensor reading (parallel)
@@ -273,9 +273,9 @@ void benchmark_hardware_targets() {
273273
// Sequential execution
274274
auto seq_start = std::chrono::high_resolution_clock::now();
275275
std::vector<std::vector<double>> seq_states(num_integrations, initial_state);
276-
for (int i = 0; i < num_integrations; ++i) {
277-
integrator.integrate(seq_states[i], dt, t_final);
278-
}
276+
for (int i = 0; i < num_integrations; ++i) {
277+
integrator->integrate(seq_states[i], dt, t_final);
278+
}
279279
auto seq_end = std::chrono::high_resolution_clock::now();
280280
auto seq_duration = std::chrono::duration_cast<std::chrono::milliseconds>(seq_end - seq_start);
281281

@@ -285,7 +285,7 @@ void benchmark_hardware_targets() {
285285
std::for_each(std::execution::par, par_states.begin(), par_states.end(),
286286
[&](std::vector<double>& state) {
287287
auto local_integrator = diffeq::make_rk45<std::vector<double>>(system);
288-
local_integrator.integrate(state, dt, t_final);
288+
local_integrator->integrate(state, dt, t_final);
289289
});
290290
auto par_end = std::chrono::high_resolution_clock::now();
291291
auto par_duration = std::chrono::duration_cast<std::chrono::milliseconds>(par_end - par_start);

examples/sde_usage_demo.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,14 @@ class HestonModel {
198198
int steps = static_cast<int>(T / dt);
199199

200200
// Use high-order SDE integrator for better accuracy
201-
auto integrator = diffeq::sde::factory::make_sosra_integrator<std::vector<double>, double>(problem, wiener);
202-
integrator->set_time(0.0);
201+
diffeq::sde::SOSRAIntegrator<std::vector<double>, double> integrator(problem, wiener);
202+
integrator.set_time(0.0);
203203

204204
std::cout << "Initial state: S = " << x[0] << ", V = " << x[1] << std::endl;
205205

206206
// Integrate Heston model
207207
for (int i = 0; i < steps; ++i) {
208-
integrator->step(x, dt);
208+
integrator.step(x, dt);
209209

210210
// Output every 25 steps (quarterly)
211211
if (i % 25 == 0) {
@@ -270,14 +270,14 @@ class NoisyOscillator {
270270
drift_func, diffusion_func, diffeq::sde::NoiseType::DIAGONAL_NOISE);
271271

272272
auto wiener = diffeq::sde::factory::make_wiener_process<std::vector<double>, double>(1, 67890);
273-
auto integrator = diffeq::sde::factory::make_milstein_integrator<std::vector<double>, double>(problem, wiener);
273+
diffeq::sde::MilsteinIntegrator<std::vector<double>, double> integrator(problem, wiener);
274274

275275
std::vector<double> state = {0.0, 0.0}; // Initial [x, xdot]
276276
double dt = 0.01;
277277
double T = 10.0;
278278
int steps = static_cast<int>(T / dt);
279279

280-
integrator->set_time(0.0);
280+
integrator.set_time(0.0);
281281

282282
std::cout << "Simulating controlled oscillator with noise..." << std::endl;
283283

@@ -293,7 +293,7 @@ class NoisyOscillator {
293293
total_error += error;
294294
max_error = std::max(max_error, error);
295295

296-
integrator->step(state, dt);
296+
integrator.step(state, dt);
297297

298298
// Output every 100 steps
299299
if (i % 100 == 0) {
@@ -356,14 +356,14 @@ class StochasticLotkaVolterra {
356356
drift_func, diffusion_func, diffeq::sde::NoiseType::DIAGONAL_NOISE);
357357

358358
auto wiener = diffeq::sde::factory::make_wiener_process<std::vector<double>, double>(2, 11111);
359-
auto integrator = diffeq::sde::factory::make_sra1_integrator<std::vector<double>, double>(problem, wiener);
359+
diffeq::sde::SRA1Integrator<std::vector<double>, double> integrator(problem, wiener);
360360

361361
std::vector<double> population = {2.0, 1.0}; // Initial [prey, predator]
362362
double dt = 0.01;
363363
double T = 20.0;
364364
int steps = static_cast<int>(T / dt);
365365

366-
integrator->set_time(0.0);
366+
integrator.set_time(0.0);
367367

368368
std::cout << "Initial populations: prey = " << population[0] << ", predator = " << population[1] << std::endl;
369369

@@ -372,7 +372,7 @@ class StochasticLotkaVolterra {
372372
double min_pred = population[1], max_pred = population[1];
373373

374374
for (int i = 0; i < steps; ++i) {
375-
integrator->step(population, dt);
375+
integrator.step(population, dt);
376376

377377
// Update min/max
378378
min_prey = std::min(min_prey, population[0]);
@@ -423,10 +423,10 @@ void demonstrate_async_sde_integration() {
423423
drift_func, diffusion_func, diffeq::sde::NoiseType::DIAGONAL_NOISE);
424424

425425
auto wiener = diffeq::sde::factory::make_wiener_process<std::vector<double>, double>(2, 22222);
426-
auto integrator = diffeq::sde::factory::make_euler_maruyama_integrator<std::vector<double>, double>(problem, wiener);
426+
diffeq::sde::EulerMaruyamaIntegrator<std::vector<double>, double> integrator(problem, wiener);
427427

428-
// Create async integrator
429-
auto async_integrator = diffeq::async::make_async_integrator(integrator);
428+
// Note: Async integrator functionality is not currently available
429+
// For now, we'll use the regular integrator
430430

431431
std::vector<double> state = {1.0, 0.0};
432432
double dt = 0.01;
@@ -437,10 +437,9 @@ void demonstrate_async_sde_integration() {
437437

438438
auto start_time = std::chrono::high_resolution_clock::now();
439439

440-
// Async integration
440+
// Regular integration (async not available)
441441
for (int i = 0; i < steps; ++i) {
442-
auto future = async_integrator->step_async(state, dt);
443-
future.wait(); // Wait for completion
442+
integrator.step(state, dt);
444443

445444
if (i % 100 == 0) {
446445
std::cout << "Step " << i << ": [" << state[0] << ", " << state[1] << "]" << std::endl;
@@ -450,7 +449,7 @@ void demonstrate_async_sde_integration() {
450449
auto end_time = std::chrono::high_resolution_clock::now();
451450
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
452451

453-
std::cout << "Async integration completed in " << duration.count() << "ms" << std::endl;
452+
std::cout << "Integration completed in " << duration.count() << "ms" << std::endl;
454453
std::cout << "Final state: [" << state[0] << ", " << state[1] << "]" << std::endl;
455454
}
456455

0 commit comments

Comments
 (0)