1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
//! Stratified scalar capability tiers for `loeres` (RFC 001).
//!
//! Rather than one monolithic `Scalar` trait, Loeres splits scalar capabilities
//! into six tiers so an algorithm states the *smallest* numerical contract it
//! actually needs. Ordering, division, metric comparison, and transcendental
//! functions are opt-in tiers, not baseline requirements — which keeps
//! order-free, fixed-point, and integer-like numeric types valid at the base.
//!
//! ```text
//! BaseScalar : Copy + Clone + PartialEq + Sized
//! OrderedScalar : BaseScalar + PartialOrd
//! FiniteScalar : BaseScalar
//! DivisibleScalar : BaseScalar
//! MetricScalar : OrderedScalar
//! AdvancedNumericalScalar: DivisibleScalar + MetricScalar
//! ```
//!
//! These traits are for monomorphized, static-dispatch use; they must not be
//! used behind `dyn` in core or device kernels. No tier references `f32`/`f64`,
//! `std`, `alloc`, formatting, or any backend type.
use crateSolverError;
/// Tier 1 — the minimum algebraic vocabulary to represent optimization data.
///
/// Requires only equality (for zero-testing), **not** `PartialOrd` and **not**
/// `Debug`. Arithmetic is method-based (so the public contract stays under
/// Loeres control) and is assumed panic-free and total over the implementation's
/// documented operating range.
/// Tier 2 — ordering plus Loeres-defined extrema and clamp.
///
/// The bound a solver requires for projection, comparison, and box constraints.
/// Kept separate from [`BaseScalar`] so order-free numeric types stay valid at
/// the base tier and so Loeres controls floating-point extrema semantics.
/// Tier 3 — boundary validation for non-finite values.
///
/// Implemented for any scalar used by public solve entrypoints that reject
/// non-finite inputs. For fixed-point / bounded integer-like scalars these may
/// be trivial constants (`true`, `false`, `false`).
/// Tier 4 — guarded division.
///
/// Division is never an unchecked baseline operation: every public division path
/// returns a structured error rather than panicking or producing a silent
/// undefined value. Guards the exact-zero denominator and non-finite results;
/// near-zero conditioning is a solver-level [`MetricScalar`] concern, so this
/// tier depends only on [`BaseScalar`].
/// Tier 5 — magnitude and tolerance comparison for convergence checks.
///
/// Extends [`OrderedScalar`] because tolerance comparison is inherently ordered,
/// so a `MetricScalar` bound implies `OrderedScalar` (and `BaseScalar`).
/// Tier 6 — expensive, solver-specific functions (barrier methods, norms).
///
/// **Forbidden as a baseline bound** for core access traits, problem
/// representations, or device entrypoints unless a concrete algorithm requires
/// it. Not implemented for primitive floats in baseline core (`no_std` targets
/// have no built-in transcendental functions); such impls require the `libm`
/// feature or a later adapter RFC.