limes
3.1.0
Composable Calculus Expressions for C++20
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <concepts>
4
#include <type_traits>
5
6
namespace
limes::algorithms::concepts
{
7
8
// Fundamental algebraic concept: a type supporting field operations
9
template
<
typename
T>
10
concept
Field
=
requires
(T a, T b) {
11
{ a + b } -> std::convertible_to<T>;
12
{ a - b } -> std::convertible_to<T>;
13
{ a * b } -> std::convertible_to<T>;
14
{ a / b } -> std::convertible_to<T>;
15
{ -a } -> std::convertible_to<T>;
16
{ T(0) };
17
{ T(1) };
18
};
19
20
// A callable that accepts a single argument of type T
21
template
<
typename
F,
typename
T>
22
concept
UnivariateFunction
= std::invocable<F, T>;
23
24
// Accumulator: incremental summation with operator+=, operator(), and default/value construction
25
template
<
typename
A,
typename
T>
26
concept
Accumulator
=
requires
(A acc, T value) {
27
{ acc += value } -> std::same_as<A&>;
28
{ acc() } -> std::convertible_to<T>;
29
{ A{} };
30
{ A{T{}} };
31
};
32
33
// Integration result: value, error, iteration count, and conversion to T
34
template
<
typename
R,
typename
T>
35
concept
IntegrationResult
=
requires
(R result) {
36
{ result.value() } -> std::convertible_to<T>;
37
{ result.error() } -> std::convertible_to<T>;
38
{ result.iterations() } -> std::convertible_to<std::size_t>;
39
{
static_cast<
T
>
(result) } -> std::convertible_to<T>;
40
};
41
42
// Quadrature rule: fixed set of nodes and weights on [-1, 1]
43
template
<
typename
Q,
typename
T>
44
concept
QuadratureRule
=
requires
(Q rule) {
45
typename
Q::value_type;
46
typename
Q::size_type;
47
{ rule.size() } -> std::convertible_to<std::size_t>;
48
{ rule.weight(std::size_t{}) } -> std::convertible_to<T>;
49
{ rule.abscissa(std::size_t{}) } -> std::convertible_to<T>;
50
};
51
52
// Integrator: a type with value_type and a result_type satisfying IntegrationResult
53
template
<
typename
I,
typename
T>
54
concept
Integrator
=
requires
{
55
typename
I::value_type;
56
typename
I::result_type;
57
requires
IntegrationResult<typename I::result_type, T>
;
58
};
59
60
}
// namespace limes::algorithms::concepts
limes::algorithms::concepts::Accumulator
Definition
concepts.hpp:26
limes::algorithms::concepts::Field
Definition
concepts.hpp:10
limes::algorithms::concepts::IntegrationResult
Definition
concepts.hpp:35
limes::algorithms::concepts::Integrator
Definition
concepts.hpp:54
limes::algorithms::concepts::QuadratureRule
Definition
concepts.hpp:44
limes::algorithms::concepts::UnivariateFunction
Definition
concepts.hpp:22
limes::algorithms::concepts
Definition
concepts.hpp:6
include
limes
algorithms
concepts
concepts.hpp
Generated on Fri Jan 30 2026 11:36:49 for limes by
1.9.8