62 template <
typename Trow,
typename Tcol,
typename NumType>
80 template <
typename T =
int,
typename NumType =
double>
83 template <
typename T,
typename NumType>
85 public LocateMixin<Vector<T, NumType>, std::pair<T, NumType>>,
103 return val < 0 ? -val : val;
131 using Pair = std::pair<T, NumType>;
181 entries(std::forward<Map>(v.entries))
198 <<
"Vector(DynList): list sizes does not match";
202 auto t = it.get_curr();
233 <<
"Vector assignment: domains must be the same";
254 <<
"Vector assignment: domains must be the same";
294 std::initializer_list<NumType>
lr)
297 <<
"size mismatch between domain and range";
299 auto itd = ld.begin();
300 auto itr =
lr.begin();
304 <<
"An item of first list doesn't belong to domain";
321 <<
"size mismatch between domain and range";
323 auto itr =
lr.begin();
324 c.for_each([
this, &
itr](
const T & key)
327 <<
"Key does not belong to domain";
517 <<
"scalar_product: different domains";
551 std::cout <<
"(" <<
k <<
"," <<
entries(
k) <<
") ";
562 std::ostringstream s;
574 typedef std::pair<std::string, std::string>
Pair;
580 const size_t fsz = p.first.size();
581 const size_t ssz = p.second.size();
583 return Pair(
" " + p.first, std::string(
fsz -
ssz + 1,
' ') + p.second);
584 return Pair(std::string(
ssz -
fsz + 1,
' ') + p.first,
" " + p.second);
598 return dstr +
"\n" + std::string(
dstr.size(),
'-') +
"\n" +
estr;
612 entry_ptr = ptr ? &ptr->second :
nullptr;
620 if (
proxy.entry_ptr ==
nullptr)
708 template <
typename T,
typename NumType>
712 template <
typename T,
typename NumType>
721 template <
typename T,
typename NumType>
725 return s <<
vec.to_str();
CRTP Mixins for container functionality (DRY principle).
Exception handling system with formatted messages for Aleph-w.
#define ah_length_error_if(C)
Throws std::length_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
Zip iterators and functional operations for multiple containers.
DRY (Don't Repeat Yourself) utilities and macros.
Functional programming utilities for Aleph-w containers.
High-level sorting functions for Aleph containers.
Integer domain classes for sparse data structures.
Generic domain class based on hash set.
Dynamic singly linked list with functional programming support.
CRTP Mixin providing functional programming operations.
Container< __Type > maps(Operation &operation) const
Transform elements using a mapping function.
size_t size() const noexcept
Count the number of elements of the list.
CRTP Mixin providing element location operations.
Sparse matrix with generic row and column domains.
CRTP Mixin providing traversal operations.
Proxy(Vector &v, const T &k) noexcept
Proxy & operator=(const Proxy &proxy)
Sparse vector implementation with domain-based indexing.
Vector(DomainPtr d, const NumType &zero=default_epsilon)
Construct a vector over a given domain (shared_ptr version)
Vector(const Domain &d, const DynList< NumType > &l, const NumType &zero=default_epsilon)
Construct vector from domain and list of values (reference version)
std::pair< T, NumType > Item_Type
const Domain & get_domain() const noexcept
Get the domain over which this vector is defined.
std::pair< T, NumType > Pair
void set_entry(const T &i, const NumType &value)
Set a vector entry at given index.
bool equal_to(const Vector &other) const noexcept
Check if this vector equals another within epsilon tolerance.
const NumType & get_epsilon() const noexcept
Get the epsilon value used for zero comparisons.
Vector(const Domain &d, const NumType &zero=default_epsilon)
Construct a vector over a given domain (reference version)
Vector & operator=(const Vector &v)
Copy assignment operator.
Iterator get_it() const noexcept
NumType * search_entry(const T &i) const noexcept
Search for an entry and return pointer to its value.
Vector(const Vector &v)
Copy constructor.
Vector operator+(const Vector &r) const
static NumType abs(const NumType &val) noexcept
bool operator==(const Vector &v) const noexcept
bool are_equal(const NumType &n1, const NumType &n2) const noexcept
Check if two numeric values are equal within epsilon.
DynList< NumType > to_list() const
bool is_zero(const NumType &val) const noexcept
static bool test_epsilon(const NumType &e) noexcept
void set_entries(const Container< T > &c, std::initializer_list< NumType > lr)
Set multiple entries using container and initializer list.
NumType get_entry(const T &i) const noexcept
Get vector entry at given index (const version)
void set_epsilon(const NumType &e) noexcept
Set the epsilon value for zero comparisons.
static const NumType default_epsilon
Proxy operator()(const T &k) const noexcept
Vector(Vector &&v) noexcept
Move constructor.
std::shared_ptr< Domain > DomainPtr
Vector(DomainPtr d, const DynList< NumType > &l, const NumType &zero=default_epsilon)
Construct vector from domain and list of values (shared_ptr version)
Proxy operator[](const T &k) const noexcept
NumType get_entry(const T &i)
Get vector entry at given index (non-const version)
void set_entries(std::initializer_list< T > ld, std::initializer_list< NumType > lr)
Set multiple entries using initializer lists.
const DomainPtr & get_domain_ptr() const noexcept
Return the shared pointer to the domain.
std::string to_str() const
Vector operator/(const NumType &scalar) const
NumType scalar_product(const Vector &v) const
Vector & operator+=(const Vector &v)
Vector & divide_by_scalar(const NumType &scalar)
Vector & product_by_scalar(const NumType &scalar) noexcept
Vector & operator-=(const Vector &v)
Iterator get_itor() const noexcept
Aleph::HashMap< T, NumType, MapODhash > Map
Vector operator*(const NumType &scalar) const
bool operator!=(const Vector &v) const noexcept
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
auto unzip(const Container &l)
Separate a list of pairs into two lists.
DynList< std::pair< typename Container1::Item_Type, typename Container2::Item_Type > > zip(const Container1 &a, const Container2 &b)
Zip two containers into a list of pairs.
std::decay_t< typename HeadC::Item_Type > T
DynArray< T > sort(const DynArray< T > &a, Cmp &&cmp=Cmp())
Returns a sorted copy of a DynArray.
Matrix< Trow, Tcol, NumType > operator*(const NumType &scalar, const Matrix< Trow, Tcol, NumType > &m)
Scalar-matrix multiplication (scalar * matrix).
std::ostream & operator<<(std::ostream &osObject, const Field< T > &rightOp)
ZipIterator< Cs... > zip_it(const Cs &... cs)
Alias for get_zip_it.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Iterator(const Vector &vec)
Aleph::DynList< T > keys() const
Unified hash table interface.