C(++)ECCO
C++ Error Control COding: a header-only library for ECC simulations and experiments, modeling complete coding systems across arbitrary finite fields and complex inter-field relationships - Christian Senger <senger@inue.uni-stuttgart.de>
Loading...
Searching...
No Matches
CECCO::Vector< T > Class Template Reference

Vector v = (v₀, v₁, …, vₙ₋₁) over a CECCO::ComponentType. More...

#include <vectors.hpp>

Public Types

enum  CacheIds { Weight = 0 }

Public Member Functions

template<FiniteFieldType S>
Vector< T > & operator= (const Vector< S > &other)
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector< T > & append (U &&rhs)
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector< T > & prepend (U &&lhs)
template<typename U>
requires std::convertible_to<std::decay_t<U>, T>
Vector< T > & set_component (size_t i, U &&c)
Constructors
constexpr Vector () noexcept
 Default constructor: empty vector (length 0).
 Vector (size_t n)
 Length-n vector with default-initialised components (T() = 0).
 Vector (size_t n, const T &l)
 Length-n vector with every component equal to l.
 Vector (const std::initializer_list< T > &l)
 From an initializer list of components, in order.
 Vector (const Vector &other)
constexpr Vector (Vector &&other) noexcept
template<FiniteFieldType S>
requires FiniteFieldType<T> && ExtensionOf<S, T>
 Vector (const Matrix< S > &mat)
 From a matrix over a subfield: each column becomes one T component.
template<FiniteFieldType S>
 Vector (const Vector< S > &other)
 Cross-field conversion between two finite fields of the same characteristic.
 Vector (const Polynomial< T > &poly)
 From polynomial coefficients: component i becomes poly[i].
Assignment Operators
constexpr Vectoroperator= (const Vector &rhs)
constexpr Vectoroperator= (Vector &&rhs) noexcept
constexpr Vectoroperator= (const T &rhs) noexcept
 Set every component to rhs.
template<FiniteFieldType S>
Vectoroperator= (const Vector< S > &other)
 Cross-field assignment (same semantics as the cross-field constructor).
Unary Arithmetic Operations
constexpr Vector operator+ () const &noexcept
 Unary + (lvalue): returns a copy.
constexpr Vector operator+ () &&noexcept
 Unary + (rvalue): returns the rvalue itself.
constexpr Vector operator- () const &
 Unary (lvalue): returns a new vector with each component negated.
constexpr Vector operator- () &&noexcept
 Unary (rvalue): negates components in place.
Compound Assignment Operations
Vectoroperator+= (const Vector &rhs)
 Component-wise addition this[i] += rhs[i].
Vectoroperator-= (const Vector &rhs)
 Component-wise subtraction this[i] -= rhs[i].
constexpr Vectoroperator*= (const T &s) noexcept
 Multiply every component by the scalar s.
Vectoroperator/= (const T &s)
 Divide every component by the scalar s.
Randomization
Vectorrandomize () noexcept
 Replace components with random values appropriate for T.
Vectorrandomize_nonzero () noexcept
 Like randomize but every component is guaranteed non-zero.
Vectorrandomize_pairwise_distinct ()
 Fill with pairwise distinct field elements (shuffled labels 0, …, q − 1).
Information and Properties
constexpr size_t get_n () const noexcept
 Vector length (number of components).
constexpr bool is_empty () const noexcept
 True iff length is 0 (distinct from a non-empty all-zero vector).
constexpr bool is_zero () const noexcept
 True iff every component equals T(0); also true for the empty vector.
constexpr bool is_pairwise_distinct () const
 True iff no two components are equal.
std::vector< size_t > supp () const
 Sorted indices of non-zero components (empty vector for an all-zero input).
size_t wH () const noexcept
 Hamming weight: number of non-zero, non-erased components; cached on first call.
constexpr size_t burst_length () const noexcept
 Burst length R − L + 1, where L, R are the first and last non-zero indices; 0 for an all-zero or empty vector.
constexpr size_t cyclic_burst_length () const noexcept
 Cyclic burst length: shortest circular arc covering all non-zero positions; 0 for an all-zero or empty vector.
Component Access and Manipulation
template<typename U>
requires std::convertible_to<std::decay_t<U>, T>
Vectorset_component (size_t i, U &&c)
 Set component i by perfect-forwarding c.
const T & operator[] (size_t i) const
 Read access to component i.
Vector get_subvector (size_t i, size_t w) const &
 Extract the contiguous subvector [i, i + w).
Vectorget_subvector (size_t i, size_t w) &&
 In-place rvalue overload of get_subvector (truncates to [i, i + w)).
Vectorset_subvector (const Vector &v, size_t i)
 Overwrite components [i, i + v.get_n()) with v.
Vectorset_subvector (Vector &&v, size_t i)
 Rvalue overload of set_subvector (move-assigns components from v).
Vectorappend (const Vector &rhs)
 Append rhs: result becomes [*this | rhs].
Vectorappend (Vector &&rhs)
 Rvalue overload of append (moves components from rhs).
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vectorappend (U &&rhs)
 Append after converting rhs to Vector<T>.
Vectorprepend (const Vector &rhs)
 Prepend rhs: result becomes [rhs | *this].
Vectorprepend (Vector &&rhs)
 Rvalue overload of prepend (moves components from rhs).
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vectorprepend (U &&lhs)
 Prepend after converting lhs to Vector<T>.
Vectordelete_components (const std::vector< size_t > &v)
 Delete the components whose indices appear in v and compact.
Vectordelete_component (size_t i)
 Delete component i (single-index convenience for delete_components).
Vectorerase_components (const std::vector< size_t > &v)
 Mark every component whose index appears in v as erased.
Vectorerase_component (size_t i)
 Erase component i (single-index convenience for erase_components).
Vectorunerase_components (const std::vector< size_t > &v)
 Clear the erasure flag on every component whose index appears in v (resets to T(0)).
Vectorunerase_component (size_t i)
 Un-erase component i (single-index convenience for unerase_components).
Vectorpad_front (size_t n)
 Prepend zeros so the vector has length at least n (no-op if already ≥ n).
Vectorpad_back (size_t n)
 Append zeros so the vector has length at least n (no-op if already ≥ n).
Transformations
constexpr Vectorrotate_left (size_t i) noexcept
 Circular left shift by i positions: j ↦ (j − i) mod n.
constexpr Vectorrotate_right (size_t i) noexcept
 Circular right shift by i positions: j ↦ (j + i) mod n.
constexpr Vectorreverse () noexcept
 Reverse component order: i ↦ n − 1 − i.
constexpr Vectorfill (const T &value) noexcept
 Set every component to value.
Finite Field Specific Operations
size_t as_integer () const noexcept
 Interpret as a base-q integer, where q = T::get_size().
Vectorfrom_integer (size_t value, size_t n)
 Replace *this with the length-n base-q encoding of value.
template<FiniteFieldType S>
requires FiniteFieldType<T> && SubfieldOf<T, S> && (!std::is_same_v<T, S>)
Matrix< S > as_matrix () const
 Expand each component into its S-coefficient column.
Matrix< T > to_matrix (size_t m) const
 Reshape into an m × (n/m) matrix, row-major.

Friends

class Matrix< T >
template<ReliablyComparableType U>
constexpr bool operator== (const Vector< U > &lhs, const Vector< U > &rhs) noexcept
constexpr T inner_product (const Vector< T > &lhs, const Vector< T > &rhs)
 Inner product ⟨lhs, rhs⟩ = Σᵢ lhs[i] · rhs[i].
constexpr Vector< T > Schur_product (const Vector< T > &lhs, const Vector< T > &rhs)
 Schur (component-wise) product.
Vector unit_vector (size_t length, size_t i)
 Length-length vector with T(1) at index i and zeros elsewhere.
std::ostream & operator<< (std::ostream &os, const Vector &rhs)
 Stream output as ( c₀, c₁, …, cₙ₋₁ ).
double dE (const Vector< std::complex< double > > &lhs, const Vector< std::complex< double > > &rhs)
 Euclidean distance ‖lhs − rhs‖₂ = √(Σᵢ |lhs[i] − rhs[i]|²) for complex vectors.

Detailed Description

template<ComponentType T>
class CECCO::Vector< T >

Vector v = (v₀, v₁, …, vₙ₋₁) over a CECCO::ComponentType.

Template Parameters
TComponent type satisfying CECCO::ComponentType (finite field, double, std::complex<double>, or signed integer including InfInt)

Components are stored contiguously; length is fixed except via the explicit resizers (pad_front, pad_back, append, prepend, delete_components, …). Dimension mismatches in arithmetic throw std::invalid_argument. Hamming weight is computed lazily and cached; the cache is invalidated on any mutation. Methods that compare against zero (wH, supp, burst_length, …) are gated by requires ReliablyComparableType<T>.

Cross-field constructors and assignment operators between two finite fields of the same characteristic route through CECCO::details::largest_common_subfield_t, so vectors over fields from disjoint construction towers can interoperate.

Usage_Example

using F4 = Ext<Fp<2>, MOD{1, 1, 1}>;
Vector<F4> v = {0, 1, 2, 3};
size_t weight = v.wH(); // Hamming weight (cached)
size_t burst = v.burst_length();
auto M = v.as_matrix<Fp<2>>(); // 2 × 4 matrix over 𝔽₂ (𝔽₂ ⊆ 𝔽₄)
Extension field 𝔽_{q^m} ≅ B[x]/(f(x)), constructed from a base field and an irreducible monic modulus...
Definition fields.hpp:2221
Vector v = (v₀, v₁, …, vₙ₋₁) over a CECCO::ComponentType.
Definition vectors.hpp:115
Matrix< S > as_matrix() const
Expand each component into its S-coefficient column.
Definition vectors.hpp:1092
size_t wH() const noexcept
Hamming weight: number of non-zero, non-erased components; cached on first call.
Definition vectors.hpp:307
constexpr size_t burst_length() const noexcept
Burst length R − L + 1, where L, R are the first and last non-zero indices; 0 for an all-zero or empt...
Definition vectors.hpp:953
#define MOD
Alias for std::array, used to spell modulus polynomials in CECCO::Ext.

Definition at line 115 of file vectors.hpp.

Member Enumeration Documentation

◆ CacheIds

template<ComponentType T>
enum CECCO::Vector::CacheIds
Enumerator
Weight 

Definition at line 127 of file vectors.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( )
inlineconstexprnoexcept

Default constructor: empty vector (length 0).

Definition at line 134 of file vectors.hpp.

◆ Vector() [2/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( size_t n)
inlineexplicit

Length-n vector with default-initialised components (T() = 0).

Definition at line 137 of file vectors.hpp.

◆ Vector() [3/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( size_t n,
const T & l )

Length-n vector with every component equal to l.

Definition at line 522 of file vectors.hpp.

◆ Vector() [4/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( const std::initializer_list< T > & l)
inline

From an initializer list of components, in order.

Definition at line 143 of file vectors.hpp.

◆ Vector() [5/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( const Vector< T > & other)

Definition at line 525 of file vectors.hpp.

◆ Vector() [6/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( Vector< T > && other)
constexprnoexcept

Definition at line 528 of file vectors.hpp.

◆ Vector() [7/9]

template<ComponentType T>
requires FiniteFieldType<T> && ExtensionOf<S, T>
template<FiniteFieldType S>
requires FiniteFieldType<T> && ExtensionOf<S, T>
CECCO::Vector< T >::Vector ( const Matrix< S > & mat)

From a matrix over a subfield: each column becomes one T component.

Template Parameters
SSubfield of T (in the construction tower)
Exceptions
std::invalid_argumentif mat.get_m() does not match [T:S] (the extension degree of T over S)

Definition at line 532 of file vectors.hpp.

◆ Vector() [8/9]

template<ComponentType T>
template<FiniteFieldType S>
CECCO::Vector< T >::Vector ( const Vector< S > & other)

Cross-field conversion between two finite fields of the same characteristic.

Template Parameters
SSource field type (Vector<S>); must share characteristic with T

Converts component by component via T's cross-field constructor, which routes through CECCO::details::largest_common_subfield_t and so handles disjoint construction towers. Propagates std::invalid_argument if any component is not representable in T.

Definition at line 547 of file vectors.hpp.

◆ Vector() [9/9]

template<ComponentType T>
CECCO::Vector< T >::Vector ( const Polynomial< T > & poly)

From polynomial coefficients: component i becomes poly[i].

Resulting length is poly.degree() + 1. For cross-field conversion, convert the polynomial first.

Definition at line 555 of file vectors.hpp.

Member Function Documentation

◆ append() [1/4]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::append ( const Vector< T > & rhs)

Append rhs: result becomes [*this | rhs].

Definition at line 649 of file vectors.hpp.

◆ append() [2/4]

template<ComponentType T>
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector< T > & CECCO::Vector< T >::append ( U && rhs)

Definition at line 696 of file vectors.hpp.

◆ append() [3/4]

template<ComponentType T>
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector & CECCO::Vector< T >::append ( U && rhs)

Append after converting rhs to Vector<T>.

◆ append() [4/4]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::append ( Vector< T > && rhs)

Rvalue overload of append (moves components from rhs).

Definition at line 662 of file vectors.hpp.

◆ as_integer()

template<ComponentType T>
requires FiniteFieldType<T>
size_t CECCO::Vector< T >::as_integer ( ) const
noexcept

Interpret as a base-q integer, where q = T::get_size().

Component data[n − 1 − i] is the i-th digit (least-significant first), so the value is Σ data[n − 1 − i] · qⁱ.

Note
May overflow size_t for large vectors over large fields.

Definition at line 1062 of file vectors.hpp.

◆ as_matrix()

template<ComponentType T>
requires FiniteFieldType<T> && SubfieldOf<T, S> && (!std::is_same_v<T, S>)
template<FiniteFieldType S>
requires FiniteFieldType<T> && SubfieldOf<T, S> && (!std::is_same_v<T, S>)
Matrix< S > CECCO::Vector< T >::as_matrix ( ) const

Expand each component into its S-coefficient column.

Template Parameters
SSubfield of T
Returns
[T:S] × get_n() matrix whose column j is data[j].as_vector<S>()
Note
Under CECCO_ERASURE_SUPPORT, an erased component j produces an entirely erased column j.

Definition at line 1092 of file vectors.hpp.

◆ burst_length()

template<ComponentType T>
size_t CECCO::Vector< T >::burst_length ( ) const
constexprnoexcept

Burst length R − L + 1, where L, R are the first and last non-zero indices; 0 for an all-zero or empty vector.

Definition at line 953 of file vectors.hpp.

◆ cyclic_burst_length()

template<ComponentType T>
size_t CECCO::Vector< T >::cyclic_burst_length ( ) const
constexprnoexcept

Cyclic burst length: shortest circular arc covering all non-zero positions; 0 for an all-zero or empty vector.

Definition at line 969 of file vectors.hpp.

◆ delete_component()

template<ComponentType T>
Vector & CECCO::Vector< T >::delete_component ( size_t i)
inline

Delete component i (single-index convenience for delete_components).

Exceptions
std::invalid_argumentif i is out of bounds

Definition at line 394 of file vectors.hpp.

◆ delete_components()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::delete_components ( const std::vector< size_t > & v)

Delete the components whose indices appear in v and compact.

Parameters
vIndices (deduplicated internally)
Exceptions
std::invalid_argumentif any index in v is out of bounds

Definition at line 721 of file vectors.hpp.

◆ erase_component()

template<ComponentType T>
Vector & CECCO::Vector< T >::erase_component ( size_t i)
inline

Erase component i (single-index convenience for erase_components).

Definition at line 411 of file vectors.hpp.

◆ erase_components()

template<ComponentType T>
requires FieldType<T>
Vector< T > & CECCO::Vector< T >::erase_components ( const std::vector< size_t > & v)

Mark every component whose index appears in v as erased.

Parameters
vIndices (deduplicated internally)
Exceptions
std::invalid_argumentif any index in v is out of bounds
Warning
Erased components must not participate in field arithmetic — see CECCO_ERASURE_SUPPORT.

Definition at line 746 of file vectors.hpp.

◆ fill()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::fill ( const T & value)
constexprnoexcept

Set every component to value.

Definition at line 818 of file vectors.hpp.

◆ from_integer()

template<ComponentType T>
requires FiniteFieldType<T>
Vector< T > & CECCO::Vector< T >::from_integer ( size_t value,
size_t n )

Replace *this with the length-n base-q encoding of value.

Left inverse of as_integer: v.from_integer(v.as_integer(), v.get_n()) == v.

Exceptions
std::out_of_rangeif value does not fit into n base-q digits

Definition at line 1072 of file vectors.hpp.

◆ get_n()

template<ComponentType T>
size_t CECCO::Vector< T >::get_n ( ) const
inlineconstexprnoexcept

Vector length (number of components).

Definition at line 278 of file vectors.hpp.

◆ get_subvector() [1/2]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::get_subvector ( size_t i,
size_t w ) &&

In-place rvalue overload of get_subvector (truncates to [i, i + w)).

Definition at line 882 of file vectors.hpp.

◆ get_subvector() [2/2]

template<ComponentType T>
Vector< T > CECCO::Vector< T >::get_subvector ( size_t i,
size_t w ) const &

Extract the contiguous subvector [i, i + w).

Exceptions
std::invalid_argumentif [i, i + w) exceeds the vector

Definition at line 871 of file vectors.hpp.

◆ is_empty()

template<ComponentType T>
bool CECCO::Vector< T >::is_empty ( ) const
inlineconstexprnoexcept

True iff length is 0 (distinct from a non-empty all-zero vector).

Definition at line 281 of file vectors.hpp.

◆ is_pairwise_distinct()

template<ComponentType T>
requires ReliablyComparableType<T>
bool CECCO::Vector< T >::is_pairwise_distinct ( ) const
constexpr

True iff no two components are equal.

Definition at line 927 of file vectors.hpp.

◆ is_zero()

template<ComponentType T>
requires ReliablyComparableType<T>
bool CECCO::Vector< T >::is_zero ( ) const
constexprnoexcept

True iff every component equals T(0); also true for the empty vector.

Definition at line 920 of file vectors.hpp.

◆ operator*=()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator*= ( const T & s)
constexprnoexcept

Multiply every component by the scalar s.

Definition at line 630 of file vectors.hpp.

◆ operator+() [1/2]

template<ComponentType T>
Vector CECCO::Vector< T >::operator+ ( ) &&
inlineconstexprnoexcept

Unary + (rvalue): returns the rvalue itself.

Definition at line 206 of file vectors.hpp.

◆ operator+() [2/2]

template<ComponentType T>
Vector CECCO::Vector< T >::operator+ ( ) const &
inlineconstexprnoexcept

Unary + (lvalue): returns a copy.

Definition at line 204 of file vectors.hpp.

◆ operator+=()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator+= ( const Vector< T > & rhs)

Component-wise addition this[i] += rhs[i].

Exceptions
std::invalid_argumentif this->get_n() != rhs.get_n()

Definition at line 611 of file vectors.hpp.

◆ operator-() [1/2]

template<ComponentType T>
Vector< T > CECCO::Vector< T >::operator- ( ) &&
constexprnoexcept

Unary (rvalue): negates components in place.

Definition at line 605 of file vectors.hpp.

◆ operator-() [2/2]

template<ComponentType T>
Vector< T > CECCO::Vector< T >::operator- ( ) const &
constexpr

Unary (lvalue): returns a new vector with each component negated.

Definition at line 598 of file vectors.hpp.

◆ operator-=()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator-= ( const Vector< T > & rhs)

Component-wise subtraction this[i] -= rhs[i].

Exceptions
std::invalid_argumentif this->get_n() != rhs.get_n()

Definition at line 619 of file vectors.hpp.

◆ operator/=()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator/= ( const T & s)

Divide every component by the scalar s.

Exceptions
std::invalid_argumentif s == T(0)
Note
Round-trip (v / s) * s == v is only guaranteed when T satisfies CECCO::FieldType (otherwise integer rounding may corrupt components).

Definition at line 642 of file vectors.hpp.

◆ operator=() [1/5]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator= ( const T & rhs)
constexprnoexcept

Set every component to rhs.

Definition at line 579 of file vectors.hpp.

◆ operator=() [2/5]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator= ( const Vector< T > & rhs)
constexpr

Definition at line 563 of file vectors.hpp.

◆ operator=() [3/5]

template<ComponentType T>
template<FiniteFieldType S>
Vector< T > & CECCO::Vector< T >::operator= ( const Vector< S > & other)

Definition at line 588 of file vectors.hpp.

◆ operator=() [4/5]

template<ComponentType T>
template<FiniteFieldType S>
Vector & CECCO::Vector< T >::operator= ( const Vector< S > & other)

Cross-field assignment (same semantics as the cross-field constructor).

◆ operator=() [5/5]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::operator= ( Vector< T > && rhs)
constexprnoexcept

Definition at line 571 of file vectors.hpp.

◆ operator[]()

template<ComponentType T>
const T & CECCO::Vector< T >::operator[] ( size_t i) const

Read access to component i.

Exceptions
std::invalid_argumentif i is out of bounds

Definition at line 865 of file vectors.hpp.

◆ pad_back()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::pad_back ( size_t n)

Append zeros so the vector has length at least n (no-op if already ≥ n).

Definition at line 809 of file vectors.hpp.

◆ pad_front()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::pad_front ( size_t n)

Prepend zeros so the vector has length at least n (no-op if already ≥ n).

Definition at line 798 of file vectors.hpp.

◆ prepend() [1/4]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::prepend ( const Vector< T > & rhs)

Prepend rhs: result becomes [rhs | *this].

Definition at line 672 of file vectors.hpp.

◆ prepend() [2/4]

template<ComponentType T>
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector< T > & CECCO::Vector< T >::prepend ( U && lhs)

Definition at line 709 of file vectors.hpp.

◆ prepend() [3/4]

template<ComponentType T>
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector & CECCO::Vector< T >::prepend ( U && lhs)

Prepend after converting lhs to Vector<T>.

◆ prepend() [4/4]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::prepend ( Vector< T > && rhs)

Rvalue overload of prepend (moves components from rhs).

Definition at line 685 of file vectors.hpp.

◆ randomize()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::randomize ( )
noexcept

Replace components with random values appropriate for T.

Distribution per component: finite-field types draw uniformly from the field; signed integers from [−100, 100]; double and the parts of std::complex<double> from [−1, 1].

Definition at line 1013 of file vectors.hpp.

◆ randomize_nonzero()

template<ComponentType T>
requires FieldType<T>
Vector< T > & CECCO::Vector< T >::randomize_nonzero ( )
noexcept

Like randomize but every component is guaranteed non-zero.

Definition at line 1032 of file vectors.hpp.

◆ randomize_pairwise_distinct()

template<ComponentType T>
requires FiniteFieldType<T>
Vector< T > & CECCO::Vector< T >::randomize_pairwise_distinct ( )

Fill with pairwise distinct field elements (shuffled labels 0, …, q − 1).

Exceptions
std::invalid_argumentif the vector length exceeds the field cardinality q

Definition at line 1044 of file vectors.hpp.

◆ reverse()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::reverse ( )
constexprnoexcept

Reverse component order: i ↦ n − 1 − i.

Definition at line 841 of file vectors.hpp.

◆ rotate_left()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::rotate_left ( size_t i)
constexprnoexcept

Circular left shift by i positions: j ↦ (j − i) mod n.

Definition at line 829 of file vectors.hpp.

◆ rotate_right()

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::rotate_right ( size_t i)
constexprnoexcept

Circular right shift by i positions: j ↦ (j + i) mod n.

Definition at line 835 of file vectors.hpp.

◆ set_component() [1/2]

template<ComponentType T>
template<typename U>
requires std::convertible_to<std::decay_t<U>, T>
Vector< T > & CECCO::Vector< T >::set_component ( size_t i,
U && c )

Definition at line 848 of file vectors.hpp.

◆ set_component() [2/2]

template<ComponentType T>
template<typename U>
requires std::convertible_to<std::decay_t<U>, T>
Vector & CECCO::Vector< T >::set_component ( size_t i,
U && c )

Set component i by perfect-forwarding c.

Exceptions
std::invalid_argumentif i is out of bounds

◆ set_subvector() [1/2]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::set_subvector ( const Vector< T > & v,
size_t i )

Overwrite components [i, i + v.get_n()) with v.

Exceptions
std::invalid_argumentif the replacement region exceeds the vector

Definition at line 894 of file vectors.hpp.

◆ set_subvector() [2/2]

template<ComponentType T>
Vector< T > & CECCO::Vector< T >::set_subvector ( Vector< T > && v,
size_t i )

Rvalue overload of set_subvector (move-assigns components from v).

Definition at line 907 of file vectors.hpp.

◆ supp()

template<ComponentType T>
std::vector< size_t > CECCO::Vector< T >::supp ( ) const
inline

Sorted indices of non-zero components (empty vector for an all-zero input).

Exceptions
std::invalid_argumentif *this is empty (length 0)

Definition at line 296 of file vectors.hpp.

◆ to_matrix()

template<ComponentType T>
Matrix< T > CECCO::Vector< T >::to_matrix ( size_t m) const

Reshape into an m × (n/m) matrix, row-major.

Inverse of Matrix::to_vector: index k of this vector lands at (k/cols, kcols) with cols = n/m.

Exceptions
std::invalid_argumentif m does not divide the vector length

Definition at line 1125 of file vectors.hpp.

◆ unerase_component()

template<ComponentType T>
Vector & CECCO::Vector< T >::unerase_component ( size_t i)
inline

Un-erase component i (single-index convenience for unerase_components).

Definition at line 427 of file vectors.hpp.

◆ unerase_components()

template<ComponentType T>
requires FieldType<T>
Vector< T > & CECCO::Vector< T >::unerase_components ( const std::vector< size_t > & v)

Clear the erasure flag on every component whose index appears in v (resets to T(0)).

Parameters
vIndices (deduplicated internally)
Exceptions
std::invalid_argumentif any index in v is out of bounds

Definition at line 764 of file vectors.hpp.

◆ wH()

template<ComponentType T>
size_t CECCO::Vector< T >::wH ( ) const
inlinenoexcept

Hamming weight: number of non-zero, non-erased components; cached on first call.

Definition at line 307 of file vectors.hpp.

◆ dE

template<ComponentType T>
double dE ( const Vector< std::complex< double > > & lhs,
const Vector< std::complex< double > > & rhs )
friend

Euclidean distance ‖lhs − rhs‖₂ = √(Σᵢ |lhs[i] − rhs[i]|²) for complex vectors.

Exceptions
std::invalid_argumentif lengths differ

Definition at line 1651 of file vectors.hpp.

◆ inner_product

template<ComponentType T>
T inner_product ( const Vector< T > & lhs,
const Vector< T > & rhs )
friend

Inner product ⟨lhs, rhs⟩ = Σᵢ lhs[i] · rhs[i].

For complex inputs this is the standard product (not the conjugate inner product).

Exceptions
std::invalid_argumentif lengths differ

Definition at line 1513 of file vectors.hpp.

◆ Matrix< T >

template<ComponentType T>
friend class Matrix< T >
friend

Definition at line 122 of file vectors.hpp.

◆ operator<<

template<ComponentType T>
std::ostream & operator<< ( std::ostream & os,
const Vector< T > & rhs )
friend

Stream output as ( c₀, c₁, …, cₙ₋₁ ).

Definition at line 1562 of file vectors.hpp.

◆ operator==

template<ComponentType T>
template<ReliablyComparableType U>
bool operator== ( const Vector< U > & lhs,
const Vector< U > & rhs )
friend

◆ Schur_product

template<ComponentType T>
Vector< T > Schur_product ( const Vector< T > & lhs,
const Vector< T > & rhs )
friend

Schur (component-wise) product.

Exceptions
std::invalid_argumentif lengths differ

Definition at line 1526 of file vectors.hpp.

◆ unit_vector

template<ComponentType T>
Vector unit_vector ( size_t length,
size_t i )
friend

Length-length vector with T(1) at index i and zeros elsewhere.

Exceptions
std::invalid_argumentif i >= length

Definition at line 1552 of file vectors.hpp.


The documentation for this class was generated from the following files: