numerics 0.1.0
Loading...
Searching...
No Matches
solve.hpp File Reference

Unified solve() dispatcher – the single entry point for all solvers. More...

#include "solve/problems.hpp"
#include "solve/algorithms.hpp"
#include "ode/ode.hpp"
#include "ode/implicit.hpp"
#include "stochastic/mcmc.hpp"
#include <concepts>
#include <random>

Go to the source code of this file.

Namespaces

namespace  num
 

Concepts

concept  num::IsODEProblem
 
concept  num::IsExplicitODEAlg
 
concept  num::IsImplicitODEAlg
 
concept  num::IsMCMCAlg
 

Functions

template<IsODEProblem P>
ODEResult num::solve (const P &prob, const RK45 &alg, ObserverFn obs=nullptr)
 
template<IsODEProblem P>
ODEResult num::solve (const P &prob, const RK4 &alg, ObserverFn obs=nullptr)
 
template<IsODEProblem P>
ODEResult num::solve (const P &prob, const Euler &alg, ObserverFn obs=nullptr)
 
template<VecField F>
void num::solve (F &u, const BackwardEuler &alg)
 
template<VecField F, typename Observer >
void num::solve (F &u, const BackwardEuler &alg, Observer &&obs)
 
template<IsMCMCAlg A, typename MeasureFn , typename RNG >
double num::solve (const MCMCProblem &prob, const A &alg, MeasureFn &&measure, RNG &rng)
 

Detailed Description

Unified solve() dispatcher – the single entry point for all solvers.

Dispatches on (problem type, algorithm type) via C++20 concepts, mirroring Julia's SciML ecosystem where the algorithm is a swappable plug:

// Explicit ODE (Lorenz, nbody, quantum, ...) auto sol = num::solve(ODEProblem{f, u0, t0, tf}, RK45{.rtol=1e-8}, obs);

// Implicit ODE (heat, diffusion, ...) num::solve(u, BackwardEuler{.solver=cg, .dt=dt, .nstep=n});

// MCMC (Ising, spin glass, ...) double m = num::solve(MCMCProblem{accept, flip, N}, Metropolis{}, measure, rng);

Problems carry the mathematics. Algorithms carry the numerics. Swapping the algorithm never touches the problem definition.

Definition in file solve.hpp.