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
vectors.hpp File Reference

Vector arithmetic library. More...

#include <initializer_list>
#include <numeric>
#include <unordered_set>
#include "matrices.hpp"
Include dependency graph for vectors.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

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

Namespaces

namespace  CECCO
 Provides a framework for error correcting codes.
namespace  CECCO::details
 Contains implementation details not to be exposed to the user. Functions and classes here may change without notice.

Functions

template<ComponentType T>
CECCO::inner_product (const Vector< T > &lhs, const Vector< T > &rhs)
 Inner product ⟨lhs, rhs⟩ = Σᵢ lhs[i] · rhs[i].
template<ComponentType T>
Vector< T > CECCO::Schur_product (const Vector< T > &lhs, const Vector< T > &rhs)
 Schur (component-wise) product.
template<ComponentType T>
Vector< T > CECCO::unit_vector (size_t length, size_t i)
 Length-length vector with T(1) at index i and zeros elsewhere.
template<ComponentType T>
std::ostream & CECCO::operator<< (std::ostream &os, const Vector< T > &rhs)
 Stream output as ( c₀, c₁, …, cₙ₋₁ ).
template<ComponentType T>
Vector< T > CECCO::delete_component (const Vector< T > &lhs, size_t i)
template<ComponentType T>
Vector< T > CECCO::delete_component (Vector< T > &&lhs, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::operator+ (const Vector< T > &lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator+ (Vector< T > &&lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator+ (const Vector< T > &lhs, Vector< T > &&rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator+ (Vector< T > &&lhs, Vector< T > &&rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator- (const Vector< T > &lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator- (Vector< T > &&lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator- (const Vector< T > &lhs, Vector< T > &&rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator- (Vector< T > &&lhs, Vector< T > &&rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::operator* (const Vector< T > &lhs, const T &rhs) noexcept
template<ComponentType T>
constexpr Vector< T > CECCO::operator* (Vector< T > &&lhs, const T &rhs) noexcept
template<ComponentType T>
constexpr Vector< T > CECCO::operator* (const T &lhs, const Vector< T > &rhs) noexcept
template<ComponentType T>
constexpr Vector< T > CECCO::operator* (const T &lhs, Vector< T > &&rhs) noexcept
template<ComponentType T>
constexpr Vector< T > CECCO::operator/ (const Vector< T > &lhs, const T &rhs)
template<FieldType T>
constexpr Vector< T > CECCO::operator/ (Vector< T > &&lhs, const T &rhs)
template<ComponentType T>
Vector< T > CECCO::convolve (const Vector< T > &v, const Vector< T > &w)
 Discrete linear convolution (= coefficients of Polynomial(v) * Polynomial(w)).
template<ComponentType T>
Vector< T > CECCO::randomize (const Vector< T > &v)
template<ComponentType T>
Vector< T > CECCO::randomize (Vector< T > &&v)
template<ComponentType T>
Vector< T > CECCO::set_component (const Vector< T > &v, size_t i, const T &c)
template<ComponentType T>
Vector< T > CECCO::set_component (Vector< T > &&v, size_t i, const T &c)
template<ComponentType T>
constexpr Vector< T > CECCO::get_subvector (const Vector< T > &v, size_t start, size_t end)
template<ComponentType T>
constexpr Vector< T > CECCO::get_subvector (Vector< T > &&v, size_t start, size_t end)
template<ComponentType T>
constexpr Vector< T > CECCO::set_subvector (Vector< T > v, size_t start, const Vector< T > &w)
template<ComponentType T>
constexpr Vector< T > CECCO::set_subvector (Vector< T > &&v, size_t start, const Vector< T > &w)
template<ComponentType T>
constexpr Vector< T > CECCO::concatenate (const Vector< T > &lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::concatenate (Vector< T > &&lhs, const Vector< T > &rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::concatenate (const Vector< T > &lhs, Vector< T > &&rhs)
template<ComponentType T>
constexpr Vector< T > CECCO::concatenate (Vector< T > &&lhs, Vector< T > &&rhs)
template<ComponentType T>
Vector< T > CECCO::delete_components (const Vector< T > &lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::delete_components (Vector< T > &&lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::erase_components (const Vector< T > &lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::erase_components (Vector< T > &&lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::erase_component (const Vector< T > &lhs, size_t i)
template<ComponentType T>
Vector< T > CECCO::erase_component (Vector< T > &&lhs, size_t i)
template<ComponentType T>
Vector< T > CECCO::unerase_components (const Vector< T > &lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::unerase_components (Vector< T > &&lhs, const std::vector< size_t > &v)
template<ComponentType T>
Vector< T > CECCO::unerase_component (const Vector< T > &lhs, size_t i)
template<ComponentType T>
Vector< T > CECCO::unerase_component (Vector< T > &&lhs, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::pad_front (const Vector< T > &v, size_t n)
template<ComponentType T>
constexpr Vector< T > CECCO::pad_front (Vector< T > &&v, size_t n)
template<ComponentType T>
constexpr Vector< T > CECCO::pad_back (const Vector< T > &v, size_t n)
template<ComponentType T>
constexpr Vector< T > CECCO::pad_back (Vector< T > &&v, size_t n)
template<ComponentType T>
constexpr Vector< T > CECCO::rotate_left (const Vector< T > &v, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::rotate_left (Vector< T > &&v, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::rotate_right (const Vector< T > &v, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::rotate_right (Vector< T > &&v, size_t i)
template<ComponentType T>
constexpr Vector< T > CECCO::reverse (const Vector< T > &v)
template<ComponentType T>
constexpr Vector< T > CECCO::reverse (Vector< T > &&v)
template<ComponentType T>
constexpr Vector< T > CECCO::fill (const Vector< T > &v, const T &value)
template<ComponentType T>
constexpr Vector< T > CECCO::fill (Vector< T > &&v, const T &value)
template<ReliablyComparableType T>
constexpr bool CECCO::operator== (const Vector< T > &lhs, const Vector< T > &rhs) noexcept
template<ReliablyComparableType T>
constexpr bool CECCO::operator!= (const Vector< T > &lhs, const Vector< T > &rhs) noexcept
Error control coding-related functions
double CECCO::dE (const Vector< std::complex< double > > &lhs, const Vector< std::complex< double > > &rhs)
 Euclidean distance ‖lhs − rhs‖₂ = √(Σᵢ |lhs[i] − rhs[i]|²) for complex vectors.
template<ReliablyComparableType T>
constexpr size_t CECCO::wH (const Vector< T > &v) noexcept
 Hamming weight; see Vector::wH for semantics.
template<ReliablyComparableType T>
std::vector< size_t > CECCO::supp (const Vector< T > &v)
 Support; see Vector::supp for semantics.
template<ReliablyComparableType T>
size_t CECCO::dH (const Vector< T > &lhs, const Vector< T > &rhs)
 Hamming distance dₕ(lhs, rhs) = wₕ(lhs − rhs).
template<ReliablyComparableType T>
size_t CECCO::dH (Vector< T > &&lhs, const Vector< T > &rhs)
template<ReliablyComparableType T>
size_t CECCO::dH (const Vector< T > &lhs, Vector< T > &&rhs)
template<ReliablyComparableType T>
size_t CECCO::dH (Vector< T > &&lhs, Vector< T > &&rhs)
template<ReliablyComparableType T>
constexpr size_t CECCO::burst_length (const Vector< T > &v) noexcept
 Burst length; see Vector::burst_length for semantics.
template<ReliablyComparableType T>
constexpr size_t CECCO::cyclic_burst_length (const Vector< T > &v) noexcept
 Cyclic burst length; see Vector::cyclic_burst_length for semantics.

Detailed Description

Vector arithmetic library.

Author
Christian Senger senge.nosp@m.r@in.nosp@m.ue.un.nosp@m.i-st.nosp@m.uttga.nosp@m.rt.d.nosp@m.e
Version
2.1.8
Date
2026

Licensed for noncommercial use only, including academic teaching, research, and personal non-profit purposes. Commercial use is prohibited without a separate commercial license. See the LICENSE file in the repository root for full terms and how to request a commercial license.

Description

Vector arithmetic for error-control coding over any CECCO::ComponentType (finite fields, floating-point, complex, signed integers including InfInt). Supports safe cross-field conversions via CECCO::SubfieldOf / CECCO::ExtensionOf / CECCO::largest_common_subfield_t, bidirectional Vector ↔ Matrix integration, and lazy O(1) caching of Hamming weight / burst length.

Usage_Example

// Basic vector operations
Vector<int> u = {1, 2, 3, 4};
Vector<int> v(4, 5); // Vector of length 4, all components = 5
auto w = u + v; // Element-wise addition
int dot = inner_product(u, v); // Inner product
// Finite field vectors
using F4 = Ext<Fp<2>, MOD{1, 1, 1}>;
Vector<F4> x = {0, 1, 2, 3};
size_t weight = x.wH(); // Hamming weight
size_t distance = dH(x, Vector<F4>(4)); // Hamming distance to zero vector
// Cross-field upcast (𝔽_2 ⊆ 𝔽_4 via construction tower)
Vector<Fp<2>> y = {1, 0, 1, 1};
Vector<F4> z(y);
#define MOD
Alias for std::array, used to spell modulus polynomials in CECCO::Ext.
size_t dH(const Vector< T > &lhs, const Vector< T > &rhs)
Hamming distance dₕ(lhs, rhs) = wₕ(lhs − rhs).
Definition vectors.hpp:1600
See also
fields.hpp, matrices.hpp, field_concepts_traits.hpp

Definition in file vectors.hpp.