numerics
0.1.0
Loading...
Searching...
No Matches
algorithms.hpp
Go to the documentation of this file.
1
/// @file solve/algorithms.hpp
2
/// @brief Algorithm tags: carry the numerics, not the mathematics.
3
#pragma once
4
5
#include "
core/policy.hpp
"
6
#include "
core/types.hpp
"
7
#include <concepts>
8
#include <type_traits>
9
10
namespace
num
{
11
12
// -- ODE integrators --
13
14
struct
Euler
{
15
double
h
= 1
e
-3;
16
};
17
18
struct
RK4
{
19
double
h
= 1
e
-3;
20
};
21
22
struct
RK45
{
23
double
h
= 1
e
-3;
24
double
rtol
= 1
e
-6;
25
double
atol
= 1
e
-9;
26
idx
max_steps
= 1000000;
27
};
28
29
// -- Linear-system solvers --
30
31
struct
CG
{
32
real
tol
= 1
e
-10;
33
idx
max_iter
= 1000;
34
Backend
backend
=
default_backend
;
35
};
36
37
struct
GMRES
{
38
real
tol
= 1
e
-6;
39
idx
max_iter
= 1000;
40
idx
restart
= 30;
41
Backend
backend
=
default_backend
;
42
};
43
44
struct
MINRES
{
45
real
tol
= 1
e
-10;
46
idx
max_iter
= 1000;
47
Backend
backend
=
default_backend
;
48
};
49
50
template
<
class
M>
51
struct
PCG
{
52
const
M&
preconditioner
;
53
real
tol
= 1
e
-10;
54
idx
max_iter
= 1000;
55
Backend
backend
=
default_backend
;
56
};
57
58
template
<
class
M>
59
PCG
(
const
M&) ->
PCG<M>
;
60
61
// -- MCMC samplers --
62
63
struct
Metropolis
{
64
int
equilibration
= 1000;
65
int
measurements
= 500;
66
};
67
68
/// @brief An MCMC algorithm tag.
69
template
<
typename
A>
70
concept
IsMCMCAlg
= std::same_as<std::remove_cvref_t<A>, Metropolis>;
71
72
}
// namespace num
num::IsMCMCAlg
An MCMC algorithm tag.
Definition
algorithms.hpp:70
policy.hpp
Backend enum and default backend selection.
types.hpp
Core type definitions.
num
Definition
quadrature.hpp:8
num::real
double real
Definition
types.hpp:10
num::Backend
Backend
Definition
policy.hpp:7
num::idx
std::size_t idx
Definition
types.hpp:11
num::e
constexpr real e
Definition
math.hpp:44
num::default_backend
constexpr Backend default_backend
Definition
policy.hpp:53
num::CG
Definition
algorithms.hpp:31
num::CG::backend
Backend backend
Definition
algorithms.hpp:34
num::CG::max_iter
idx max_iter
Definition
algorithms.hpp:33
num::CG::tol
real tol
Definition
algorithms.hpp:32
num::Euler
Definition
algorithms.hpp:14
num::Euler::h
double h
Definition
algorithms.hpp:15
num::GMRES
Definition
algorithms.hpp:37
num::GMRES::backend
Backend backend
Definition
algorithms.hpp:41
num::GMRES::tol
real tol
Definition
algorithms.hpp:38
num::GMRES::restart
idx restart
Definition
algorithms.hpp:40
num::GMRES::max_iter
idx max_iter
Definition
algorithms.hpp:39
num::MINRES
Definition
algorithms.hpp:44
num::MINRES::max_iter
idx max_iter
Definition
algorithms.hpp:46
num::MINRES::tol
real tol
Definition
algorithms.hpp:45
num::MINRES::backend
Backend backend
Definition
algorithms.hpp:47
num::Metropolis
Definition
algorithms.hpp:63
num::Metropolis::equilibration
int equilibration
Definition
algorithms.hpp:64
num::Metropolis::measurements
int measurements
Definition
algorithms.hpp:65
num::PCG
Definition
algorithms.hpp:51
num::PCG::backend
Backend backend
Definition
algorithms.hpp:55
num::PCG::max_iter
idx max_iter
Definition
algorithms.hpp:54
num::PCG::preconditioner
const M & preconditioner
Definition
algorithms.hpp:52
num::PCG::tol
real tol
Definition
algorithms.hpp:53
num::RK45
Definition
algorithms.hpp:22
num::RK45::max_steps
idx max_steps
Definition
algorithms.hpp:26
num::RK45::atol
double atol
Definition
algorithms.hpp:25
num::RK45::rtol
double rtol
Definition
algorithms.hpp:24
num::RK45::h
double h
Definition
algorithms.hpp:23
num::RK4
Definition
algorithms.hpp:18
num::RK4::h
double h
Definition
algorithms.hpp:19
include
solve
algorithms.hpp
Generated by
1.9.8