Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::linear_algebra::Dual< F > Class Template Reference

Represents f(x) + f'(x)ε. More...

Public Types

using value_type = F

Public Member Functions

constexpr Dual (F v, F d=F{})
constexpr F value () const
constexpr F derivative () const
constexpr Dual operator- () const
constexpr Dual inverse () const
 Multiplicative inverse: (a + bε)⁻¹ = (1/a) - (b/a²)ε. Valid when a ≠ 0.

Public Attributes

F val {}
 Primal f(x). Public so the type is NTTP-structural.
F der {}
 Tangent f'(x). Public so the type is NTTP-structural.

Friends

constexpr bool operator== (const Dual &, const Dual &)=default
constexpr bool operator< (const Dual &a, const Dual &b)
 Lexicographic total order: primal first, tangent breaks ties.
constexpr Dual operator+ (const Dual &a, const Dual &b)
constexpr Dual operator- (const Dual &a, const Dual &b)
constexpr Dual operator* (const Dual &a, const Dual &b)
constexpr Dual operator/ (const Dual &a, const Dual &b)

Detailed Description

template<typename F>
requires std::semiregular<F> && (!std::floating_point<F>)
class dedekind::linear_algebra::Dual< F >

Represents f(x) + f'(x)ε.

Structural C++20 NTTP-compatible layout: primal / tangent fields are public so the type can be used as a non-type template parameter (e.g. Halfspace2D<Dual<Rat>, …> for parametric LP). Backward-compatible accessors value() / derivative() are kept for existing call sites.

◆ operator<

template<typename F>
bool operator< ( const Dual< F > & a,
const Dual< F > & b )
friend

Lexicographic total order: primal first, tangent breaks ties.

a < b iff a.val < b.val, or equal primal with a.der < b.der. This is a total order whose induced equality is operator== (which compares both components), so trichotomy holds and any order-extremum over Dual — e.g. the tropical ⊕ = max — is commutative (a genuine semiring join, not an argument-order artefact). On a primal tie the extremum carries the larger tangent, the upper subgradient: a deterministic, valid selection at a point where max is non-differentiable. The primal alone still fixes the optimum's value (a tie is equal-primal); the tangent only decides which representative is carried out of the tie, so downstream argmax (e.g. dedekind.optimization:lp) keeps the same optimal value, with degenerate ties now broken deterministically.

◆ operator==

template<typename F>
bool operator== ( const Dual< F > & ,
const Dual< F > &  )
friend

The documentation for this class was generated from the following file:
  • src/main/modules/dedekind/analysis/dual.cppm