Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::linear_algebra::Invertible2x2< T, a, b, c, d > Struct Template Referenceexport

Full-rank 2×2 matrix with entries as non-type template parameters. More...

Public Types

using Domain = T
using inverse_type = Invertible2x2<T, d / det, -b / det, -c / det, a / det>
 Closed-form inverse via Cramer's rule.

Public Member Functions

template<T a2, T b2, T c2, T d2>
constexpr auto operator* (Invertible2x2< T, a2, b2, c2, d2 >) const
 Matrix-matrix composition at the type level: (A · B).
template<T x, T y>
constexpr auto operator* (Vec2< T, x, y >) const
 Left action on Vec2: the compile-time analogue of GL_2(T) × T² → T².
constexpr auto inverse () const
template<T a2, T b2, T c2, T d2>
constexpr bool operator== (Invertible2x2< T, a2, b2, c2, d2 >) const
 Componentwise equality.

Static Public Attributes

static constexpr T m11 = a
static constexpr T m12 = b
static constexpr T m21 = c
static constexpr T m22 = d
static constexpr T det = a * d - b * c

Detailed Description

template<typename T, T a, T b, T c, T d>
requires dedekind::algebra::HasFieldOperators<T>
struct dedekind::linear_algebra::Invertible2x2< T, a, b, c, d >

Full-rank 2×2 matrix with entries as non-type template parameters.

— compile-time 2×2 matrices used for the

block-Schur invertibility program (#366). Entries live in the type.

Entry layout:

M = [[ a, b ],
     [ c, d ]]
det(M) = a·d − b·c        (non-zero; enforced at instantiation)

The type carries the entries structurally, so M * M.inverse() is a compile-time expression whose result type IS the identity matrix when the inverse is exact over T (always true for T = Rational<Z>).

Template Parameters
TStructural (C++20 NTTP-compatible) carrier type with ring-like arithmetic. Rational<Z> over any IsInteger Z is the canonical choice for the paper-facing ℚ proof.
a,b,c,dEntries as NTTPs of type T.

Member Typedef Documentation

◆ inverse_type

template<typename T, T a, T b, T c, T d>
using dedekind::linear_algebra::Invertible2x2< T, a, b, c, d >::inverse_type = Invertible2x2<T, d / det, -b / det, -c / det, a / det>

Closed-form inverse via Cramer's rule.

M^{-1} = (1 / det(M)) · [[ d, -b ], [-c, a ]]

Exact over T = Rational<Z> (any integer Z) and over integer matrices whose determinant is ±1. For carriers where the division is not exact (e.g. int with |det| > 1) this expression loses information silently; use Rational<Z> for the paper-facing existential proof.

Member Function Documentation

◆ operator*() [1/2]

template<typename T, T a, T b, T c, T d>
template<T a2, T b2, T c2, T d2>
auto dedekind::linear_algebra::Invertible2x2< T, a, b, c, d >::operator* ( Invertible2x2< T, a2, b2, c2, d2 > ) const
inlineconstexpr

Matrix-matrix composition at the type level: (A · B).

The result is Invertible2x2<T, …> whose entries are the NTTP-evaluated products-and-sums of the operands'. Invertibility is preserved: the product of two invertible matrices is invertible, and the result type's own static_assert re-checks this as a belt-and-braces guard against carriers where a determinant might underflow.

◆ operator*() [2/2]

template<typename T, T a, T b, T c, T d>
template<T x, T y>
auto dedekind::linear_algebra::Invertible2x2< T, a, b, c, d >::operator* ( Vec2< T, x, y > ) const
inlineconstexpr

Left action on Vec2: the compile-time analogue of GL_2(T) × T² → T².

The matrix-vector product is a type-level rewrite — each Vec2<T, x, y> operand is mapped to Vec2<T, a·x + b·y, c·x + d·y> as a distinct type. Observable via static_assert(M * v == Vec2<T, …>{}).

◆ operator==()

template<typename T, T a, T b, T c, T d>
template<T a2, T b2, T c2, T d2>
bool dedekind::linear_algebra::Invertible2x2< T, a, b, c, d >::operator== ( Invertible2x2< T, a2, b2, c2, d2 > ) const
inlineconstexpr

Componentwise equality.

Because entries are NTTPs, this is a strictly type-level comparison — distinct matrices have distinct types, and the equality is decided at instantiation.


The documentation for this struct was generated from the following file: