Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
diagonal.cppm File Reference

Intensional diagonal and rank-1 outer-product matrix carriers (#372 slice c + e) at any dimension, including ℵ_0. More...

#include <concepts>
#include <cstddef>
#include <functional>
#include <type_traits>
import dedekind.linear_algebra:mat2x2;
import dedekind.sets;
import dedekind.order;
import dedekind.category;
import dedekind.algebra;
Include dependency graph for diagonal.cppm:

Classes

struct  dedekind::linear_algebra::dim_finite< N >
 Type-level witness for a finite dimension N. Sibling of dedekind::sets::ℵ<N> on the infinite side; together they cover the dimension axis used by Diagonal / OuterProduct without forcing the std::variant<> Cardinality value to appear as an NTTP. More...
struct  dedekind::linear_algebra::Diagonal< D, F >
 Diagonal matrix carrier M: D×D → T parametric in dimension D and diagonal rule F. More...
struct  dedekind::linear_algebra::identity_rule< T >
 Identity rule: i ↦ T{1}. IsArrow witness for the constant unit. More...
struct  dedekind::linear_algebra::zero_rule< T >
 Zero rule: i ↦ T{0}. More...
struct  dedekind::linear_algebra::one_hot< T, D >
 The one-hot / basis vector e_k : j ↦ δ(j,k) = [j=k] (T{1} on its own index k, T{0} elsewhere) — a 1-arg IsArrow, the k-th COLUMN of the identity Identity (the Kronecker δ with one leg fixed; Diagonal 's entry is δ_ij·F). More...
struct  dedekind::linear_algebra::diagonal_product_rule< F, G >
 The componentwise rule (F·G)(i) = F(i) · G(i). More...
struct  dedekind::linear_algebra::OuterProduct< U, V, Mult >
 Rank-1 matrix M = u⊗v with M[i][j] = u(i)⊗v(j), the product taken in a semiring. More...
struct  dedekind::linear_algebra::detail_diag::linear_rule_int
struct  dedekind::linear_algebra::detail_diag::const_rule_three
struct  dedekind::linear_algebra::detail_diag::const_rule_six
struct  dedekind::linear_algebra::detail_diag::rule_one_two

Namespaces

namespace  dedekind::linear_algebra::detail_diag

Concepts

concept  dedekind::linear_algebra::IsDimension
 A type-template witness for a dimension cardinality. Today's inhabitants: dim_finite<N> and dedekind::sets::ℵ<N>.

Typedefs

template<typename D, typename T>
using dedekind::linear_algebra::Identity = Diagonal<D, identity_rule<T>>
 Identity matrix as Diagonal<D, identity_rule<T>>.
template<typename D, typename T>
using dedekind::linear_algebra::DiagonalZero = Diagonal<D, zero_rule<T>>
 Zero diagonal as Diagonal<D, zero_rule<T>>.

Functions

template<typename D, typename F, typename G>
requires IsDimension<D> && dedekind::category::IsArrow<F> && dedekind::category::IsArrow<G>
constexpr auto dedekind::linear_algebra::operator* (Diagonal< D, F > const &a, Diagonal< D, G > const &b)
 Diagonal-times-diagonal: returns the componentwise-product diagonal at the same dimension D.
template<typename F>
requires dedekind::category::IsArrow<F> && std::semiregular<typename std::remove_cvref_t<F>::Codomain> && dedekind::algebra::HasRingOperators< typename std::remove_cvref_t<F>::Codomain>
constexpr Matrix2x2V< typename std::remove_cvref_t< F >::Codomain > dedekind::linear_algebra::to_dense (Diagonal< dim_finite< 2 >, F > const &d)

Variables

constexpr Identity< dim_finite< 2 >, int > dedekind::linear_algebra::detail_diag::id2 {}
constexpr Identity< dedekind::sets::ℵ_0, int > dedekind::linear_algebra::detail_diag::id_inf {}
constexpr Diagonal< dedekind::sets::ℵ_0, linear_rule_int > dedekind::linear_algebra::detail_diag::diag_lin {}
constexpr OuterProduct< linear_rule_int, const_rule_three > dedekind::linear_algebra::detail_diag::rk1 {}
constexpr OuterProduct< linear_rule_int, const_rule_six > dedekind::linear_algebra::detail_diag::rk1_scaled {}
constexpr Diagonal< dim_finite< 2 >, rule_one_two > dedekind::linear_algebra::detail_diag::diag_one_two {}
constexpr auto dedekind::linear_algebra::detail_diag::diag_one_two_squared = diag_one_two * diag_one_two

Detailed Description

Intensional diagonal and rank-1 outer-product matrix carriers (#372 slice c + e) at any dimension, including ℵ_0.

@partition :diagonal

diagonal__Motivation

Two intensional matrix carriers that bypass dense storage and therefore extend uniformly to infinite dimension ℵ_0:

  • Diagonal<D, F> — a diagonal matrix M: D×D → T storing the rule F: ℕ → T with M[i][j] = δ_ij · F(i). The canonical instance Identity<D, T> fixes F to the constant i ↦ T{1}.
  • OuterProduct<U, V> — the rank-1 matrix M = u⊗v with M[i][j] = u(i)·v(j), where u and v are IsArrow factors with size_t domain and a common scalar codomain. Either factor may be infinite-dimensional (e.g. sequences::Path<T> over ℵ_0); the outer product never materialises a dense m× n storage.

Together they discharge the named trigger of #372 ("first infinite-dim tuple/matrix carrier lands") via two complementary intensional shapes: the diagonal subalgebra of End(ℓ²), and the rank-1 image of ℓ² ⊗ ℓ² in the dense matrix algebra.

diagonal__Type_Level_Dimension_Witnesses

  • dim_finite<N> (defined here) — finite dimension N as an NTTP, is_finite = true. Mirrors std::integral_constant but with the is_finite / is_countable discriminators the cardinality ladder uses.
  • dedekind::sets::ℵ<N> (existing) — is_finite = false, is_countable = (N==0). Use ℵ_0 (= ℵ<0>) for countable infinity.

The IsDimension concept selects either via the is_finite / is_countable surface, without committing to a std::variant<> NTTP (which the numbers::natural precedent (#402) navigated for runtime values, but type-template parameters keep the carrier-side dispatch simpler at the type level).

Wikipedia: Diagonal matrix, Outer product, Tensor product of vector spaces

Note
"Wir müssen wissen, wir werden wissen." [Trans: "We must know, we will know."] — David Hilbert, Königsberg radio address (8 September 1930); inscribed on his tombstone in Göttingen. Applied here to the rule-based carriers: an intensional matrix is its rule — at any cardinality, every entry is decidable on demand without a dense representation.

Function Documentation

◆ to_dense()

template<typename F>
requires dedekind::category::IsArrow<F> && std::semiregular<typename std::remove_cvref_t<F>::Codomain> && dedekind::algebra::HasRingOperators< typename std::remove_cvref_t<F>::Codomain>
Matrix2x2V< typename std::remove_cvref_t< F >::Codomain > dedekind::linear_algebra::to_dense ( Diagonal< dim_finite< 2 >, F > const & d)
constexprexport

— Diagonal<dim_finite<2>, F>

→ Matrix2x2V<T> at finite n=2 (#372 slice d).

At finite dimension, the intensional Diagonal<dim_finite<N>, F> has a canonical dense companion: the N×N matrix with F(i) on the diagonal and T{} off-diagonal. At N = 2, that companion is Matrix2x2V<T> from :mat2x2. The arrow is one-way: every diagonal carrier projects onto a dense matrix; the reverse direction (recognising rank-≤2 sparsity in a dense matrix) is not universally well-defined and stays out of scope.

This is the bridge between the intensional rank-1 / diagonal carriers from #534 and the existing 2×2 worked instance from #500. The diagonal subalgebra of End(V_2(T)) = M_2(T) lives literally inside Matrix2x2V<T> under this arrow.