|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Sparse vector implementation with domain-based indexing. More...
#include <al-vector.H>
Classes | |
| struct | Iterator |
| class | Proxy |
The entry of a key, as v[k] gives it: reads and assigns it. More... | |
Public Types | |
| using | Domain = AlDomain< T > |
| using | DomainPtr = std::shared_ptr< Domain > |
| using | Map = Aleph::HashMap< T, NumType, MapODhash > |
| using | Item_Type = std::pair< T, NumType > |
| using | Pair = std::pair< T, NumType > |
| typedef std::pair< std::string, std::string > | Pair |
| using | Const_Iterator = Aleph::Const_Iterator< Iterator > |
| Read-only iterator: the iterator of a constant vector. | |
Public Member Functions | |
| const NumType & | get_epsilon () const noexcept |
| Get the epsilon value used for zero comparisons. | |
| void | set_epsilon (const NumType &e) noexcept |
| Set the epsilon value for zero comparisons. | |
| const Domain & | get_domain () const noexcept |
| Get the domain over which this vector is defined. | |
| const DomainPtr & | get_domain_ptr () const noexcept |
| Return the shared pointer to the domain. | |
| Vector (DomainPtr d, const NumType &zero=default_epsilon) | |
| Construct a vector over a given domain (shared_ptr version) | |
| Vector (const Domain &d, const NumType &zero=default_epsilon) | |
| Construct a vector over a given domain (reference version) | |
| Vector (Domain &&d, const NumType &zero=default_epsilon) | |
| Construct a vector over a temporary domain, which it keeps. | |
| template<typename I > requires std::is_integral_v<I> | |
| Vector (I, const NumType &=default_epsilon)=delete | |
A vector needs a domain: Vector(IntRange(n)), not Vector(n), which would turn n into an empty domain. | |
| Vector (const Vector &v) | |
| Copy constructor. | |
| Vector (Vector &&v) noexcept | |
| Move constructor. | |
| Vector (DomainPtr d, const DynList< NumType > &l, const NumType &zero=default_epsilon) | |
| Construct vector from domain and list of values (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) | |
| Vector (Domain &&d, const DynList< NumType > &l, const NumType &zero=default_epsilon) | |
| Construct vector from a temporary domain, which it keeps, and a list of values. | |
| template<typename I > requires std::is_integral_v<I> | |
| Vector (I, const DynList< NumType > &, const NumType &=default_epsilon)=delete | |
A vector needs a domain: Vector(IntRange(n), l), not Vector(n, l), which would turn n into an empty domain. | |
| Vector & | operator= (const Vector &v) |
| Copy assignment operator. | |
| Vector & | operator= (Vector &&v) |
| Move assignment operator. | |
| void | set_entry (const T &i, const NumType &value) |
| Set a vector entry at given index. | |
| void | set_entries (std::initializer_list< T > ld, std::initializer_list< NumType > lr) |
| Set multiple entries using initializer lists. | |
| template<template< typename > class Container = DynList> | |
| 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) |
| Get vector entry at given index (non-const version) | |
| NumType | get_entry (const T &i) const noexcept |
| Get vector entry at given index (const version) | |
| NumType * | search_entry (const T &i) noexcept |
| Search for an entry and return pointer to its value. | |
| const NumType * | search_entry (const T &i) const noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A pointer to const. | |
| bool | are_equal (const NumType &n1, const NumType &n2) const noexcept |
| Check if two numeric values are equal within epsilon. | |
| bool | equal_to (const Vector &other) const noexcept |
| Check if this vector equals another within epsilon tolerance. | |
| bool | operator== (const Vector &v) const noexcept |
Whether the entries of v are equal to these, within epsilon. | |
| bool | operator!= (const Vector &v) const noexcept |
Whether some entry of v differs from this one, beyond epsilon. | |
| Vector & | operator+= (const Vector &v) |
Add v, over the same domain, to this vector. | |
| Vector & | operator-= (const Vector &v) |
Subtract v, over the same domain, from this vector. | |
| Vector | operator+ (const Vector &r) const |
The sum of this vector and r, over the same domain. | |
| Vector | operator- (const Vector &r) const |
The difference of this vector and r, over the same domain. | |
| Vector & | product_by_scalar (const NumType &scalar) noexcept |
Multiply every entry by scalar. | |
| Vector | operator* (const NumType &scalar) const |
This vector multiplied by scalar. | |
| Vector & | divide_by_scalar (const NumType &scalar) |
Divide every entry by scalar, which must not be zero. | |
| Vector | operator/ (const NumType &scalar) const |
This vector divided by scalar, which must not be zero. | |
| Vector | operator- () const |
| The negation of this vector. | |
| NumType | scalar_product (const Vector &v) const and AlMultiplicativeNumber< NumType > |
The scalar product of this vector and v, over the same domain. | |
| NumType | operator* (const Vector &v) const and AlMultiplicativeNumber< NumType > |
The scalar product of this vector and v, over the same domain. | |
| DynList< NumType > | to_list () const |
| The values of the vector, in the order of the sorted keys of its domain. | |
| void | print () const and AlStreamable< T > and AlStreamable< NumType > |
| Print the nonzero entries, in the order of the sorted keys. | |
| std::string | to_str () const and AlStreamable< T > and |
| The keys over their values, in the order of the keys. | |
| return dstr n | std::string (dstr.size(), '-')+"\n"+estr |
| NumType | operator[] (const T &k) const noexcept |
The value of the entry of k, read-only: 0 if it has none. | |
| Proxy | operator[] (const T &k) |
The entry of k, which a Proxy reads and assigns. | |
| NumType | operator() (const T &k) const noexcept |
The value of the entry of k, read-only: 0 if it has none. | |
| Proxy | operator() (const T &k) |
The entry of k, which a Proxy reads and assigns. | |
| Iterator | get_itor () noexcept |
| Iterator | get_it () noexcept |
| Const_Iterator | get_itor () const noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Read-only. | |
| Const_Iterator | get_it () const noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Read-only. | |
Public Member Functions inherited from Aleph::TraverseMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| bool | traverse (Operation &operation) const |
| Traverse all elements, applying an operation to each. | |
| bool | traverse (Operation &operation) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | traverse (Operation and operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | traverse (Operation and operation=Operation()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Public Member Functions inherited from Aleph::LocateMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| std::pair< T, NumType > & | nth (const size_t n) |
| Access the n-th element (bounds-checked). | |
| const std::pair< T, NumType > & | nth (const size_t n) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const. | |
| std::pair< T, NumType > & | nth_ne (const size_t n) noexcept |
| Access the n-th element (unchecked). | |
| const std::pair< T, NumType > & | nth_ne (const size_t n) const noexcept |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A reference to const. | |
| std::pair< T, NumType > * | find_ptr (Operation &operation) |
| Find the first element satisfying a predicate. | |
| const std::pair< T, NumType > * | find_ptr (Operation &operation) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| const std::pair< T, NumType > * | find_ptr (Operation and operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::pair< T, NumType > * | find_ptr (Operation and operation=Operation()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::tuple< bool, std::pair< T, NumType > > | find_item (Operation &operation) |
| Find element with success flag. | |
| std::tuple< bool, std::pair< T, NumType > > | find_item (Operation &operation) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::tuple< bool, std::pair< T, NumType > > | find_item (Operation &&operation=Operation()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::tuple< bool, std::pair< T, NumType > > | find_item (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Public Member Functions inherited from Aleph::FunctionalMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| auto | for_each (Operation &operation) const -> decltype(self()) |
| Apply an operation to each element (read-only). | |
| auto | for_each (Operation &operation) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| auto | for_each (Operation &&operation=Operation()) const -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| auto | for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| auto | mutable_for_each (Operation &operation) -> decltype(self()) |
| Apply an operation to each element (mutable). | |
| auto | mutable_for_each (Operation &&operation=Operation()) -> decltype(self()) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | all (Operation &operation) const |
| Test if all elements satisfy a predicate. | |
| bool | all (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | forall (Operation &operation) const |
| Alias for all(). | |
| bool | forall (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | exists (Operation &operation) const |
| Test if any element satisfies a predicate. | |
| bool | exists (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| Container< concepts_detail::map_result_t< R, Operation &, std::pair< T, NumType > > > | maps (Operation &operation) const |
| Container< concepts_detail::map_result_t< R, Operation &, std::pair< T, NumType > > > | maps (Operation &&operation=Operation()) const |
| Acc | foldl (const Acc &init, std::function< Acc(const Acc &, const std::pair< T, NumType > &)> operation) const |
| Left fold (reduce) with initial value. | |
| Acc | fold_left (std::function< Acc(const Acc &, const std::pair< T, NumType > &)> operation, const Acc &init) const |
| Left fold with operation first (alternative signature). | |
| std::pair< T, NumType > | fold (const std::pair< T, NumType > &init, Operation &operation) const |
| Simple fold with same type for accumulator and elements. | |
| std::pair< T, NumType > | fold (const std::pair< T, NumType > &init, Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| DynList< std::pair< T, NumType > > | filter (Operation &operation) const |
| Filter elements by a predicate. | |
| DynList< std::pair< T, NumType > > | filter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| DynList< std::tuple< std::pair< T, NumType >, size_t > > | pfilter (Operation &operation) const |
| Filter with position information. | |
| DynList< std::tuple< std::pair< T, NumType >, size_t > > | pfilter (Operation &&operation=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::pair< DynList< std::pair< T, NumType > >, DynList< std::pair< T, NumType > > > | partition (Operation &op) const |
| Partition elements by a predicate. | |
| std::pair< DynList< std::pair< T, NumType > >, DynList< std::pair< T, NumType > > > | partition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| std::tuple< DynList< std::pair< T, NumType > >, DynList< std::pair< T, NumType > > > | tpartition (Operation &op) const |
| Partition returning tuple instead of pair. | |
| std::tuple< DynList< std::pair< T, NumType > >, DynList< std::pair< T, NumType > > > | tpartition (Operation &&op=Operation()) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| size_t | length () const noexcept |
| Count the number of elements. | |
| Container< std::pair< T, NumType > > | rev () const |
| Create a reversed copy. | |
| Container< std::pair< T, NumType > > | take (const size_t n) const |
| Take the first n elements. | |
| Container< std::pair< T, NumType > > | drop (const size_t n) const |
| Skip the first n elements. | |
| std::pair< T, NumType > | sum (const std::pair< T, NumType > &init=std::pair< T, NumType > {}) const |
| Compute the sum of all elements. | |
| std::pair< T, NumType > | product (const std::pair< T, NumType > &init) const |
| Compute the product of all elements. | |
| const std::pair< T, NumType > * | min () const |
| Find the minimum element. | |
| const std::pair< T, NumType > * | max () const |
| Find the maximum element. | |
| const std::pair< T, NumType > * | min_by (Compare cmp) const |
| Find the minimum element using a custom comparator. | |
| const std::pair< T, NumType > * | max_by (Compare cmp) const |
| Find the maximum element using a custom comparator. | |
| bool | has_value (const std::pair< T, NumType > &val) const |
| Check if container has a value. | |
| bool | none (Predicate &pred) const |
| Check if no element satisfies a predicate. | |
| bool | none (Predicate &&pred) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| size_t | count_if (Predicate pred) const |
| Count elements satisfying a predicate. | |
| const std::pair< T, NumType > * | first () const |
| Get the first element. | |
| std::pair< T, NumType > | first_or (const std::pair< T, NumType > &default_val) const |
| Get the first element or a default value. | |
| const std::pair< T, NumType > * | last () const |
| Get the last element. | |
| std::pair< T, NumType > | last_or (const std::pair< T, NumType > &default_val) const |
| Get the last element or a default value. | |
| Container< std::pair< size_t, std::pair< T, NumType > > > | enumerate () const |
| Enumerate elements with their indices. | |
| size_t | find_index (Predicate pred) const |
| Find the index of the first element satisfying a predicate. | |
| size_t | index_of (const std::pair< T, NumType > &val) const |
| Find the index of a specific value. | |
| Container< std::pair< T, NumType > > | unique () const |
| Remove consecutive duplicate elements. | |
| Container< std::pair< T, NumType > > | unique_by (EqPred eq) const |
| Remove consecutive duplicates using a custom equality predicate. | |
| Container< std::pair< T, NumType > > | intersperse (const std::pair< T, NumType > &sep) const |
| Intersperse a separator between elements. | |
| Container< Container< std::pair< T, NumType > > > | chunk (size_t n) const |
| Split into chunks of fixed size. | |
| Container< Container< std::pair< T, NumType > > > | sliding (size_t size, size_t step=1) const |
| Create sliding windows of fixed size. | |
| std::vector< std::pair< T, NumType > > | to_vector () const |
| Convert to std::vector. | |
| DynListType | to_dynlist () const |
| Convert container to DynList. | |
| StringType | join (const StringType &sep=StringType{", "}) const |
| Join elements into a string with separator. | |
| std::string | join_str (const std::string &sep=", ") const |
| Join string elements with separator. | |
| Container< std::pair< std::pair< T, NumType >, typename Other::Item_Type > > | zip_with (const Other &other) const |
| Zip with another container. | |
Public Attributes | |
| const DynList< std::string > | entries_str |
| DynList< Pair > | pairs = zip(keys_str, entries_str) |
| const DynList< Pair > | format |
| std::pair< DynList< std::string >, DynList< std::string > > | ret = unzip(format) |
| auto | concatenate |
| const std::string | dstr = ret.first.template foldl<std::string>("", concatenate) |
| const std::string | estr = ret.second.template foldl<std::string>("", concatenate) |
Public Attributes inherited from Aleph::FunctionalMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| and | |
| Transform elements using a mapping function. | |
Private Member Functions | |
| bool | is_zero (const NumType &val) const noexcept |
| void | insert_or_remove_entry (const T &i, const NumType &value, Pair *ptr) |
Static Private Member Functions | |
| static NumType | abs (const NumType &val) noexcept |
| static bool | test_epsilon (const NumType &e) noexcept |
Private Attributes | |
| DomainPtr | domain_ptr = nullptr |
| NumType | epsilon = default_epsilon |
| Map | entries |
Static Private Attributes | |
| static const NumType | default_epsilon = 1e-7 |
Additional Inherited Members | |
Protected Member Functions inherited from Aleph::TraverseMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| const Vector< T, NumType > & | self () const noexcept |
| Access the derived class (const version). | |
| Vector< T, NumType > & | self () noexcept |
| Access the derived class (mutable version). | |
Protected Member Functions inherited from Aleph::LocateMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| const Vector< T, NumType > & | self () const noexcept |
| Vector< T, NumType > & | self () noexcept |
Protected Member Functions inherited from Aleph::FunctionalMixin< Vector< T, NumType >, std::pair< T, NumType > > | |
| const Vector< T, NumType > & | self () const noexcept |
| Vector< T, NumType > & | self () noexcept |
Sparse vector implementation with domain-based indexing.
This class implements a mathematical vector with sparse storage, where only non-zero entries are stored. The vector is defined over a domain of type T, and entries have values of type NumType.
The vector uses epsilon-based comparison for numerical tolerance, automatically removing entries that become close to zero.
| T | Type of domain elements (default: int) |
| NumType | Numeric type for vector entries (default: double) |
Definition at line 152 of file al-vector.H.
| using Aleph::Vector< T, NumType >::Const_Iterator = Aleph::Const_Iterator<Iterator> |
Read-only iterator: the iterator of a constant vector.
Definition at line 875 of file al-vector.H.
| using Aleph::Vector< T, NumType >::Domain = AlDomain<T> |
Definition at line 157 of file al-vector.H.
| using Aleph::Vector< T, NumType >::DomainPtr = std::shared_ptr<Domain> |
Definition at line 158 of file al-vector.H.
| using Aleph::Vector< T, NumType >::Item_Type = std::pair<T, NumType> |
Definition at line 160 of file al-vector.H.
| using Aleph::Vector< T, NumType >::Map = Aleph::HashMap<T, NumType, MapODhash> |
Definition at line 159 of file al-vector.H.
| using Aleph::Vector< T, NumType >::Pair = std::pair<T, NumType> |
Definition at line 199 of file al-vector.H.
| typedef std::pair<std::string, std::string> Aleph::Vector< T, NumType >::Pair |
Definition at line 760 of file al-vector.H.
|
inline |
Construct a vector over a given domain (shared_ptr version)
| d | Shared pointer to domain for the vector indices |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
Definition at line 215 of file al-vector.H.
|
inline |
Construct a vector over a given domain (reference version)
| d | Domain for the vector indices (will be wrapped in shared_ptr) |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
Definition at line 227 of file al-vector.H.
|
inline |
Construct a vector over a temporary domain, which it keeps.
The vector takes d, as Vector(IntRange(10)) gives it, so that the domain lives as long as the vector and those that share it. Another vector over an equal domain has another one: operations between them need the same domain, as get_domain_ptr() gives it.
| d | Temporary domain for the vector indices |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
Definition at line 244 of file al-vector.H.
|
delete |
A vector needs a domain: Vector(IntRange(n)), not Vector(n), which would turn n into an empty domain.
|
inline |
Construct vector from domain and list of values (shared_ptr version)
| d | Shared pointer to domain for the vector indices |
| l | List of values (must match domain size) |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
| ah_length_error | if list size doesn't match domain size |
Definition at line 284 of file al-vector.H.
References ah_length_error_if, Aleph::Vector< T, NumType >::domain_ptr, l, Aleph::Vector< T, NumType >::set_entry(), Aleph::DynList< T >::size(), and Aleph::zip_it().
|
inline |
Construct vector from domain and list of values (reference version)
| d | Domain for the vector indices (will be wrapped in shared_ptr) |
| l | List of values (must match domain size) |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
| ah_length_error | if list size doesn't match domain size |
Definition at line 307 of file al-vector.H.
|
inline |
Construct vector from a temporary domain, which it keeps, and a list of values.
| d | Temporary domain for the vector indices |
| l | List of values (must match domain size) |
| zero | Epsilon value for zero comparisons (default: 1e-7) |
| ah_length_error | if list size doesn't match domain size |
Definition at line 321 of file al-vector.H.
|
delete |
A vector needs a domain: Vector(IntRange(n), l), not Vector(n, l), which would turn n into an empty domain.
|
inlinestaticprivatenoexcept |
Definition at line 169 of file al-vector.H.
Referenced by Aleph::Vector< T, NumType >::is_zero().
|
inlinenoexcept |
Check if two numeric values are equal within epsilon.
| n1 | First value |
| n2 | Second value |
Definition at line 542 of file al-vector.H.
References Aleph::Vector< T, NumType >::is_zero().
Referenced by Aleph::Vector< T, NumType >::equal_to(), and TEST_F().
|
inline |
Divide every entry by scalar, which must not be zero.
Definition at line 651 of file al-vector.H.
References ah_domain_error_if, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::is_zero().
Referenced by Aleph::Vector< T, NumType >::operator/().
|
inlinenoexcept |
Check if this vector equals another within epsilon tolerance.
| other | Vector to compare with (must have same domain) |
Definition at line 553 of file al-vector.H.
References Aleph::FunctionalMixin< Vector< T, NumType >, std::pair< T, NumType > >::and, Aleph::Vector< T, NumType >::are_equal(), Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::get_entry().
|
inlinenoexcept |
Get the domain over which this vector is defined.
Definition at line 205 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr.
Referenced by Aleph::Matrix< Trow, Tcol, NumType >::set_vector_as_col(), Aleph::Matrix< Trow, Tcol, NumType >::set_vector_as_row(), TEST(), TEST_F(), and TEST_F().
|
inlinenoexcept |
Return the shared pointer to the domain.
Definition at line 208 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr.
Referenced by Aleph::outer_product(), and TEST().
|
inline |
Get vector entry at given index (non-const version)
| i | Index (must be in domain) |
Definition at line 474 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::is_zero().
Referenced by demo_sparse_vector(), demo_string_indexed_vector(), Aleph::Vector< T, NumType >::equal_to(), Aleph::Matrix< Trow, Tcol, NumType >::mult_matrix_vector_sparse(), Aleph::Vector< T, NumType >::operator()(), Aleph::Vector< T, NumType >::operator+=(), Aleph::Vector< T, NumType >::operator-=(), Aleph::Vector< T, NumType >::operator[](), Aleph::Vector< T, NumType >::scalar_product(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and Aleph::Vector< T, NumType >::to_list().
|
inlinenoexcept |
Get vector entry at given index (const version)
| i | Index (must be in domain) |
Definition at line 496 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::entries.
|
inlinenoexcept |
Get the epsilon value used for zero comparisons.
Definition at line 187 of file al-vector.H.
References Aleph::Vector< T, NumType >::epsilon.
Referenced by demo_epsilon(), TEST_F(), TEST_F(), and TEST_F().
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Read-only.
Definition at line 886 of file al-vector.H.
|
inlinenoexcept |
Definition at line 878 of file al-vector.H.
Referenced by demo_epsilon(), demo_sparse_vector(), demo_string_indexed_vector(), TEST_F(), and TEST_F().
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Read-only.
Definition at line 882 of file al-vector.H.
|
inlinenoexcept |
Definition at line 877 of file al-vector.H.
|
inlineprivate |
Definition at line 404 of file al-vector.H.
References Aleph::Vector< T, NumType >::entries, Aleph::Vector< T, NumType >::is_zero(), and value.
Referenced by Aleph::Vector< T, NumType >::Proxy::operator=().
|
inlineprivatenoexcept |
Definition at line 174 of file al-vector.H.
References Aleph::Vector< T, NumType >::abs(), and Aleph::Vector< T, NumType >::epsilon.
Referenced by Aleph::Vector< T, NumType >::are_equal(), Aleph::Vector< T, NumType >::divide_by_scalar(), Aleph::Vector< T, NumType >::get_entry(), Aleph::Vector< T, NumType >::insert_or_remove_entry(), Aleph::Vector< T, NumType >::Proxy::operator=(), Aleph::Vector< T, NumType >::product_by_scalar(), and Aleph::Vector< T, NumType >::set_entry().
|
inlinenoexcept |
Whether some entry of v differs from this one, beyond epsilon.
Definition at line 576 of file al-vector.H.
|
inline |
The entry of k, which a Proxy reads and assigns.
Definition at line 860 of file al-vector.H.
References k.
|
inlinenoexcept |
The value of the entry of k, read-only: 0 if it has none.
Definition at line 854 of file al-vector.H.
References Aleph::Vector< T, NumType >::get_entry(), and k.
|
inline |
This vector multiplied by scalar.
Definition at line 643 of file al-vector.H.
References Aleph::Vector< T, NumType >::product_by_scalar().
|
inline |
The scalar product of this vector and v, over the same domain.
Definition at line 707 of file al-vector.H.
References Aleph::Vector< T, NumType >::scalar_product().
|
inline |
The sum of this vector and r, over the same domain.
Definition at line 607 of file al-vector.H.
References r.
|
inline |
Add v, over the same domain, to this vector.
Definition at line 583 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::get_entry(), and Aleph::Vector< T, NumType >::set_entry().
|
inline |
The negation of this vector.
Definition at line 676 of file al-vector.H.
References Aleph::Vector< T, NumType >::product_by_scalar().
|
inline |
The difference of this vector and r, over the same domain.
Definition at line 615 of file al-vector.H.
References r.
|
inline |
Subtract v, over the same domain, from this vector.
Definition at line 595 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::get_entry(), and Aleph::Vector< T, NumType >::set_entry().
|
inline |
This vector divided by scalar, which must not be zero.
Definition at line 668 of file al-vector.H.
References Aleph::Vector< T, NumType >::divide_by_scalar().
|
inline |
Copy assignment operator.
| v | Vector to copy from |
| std::domain_error | if domains are different (not the same object) |
Definition at line 340 of file al-vector.H.
References ah_domain_error_if, Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::epsilon.
|
inline |
Move assignment operator.
| v | Vector to move from |
| std::domain_error | if domains are different (not the same object) |
Definition at line 361 of file al-vector.H.
References ah_domain_error_if, Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::epsilon.
|
inlinenoexcept |
Whether the entries of v are equal to these, within epsilon.
Definition at line 569 of file al-vector.H.
|
inline |
The entry of k, which a Proxy reads and assigns.
Definition at line 848 of file al-vector.H.
References k.
|
inlinenoexcept |
The value of the entry of k, read-only: 0 if it has none.
Definition at line 842 of file al-vector.H.
References Aleph::Vector< T, NumType >::get_entry(), and k.
|
inline |
Print the nonzero entries, in the order of the sorted keys.
Definition at line 728 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and k.
|
inlinenoexcept |
Multiply every entry by scalar.
Definition at line 623 of file al-vector.H.
References Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::is_zero().
Referenced by Aleph::Vector< T, NumType >::operator*(), Aleph::operator*(), and Aleph::Vector< T, NumType >::operator-().
|
inline |
The scalar product of this vector and v, over the same domain.
Definition at line 683 of file al-vector.H.
References ah_domain_error_if, Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, and Aleph::Vector< T, NumType >::get_entry().
Referenced by Aleph::Vector< T, NumType >::operator*(), and TEST_F().
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. A pointer to const.
Definition at line 525 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::entries.
|
inlinenoexcept |
Search for an entry and return pointer to its value.
| i | Index (must be in domain) |
Definition at line 512 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::entries.
Referenced by TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().
|
inline |
Set multiple entries using container and initializer list.
| c | Container of domain indices |
| lr | List of corresponding values |
| ah_range_error | if container and list have different sizes |
| ah_domain_error | if any index not in domain |
Definition at line 452 of file al-vector.H.
References ah_domain_error_if, ah_range_error_if, Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::set_entry().
|
inline |
Set multiple entries using initializer lists.
| ld | List of domain indices |
| lr | List of corresponding values |
| ah_range_error | if lists have different sizes |
| ah_domain_error | if any index not in domain |
Definition at line 427 of file al-vector.H.
References ah_domain_error_if, ah_range_error_if, Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::set_entry().
|
inline |
Set a vector entry at given index.
| i | Index (must be in domain) |
| value | Value to set (automatically removed if within epsilon of zero) |
Definition at line 381 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, Aleph::Vector< T, NumType >::entries, Aleph::Vector< T, NumType >::is_zero(), and value.
Referenced by Aleph::Vector< T, NumType >::Vector(), demo_epsilon(), demo_linear_system(), demo_matrix_vector_mult(), demo_outer_product(), demo_row_col_operations(), demo_sparse_vector(), demo_string_indexed_vector(), demo_vector_arithmetic(), Aleph::Matrix< Trow, Tcol, NumType >::get_col_vector(), Aleph::Matrix< Trow, Tcol, NumType >::get_row_vector(), Aleph::Matrix< Trow, Tcol, NumType >::mult_matrix_vector_dot_product(), Aleph::Matrix< Trow, Tcol, NumType >::mult_matrix_vector_sparse(), Aleph::Matrix< Trow, Tcol, NumType >::mult_vector_matrix_dot_product(), Aleph::Vector< T, NumType >::operator+=(), Aleph::Vector< T, NumType >::operator-=(), Aleph::Vector< T, NumType >::Proxy::operator=(), Aleph::Vector< T, NumType >::set_entries(), Aleph::Vector< T, NumType >::set_entries(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), Aleph::Matrix< Trow, Tcol, NumType >::to_collist(), and Aleph::Matrix< Trow, Tcol, NumType >::to_rowlist().
|
inlinenoexcept |
Set the epsilon value for zero comparisons.
| e | New epsilon value (must be >= 0) |
Definition at line 194 of file al-vector.H.
References Aleph::Vector< T, NumType >::epsilon.
Referenced by demo_epsilon(), and TEST_F().
| return dstr n Aleph::Vector< T, NumType >::std::string | ( | dstr. | size(), |
| '-' | |||
| ) |
References Aleph::Vector< T, NumType >::std::string().
Referenced by Aleph::Vector< T, NumType >::std::string(), and Aleph::Vector< T, NumType >::to_str().
|
inlinestaticprivatenoexcept |
Definition at line 180 of file al-vector.H.
|
inline |
The values of the vector, in the order of the sorted keys of its domain.
It is the list that the constructor from a domain and a list takes: Vector(d, l).to_list() gives l.
Definition at line 719 of file al-vector.H.
References Aleph::Vector< T, NumType >::domain_ptr, and Aleph::Vector< T, NumType >::get_entry().
Referenced by TEST_F(), and Aleph::Matrix< Trow, Tcol, NumType >::to_str().
|
inline |
The keys over their values, in the order of the keys.
Definition at line 740 of file al-vector.H.
References Aleph::Vector< T, NumType >::std::string().
Referenced by Aleph::operator<<(), and TEST_F().
| auto Aleph::Vector< T, NumType >::concatenate |
Definition at line 775 of file al-vector.H.
|
staticprivate |
Definition at line 163 of file al-vector.H.
|
private |
Definition at line 165 of file al-vector.H.
Referenced by Aleph::Vector< T, NumType >::Vector(), Aleph::Vector< T, NumType >::equal_to(), Aleph::Vector< T, NumType >::get_domain(), Aleph::Vector< T, NumType >::get_domain_ptr(), Aleph::Vector< T, NumType >::get_entry(), Aleph::Vector< T, NumType >::get_entry(), Aleph::Vector< T, NumType >::operator+=(), Aleph::Vector< T, NumType >::operator-=(), Aleph::Vector< T, NumType >::Proxy::operator=(), Aleph::Vector< T, NumType >::operator=(), Aleph::Vector< T, NumType >::operator=(), Aleph::Vector< T, NumType >::print(), Aleph::Vector< T, NumType >::scalar_product(), Aleph::Vector< T, NumType >::search_entry(), Aleph::Vector< T, NumType >::search_entry(), Aleph::Vector< T, NumType >::set_entries(), Aleph::Vector< T, NumType >::set_entries(), Aleph::Vector< T, NumType >::set_entry(), and Aleph::Vector< T, NumType >::to_list().
| const std::string Aleph::Vector< T, NumType >::dstr = ret.first.template foldl<std::string>("", concatenate) |
Definition at line 780 of file al-vector.H.
|
private |
Definition at line 167 of file al-vector.H.
Referenced by Aleph::Vector< T, NumType >::divide_by_scalar(), Aleph::Vector< T, NumType >::equal_to(), Aleph::Vector< T, NumType >::get_entry(), Aleph::Vector< T, NumType >::get_entry(), Aleph::Vector< T, NumType >::insert_or_remove_entry(), Aleph::Vector< T, NumType >::Proxy::operator=(), Aleph::Vector< T, NumType >::operator=(), Aleph::Vector< T, NumType >::operator=(), Aleph::Vector< T, NumType >::print(), Aleph::Vector< T, NumType >::product_by_scalar(), Aleph::Vector< T, NumType >::scalar_product(), Aleph::Vector< T, NumType >::search_entry(), Aleph::Vector< T, NumType >::search_entry(), and Aleph::Vector< T, NumType >::set_entry().
| const DynList<std::string> Aleph::Vector< T, NumType >::entries_str |
Definition at line 754 of file al-vector.H.
|
private |
Definition at line 166 of file al-vector.H.
Referenced by Aleph::Vector< T, NumType >::get_epsilon(), Aleph::Vector< T, NumType >::is_zero(), Aleph::Vector< T, NumType >::operator=(), Aleph::Vector< T, NumType >::operator=(), and Aleph::Vector< T, NumType >::set_epsilon().
| const std::string Aleph::Vector< T, NumType >::estr = ret.second.template foldl<std::string>("", concatenate) |
Definition at line 782 of file al-vector.H.
| const DynList<Pair> Aleph::Vector< T, NumType >::format |
Definition at line 763 of file al-vector.H.
| DynList<Pair> Aleph::Vector< T, NumType >::pairs = zip(keys_str, entries_str) |
Definition at line 761 of file al-vector.H.
| std::pair<DynList<std::string>, DynList<std::string> > Aleph::Vector< T, NumType >::ret = unzip(format) |
Definition at line 773 of file al-vector.H.