![]() |
Blaze
3.6
|
Efficient implementation of an arbitrary sized zero vector.The ZeroVector class template is the representation of an immutable, arbitrary sized zero vector with N elements of arbitrary type. The type of the elements and the transpose flag of the vector can be specified via the two template parameters: More...
#include <ZeroVector.h>
Inherits blaze::Expression< SparseVector< ZeroVector< Type, TF >, TF > >.
Classes | |
struct | Rebind |
Rebind mechanism to obtain a ZeroVector with different data/element type. More... | |
struct | Resize |
Resize mechanism to obtain a ZeroVector with a different fixed number of elements. More... | |
Public Types | |
using | This = ZeroVector< Type, TF > |
Type of this ZeroVector instance. | |
using | BaseType = SparseVector< This, TF > |
Base type of this ZeroVector instance. | |
using | ResultType = This |
Result type for expression template evaluations. | |
using | TransposeType = ZeroVector< Type,!TF > |
Transpose type for expression template evaluations. | |
using | ElementType = Type |
Type of the zero vector elements. | |
using | ReturnType = const Type & |
Return type for expression template evaluations. | |
using | CompositeType = const This & |
Data type for composite expression templates. | |
using | Reference = const Type & |
Reference to a zero vector element. | |
using | ConstReference = const Type & |
Reference to a constant zero vector element. | |
using | Iterator = Element * |
Iterator over non-constant elements. | |
using | ConstIterator = const Element * |
Iterator over constant elements. | |
using | VectorType = ZeroVector< Type, TF > |
Type of the vector. | |
Public Member Functions | |
template<typename VT > | |
ZeroVector< Type, TF > & | operator= (const Vector< VT, TF > &rhs) |
Assignment operator for different zero vectors. More... | |
BLAZE_ALWAYS_INLINE constexpr VectorType & | operator~ () noexcept |
Conversion operator for non-constant vectors. More... | |
BLAZE_ALWAYS_INLINE constexpr const VectorType & | operator~ () const noexcept |
Conversion operator for constant vectors. More... | |
Constructors | |
constexpr | ZeroVector () noexcept |
The default constructor for ZeroVector. | |
constexpr | ZeroVector (size_t size) noexcept |
Constructor for a zero vector of size n. More... | |
template<typename VT > | |
ZeroVector (const Vector< VT, TF > &v) | |
Conversion constructor for different zero vectors. More... | |
ZeroVector (const ZeroVector &)=default | |
ZeroVector (ZeroVector &&)=default | |
Destructor | |
~ZeroVector ()=default | |
Data access functions | |
constexpr ConstReference | operator[] (size_t index) const noexcept |
Subscript operator for the direct access to the zero vector elements. More... | |
ConstReference | at (size_t index) const |
Checked access to the zero vector elements. More... | |
constexpr ConstIterator | begin () const noexcept |
Returns an iterator to the first non-zero element of the zero vector. More... | |
constexpr ConstIterator | cbegin () const noexcept |
Returns an iterator to the first non-zero element of the zero vector. More... | |
constexpr ConstIterator | end () const noexcept |
Returns an iterator just past the last non-zero element of the zero vector. More... | |
constexpr ConstIterator | cend () const noexcept |
Returns an iterator just past the last non-zero element of the zero vector. More... | |
Assignment operators | |
template<typename VT > | |
ZeroVector & | operator= (const Vector< VT, TF > &rhs) |
ZeroVector & | operator= (const ZeroVector &)=default |
ZeroVector & | operator= (ZeroVector &&)=default |
Utility functions | |
constexpr size_t | size () const noexcept |
Returns the current size/dimension of the zero vector. More... | |
constexpr size_t | capacity () const noexcept |
Returns the maximum capacity of the zero vector. More... | |
constexpr size_t | nonZeros () const noexcept |
Returns the number of non-zero elements in the zero vector. More... | |
constexpr void | clear () noexcept |
Clearing the zero vector. More... | |
constexpr void | resize (size_t n) noexcept |
Changing the size of the zero vector. More... | |
constexpr void | swap (ZeroVector &v) noexcept |
Swapping the contents of two zero vectors. More... | |
Lookup functions | |
ConstIterator | find (size_t index) const |
Searches for a specific vector element. More... | |
ConstIterator | lowerBound (size_t index) const |
Returns an iterator to the first index not less then the given index. More... | |
ConstIterator | upperBound (size_t index) const |
Returns an iterator to the first index greater then the given index. More... | |
Expression template evaluation functions | |
template<typename Other > | |
bool | canAlias (const Other *alias) const noexcept |
Returns whether the vector can alias with the given address alias. More... | |
template<typename Other > | |
bool | isAliased (const Other *alias) const noexcept |
Returns whether the vector is aliased with the given address alias. More... | |
bool | canSMPAssign () const noexcept |
Returns whether the vector can be used in SMP assignments. More... | |
Static Public Attributes | |
static constexpr bool | smpAssignable = !IsSMPAssignable_v<Type> |
Compilation flag for SMP assignments. More... | |
static constexpr bool | transposeFlag |
Transpose flag of the vector. | |
Private Types | |
using | Element = ValueIndexPair< Type > |
Value-index-pair for the ZeroVector class. | |
Member variables | |
size_t | size_ |
The current size/dimension of the zero vector. | |
static const Type | zero_ {} |
The zero element. | |
Efficient implementation of an arbitrary sized zero vector.
The ZeroVector class template is the representation of an immutable, arbitrary sized zero vector with N elements of arbitrary type. The type of the elements and the transpose flag of the vector can be specified via the two template parameters:
It is not possible to insert, erase or modify the elements of a zero vector. It is only possible to read from the elements:
The use of ZeroVector is very natural and intuitive. All operations (addition, subtraction, multiplication, ...) can be performed on all possible combinations of dense and sparse vectors with fitting element types. The following example gives an impression of the use of ZeroVector:
|
inlineexplicitnoexcept |
Constructor for a zero vector of size n.
n | The size of the vector. |
|
inline |
Conversion constructor for different zero vectors.
v | Zero vector to be copied. |
std::invalid_argument | Invalid setup of zero vector. |
The vector is sized according to the given N-dimensional zero vector and initialized as a copy of this vector.
|
inline |
Checked access to the zero vector elements.
index | Access index. The index has to be in the range ![]() |
std::out_of_range | Invalid zero vector access index. |
In contrast to the subscript operator this function always performs a check of the given access indices.
|
inlinenoexcept |
Returns an iterator to the first non-zero element of the zero vector.
|
inlinenoexcept |
Returns whether the vector can alias with the given address alias.
alias | The alias to be checked. |
This function returns whether the given address can alias with the vector. In contrast to the isAliased() function this function is allowed to use compile time expressions to optimize the evaluation.
|
inlinenoexcept |
Returns whether the vector can be used in SMP assignments.
This function returns whether the vector can be used in SMP assignments. In contrast to the smpAssignable member enumeration, which is based solely on compile time information, this function additionally provides runtime information (as for instance the current size of the vector).
|
inlinenoexcept |
Returns the maximum capacity of the zero vector.
|
inlinenoexcept |
Returns an iterator to the first non-zero element of the zero vector.
|
inlinenoexcept |
Returns an iterator just past the last non-zero element of the zero vector.
|
inlinenoexcept |
|
inlinenoexcept |
Returns an iterator just past the last non-zero element of the zero vector.
|
inline |
Searches for a specific vector element.
index | The index of the search element. The index has to be in the range ![]() |
This function can be used to check whether a specific element is contained in the sparse vector. It specifically searches for the element with index index. In case the element is found, the function returns an iterator to the element. Otherwise an iterator just past the last non-zero element of the zero vector (the end() iterator) is returned.
|
inlinenoexcept |
Returns whether the vector is aliased with the given address alias.
alias | The alias to be checked. |
This function returns whether the given address is aliased with the vector. In contrast to the canAlias() function this function is not allowed to use compile time expressions to optimize the evaluation.
|
inline |
Returns an iterator to the first index not less then the given index.
index | The index of the search element. The index has to be in the range ![]() |
This function returns an iterator to the first element with an index not less then the given index. In combination with the upperBound() function this function can be used to create a pair of iterators specifying a range of indices.
|
inlinenoexcept |
Returns the number of non-zero elements in the zero vector.
Note that the number of non-zero elements is always smaller than the current size of the zero vector.
|
inline |
Assignment operator for different zero vectors.
rhs | Zero vector to be copied. |
std::invalid_argument | Invalid assignment to zero vector. |
The vector is resized according to the given zero vector and initialized as a copy of this vector.
|
inlinenoexcept |
Subscript operator for the direct access to the zero vector elements.
index | Access index. The index has to be in the range ![]() |
|
inlinenoexceptinherited |
Conversion operator for non-constant vectors.
|
inlinenoexceptinherited |
Conversion operator for constant vectors.
|
inlinenoexcept |
Changing the size of the zero vector.
n | The new size of the zero vector. |
This function resizes the zero vector using the given size to n. Note that this function may invalidate all existing views (subvectors, ...) on the vector if it is used to shrink the vector.
|
inlinenoexcept |
Returns the current size/dimension of the zero vector.
|
inlinenoexcept |
Swapping the contents of two zero vectors.
v | The zero vector to be swapped. |
|
inline |
Returns an iterator to the first index greater then the given index.
index | The index of the search element. The index has to be in the range ![]() |
This function returns an iterator to the first element with an index greater then the given index. In combination with the lowerBound() function this function can be used to create a pair of iterators specifying a range of indices.
|
static |
Compilation flag for SMP assignments.
The smpAssignable compilation flag indicates whether the vector can be used in SMP (shared memory parallel) assignments (both on the left-hand and right-hand side of the assignment).