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
 Default constructor: empty vector (length 0).
 Vector (size_t n)
 Length-n vector with zero-initialised components.
 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.
template<CoefficientType U>
 Vector (const Polynomial< U > &poly)
 From polynomial coefficients: component i becomes poly[i].
Assignment Operators
constexpr Vector & operator= (const Vector &rhs)
constexpr Vector & operator= (Vector &&rhs) noexcept
constexpr Vector & operator= (const T &rhs)
 Set every component to rhs.
template<FiniteFieldType S>
Vector & operator= (const Vector< S > &other)
 Cross-field assignment (same semantics as the cross-field constructor).
Unary Arithmetic Operations
constexpr Vector operator+ () const &
 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- () &&
 Unary − (rvalue): negates components in place.
Compound Assignment Operations
Vector & operator+= (const Vector &rhs)
 Component-wise addition this[i] += rhs[i].
Vector & operator-= (const Vector &rhs)
 Component-wise subtraction this[i] -= rhs[i].
constexpr Vector & operator*= (const T &s)
 Multiply every component by the scalar s.
Vector & operator/= (const T &s)
 Divide every component by the scalar s.
Randomization
Vector & randomize ()
 Replace components with random values appropriate for T.
Vector & randomize_nonzero ()
 Like randomize but every component is guaranteed non-zero.
Vector & randomize_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
 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, non-erased components (empty vector for an input with only zeros and erasures).
size_t wH () const
 Hamming weight: number of non-zero, non-erased components; cached on first call.
constexpr size_t burst_length () const
 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
 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>
Vector & set_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).
Vector & get_subvector (size_t i, size_t w) &&
 In-place rvalue overload of get_subvector (truncates to [i, i + w)).
Vector & set_subvector (const Vector &v, size_t i)
 Overwrite components [i, i + v.get_n()) with v.
Vector & set_subvector (Vector &&v, size_t i)
 Rvalue overload of set_subvector (move-assigns components from v).
Vector & append (const Vector &rhs)
 Append rhs: result becomes [*this | rhs].
Vector & append (Vector &&rhs)
 Rvalue overload of append (moves components from rhs).
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector & append (U &&rhs)
 Append after converting rhs to Vector<T>.
Vector & prepend (const Vector &rhs)
 Prepend rhs: result becomes [rhs | *this].
Vector & prepend (Vector &&rhs)
 Rvalue overload of prepend (moves components from rhs).
template<typename U>
requires std::constructible_from<Vector<T>, U>
Vector & prepend (U &&lhs)
 Prepend after converting lhs to Vector<T>.
Vector & delete_components (const std::vector< size_t > &v)
 Delete the components whose indices appear in v and compact.
Vector & delete_component (size_t i)
 Delete component i (single-index convenience for delete_components).
Vector & erase_components (const std::vector< size_t > &v)
 Mark every component whose index appears in v as erased.
Vector & erase_component (size_t i)
 Erase component i (single-index convenience for erase_components).
Vector & unerase_components (const std::vector< size_t > &v)
 Clear the erasure flag on every component whose index appears in v (resets to T(0)).
Vector & unerase_component (size_t i)
 Un-erase component i (single-index convenience for unerase_components).
Vector & pad_front (size_t n)
 Prepend zeros so the vector has length at least n (no-op if already ≥ n).
Vector & pad_back (size_t n)
 Append zeros so the vector has length at least n (no-op if already ≥ n).
Transformations
constexpr Vector & rotate_left (size_t i)
 Circular left shift by i positions: j ↦ (j − i) mod n.
constexpr Vector & rotate_right (size_t i)
 Circular right shift by i positions: j ↦ (j + i) mod n.
constexpr Vector & reverse ()
 Reverse component order: i ↦ n − 1 − i.
constexpr Vector & fill (const T &value)
 Set every component to value.
Finite Field Specific Operations
size_t as_integer () const
 Interpret as a base-q integer, where q = T::get_size().
Vector & from_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<CoefficientType U>
class Polynomial
template<ReliablyComparableType U>
constexpr bool operator== (const Vector< U > &lhs, const Vector< U > &rhs)
T inner_product (const Vector< T > &lhs, const Vector< T > &rhs)
 Inner product ⟨lhs, rhs⟩ = Σᵢ lhs[i] · rhs[i].
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:2244
Vector v = (v₀, v₁, …, vₙ₋₁) over a CECCO::ComponentType.
Definition vectors.hpp:124
Matrix< S > as_matrix() const
Expand each component into its S-coefficient column.
Definition vectors.hpp:1174
constexpr size_t burst_length() const
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:1011
size_t wH() const
Hamming weight: number of non-zero, non-erased components; cached on first call.
Definition vectors.hpp:336
#define MOD
Alias for std::array, used to spell modulus polynomials in CECCO::Ext.

Definition at line 124 of file vectors.hpp.

Member Enumeration Documentation

◆ CacheIds

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

Definition at line 138 of file vectors.hpp.

Constructor & Destructor Documentation

◆ Vector() [1/9]

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

Default constructor: empty vector (length 0).

◆ Vector() [2/9]

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

Length-n vector with zero-initialised components.

Definition at line 148 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 560 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 156 of file vectors.hpp.

◆ Vector() [5/9]

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

Definition at line 565 of file vectors.hpp.

◆ Vector() [6/9]

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

Definition at line 568 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 574 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 589 of file vectors.hpp.

◆ Vector() [9/9]

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

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

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

Note
Member template with U fixed to T, so that instantiating a vector over polynomial components does not form the unsupported type Polynomial<Polynomial<...>>.

Definition at line 599 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 703 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 750 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 716 of file vectors.hpp.

◆ as_integer()

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

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.
Exceptions
std::invalid_argumentif any component is erased.

Definition at line 1136 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 1174 of file vectors.hpp.

◆ burst_length()

template<ComponentType T>
requires ReliablyComparableType<T>
size_t CECCO::Vector< T >::burst_length ( ) const
constexpr

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 1011 of file vectors.hpp.

◆ cyclic_burst_length()

template<ComponentType T>
requires ReliablyComparableType<T>
size_t CECCO::Vector< T >::cyclic_burst_length ( ) const
constexpr

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

Definition at line 1029 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 427 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 781 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 444 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 804 of file vectors.hpp.

◆ fill()

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

Set every component to value.

Definition at line 872 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 1154 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 301 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 941 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 930 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 304 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 985 of file vectors.hpp.

◆ is_zero()

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

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

Definition at line 977 of file vectors.hpp.

◆ operator*=()

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

Multiply every component by the scalar s.

Definition at line 678 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 224 of file vectors.hpp.

◆ operator+() [2/2]

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

Unary + (lvalue): returns a copy.

Definition at line 222 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 659 of file vectors.hpp.

◆ operator-() [1/2]

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

Unary − (rvalue): negates components in place.

Definition at line 653 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 646 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 667 of file vectors.hpp.

◆ operator/=()

template<ComponentType T>
requires CoefficientType<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 689 of file vectors.hpp.

◆ operator=() [1/5]

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

Set every component to rhs.

Definition at line 629 of file vectors.hpp.

◆ operator=() [2/5]

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

Definition at line 612 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 636 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 620 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 924 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 864 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 854 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 726 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 766 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 739 of file vectors.hpp.

◆ randomize()

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

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].

Note
Unavailable for polynomial components: randomizing a polynomial needs a degree, see CECCO::Polynomial::randomize.

Definition at line 1072 of file vectors.hpp.

◆ randomize_nonzero()

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

Like randomize but every component is guaranteed non-zero.

Definition at line 1093 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 1107 of file vectors.hpp.

◆ reverse()

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

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

Definition at line 898 of file vectors.hpp.

◆ rotate_left()

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

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

Definition at line 886 of file vectors.hpp.

◆ rotate_right()

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

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

Definition at line 892 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 905 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 953 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 965 of file vectors.hpp.

◆ supp()

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

Sorted indices of non-zero, non-erased components (empty vector for an input with only zeros and erasures).

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

Definition at line 319 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 1202 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 460 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 821 of file vectors.hpp.

◆ wH()

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

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

Definition at line 336 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 1727 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 1590 of file vectors.hpp.

◆ Matrix< T >

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

Definition at line 131 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 1639 of file vectors.hpp.

◆ operator==

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

◆ Polynomial

template<ComponentType T>
template<CoefficientType U>
friend class Polynomial
friend

Definition at line 134 of file vectors.hpp.

◆ 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 1603 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 1629 of file vectors.hpp.


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