Dedekind 0.0.0
A structuralist C++23 Module Library
Loading...
Searching...
No Matches
dedekind::linear_algebra::Vec2V< T > Struct Template Referenceexport

Value-level column vector of length 2, viewed as a 2×1 matrix. More...

Collaboration diagram for dedekind::linear_algebra::Vec2V< T >:

Classes

struct  ArrowView
 Named-pair view via operator->. More...

Public Types

using scalar_type = T
using orientation = ColumnOrientation
using dimension_type = dedekind::sets::Finite

Public Member Functions

template<typename Idx>
requires dedekind::order::IsDirectedSet<Idx> && std::convertible_to<Idx, std::size_t>
constexpr T operator[] (Idx const &i) const
 Indexed projection. Semantics match row()/column() in the matrix family: i=0 returns x, i=1 returns y, out-of-range returns T{} (the zero element). Returned by value to avoid the m[i][j]-style dangling-reference trap when binding to a reference.
template<std::integral U, U I>
requires (static_cast<std::size_t>(I) < dimension)
constexpr T operator[] (std::integral_constant< U, I >) const
 Halfspace-gated static-index overload (#372 slice b).
constexpr ArrowView operator-> () const
constexpr Covec2V< T > transpose () const
 Transpose to the dual covector: column → row.

Public Attributes

T x {}
T y {}

Static Public Attributes

static constexpr std::size_t dimension = 2
static constexpr std::size_t row_count = 2
static constexpr std::size_t column_count = 1

Friends

constexpr bool operator== (const Vec2V &, const Vec2V &)=default
constexpr Vec2V operator+ (const Vec2V &a, const Vec2V &b)
constexpr Vec2V operator- (const Vec2V &a, const Vec2V &b)
constexpr Vec2V operator- (const Vec2V &a)
constexpr Vec2V operator* (const T &s, const Vec2V &a)
constexpr Vec2V operator* (const Vec2V &a, const T &s)

Detailed Description

template<typename T>
requires std::semiregular<T> && dedekind::algebra::HasRingOperators<T>
struct dedekind::linear_algebra::Vec2V< T >

Value-level column vector of length 2, viewed as a 2×1 matrix.

Carries:

  • scalar_type = T,
  • orientation = ColumnOrientation,
  • dimension = 2 (number of coordinate axes),
  • row_count = 2 / column_count = 1 (matrix shape — a column vector IS a 2×1 matrix).

Arithmetic is component-wise with a left and a right scalar action. transpose() yields the dual Covec2V<T> (a 1×2 matrix), establishing the IsTransposeDualPair<Vec2V<T>, Covec2V<T>> relationship from :contracts.

Member Function Documentation

◆ operator[]() [1/2]

template<typename T>
template<typename Idx>
requires dedekind::order::IsDirectedSet<Idx> && std::convertible_to<Idx, std::size_t>
T dedekind::linear_algebra::Vec2V< T >::operator[] ( Idx const & i) const
inlineconstexpr

Indexed projection. Semantics match row()/column() in the matrix family: i=0 returns x, i=1 returns y, out-of-range returns T{} (the zero element). Returned by value to avoid the m[i][j]-style dangling-reference trap when binding to a reference.

Categorical reading (Mac Lane CWM §IV.6): the subscript v[i] is the CCC eval counit ε: (T^2)^{2} × 2 → T applied to (v, i). Equivalently the curried form v: 2 → T in Set, with v[i] = eval(v, i). The is_eval_arrow_v trait below pins the categorical reading at the carrier site.

Idx is gated by dedekind::order::IsDirectedSet — the algebraic predicate that picks out net domains (compare sequences:net's IsNet, which requires IsDirectedSet on N::Domain). Conversion to std::size_t names the index numerically and admits bool, int, unsigned, std::size_t, ℕ, and any future intensional cardinal that converts.

◆ operator[]() [2/2]

template<typename T>
template<std::integral U, U I>
requires (static_cast<std::size_t>(I) < dimension)
T dedekind::linear_algebra::Vec2V< T >::operator[] ( std::integral_constant< U, I > ) const
inlineconstexpr

Halfspace-gated static-index overload (#372 slice b).

When the index is encoded at the type level via {std::integral_constant<U,I>} for any {std::integral U}, the dimension halfspace {[0, dimension)} is decided at compile time: out-of-range indices fail to instantiate (the requires-clause refuses them).

Subsumes both presentations:

  • {std::integral_constant<std::size_t,I>} — the size_t face; {v[std::integral_constant<size_t,2>{}]} is a type-check failure rather than a runtime fallback.
  • {std::bool_constant} (= {std::integral_constant<bool,B>}) — the 𝔹-indexed face. {Vec2V<T> ≅ 𝔹 → T} as a function space: {v[false_type] = x}, {v[true_type] = y}. Drives home the slogan "the dimension halfspace at @c n=2 @b is 𝔹".

The documentation for this struct was generated from the following file:
  • src/main/modules/dedekind/linear_algebra/vec2.cppm