![]() |
Blaze 3.9
|
Efficient implementation of an arbitrary sized vector. More...
#include <DynamicVector.h>
Inherits blaze::DenseVector< DynamicVector< Type, TF, Alloc, Tag >, TF >.
Classes | |
struct | Rebind |
Rebind mechanism to obtain a DynamicVector with different data/element type. More... | |
struct | Resize |
Resize mechanism to obtain a DynamicVector with a different fixed number of elements. More... | |
struct | Uninitialized |
Definition of the nested auxiliary struct Uninitialized. More... | |
Public Types | |
using | This = DynamicVector< Type, TF, Alloc, Tag > |
Type of this DynamicVector instance. | |
using | BaseType = DenseVector< This, TF > |
Base type of this DynamicVector instance. | |
using | ResultType = This |
Result type for expression template evaluations. | |
using | TransposeType = DynamicVector< Type,!TF, Alloc, Tag > |
Transpose type for expression template evaluations. | |
using | ElementType = Type |
Type of the vector elements. | |
using | SIMDType = SIMDTrait_t< ElementType > |
SIMD type of the vector elements. | |
using | AllocatorType = AlignedAllocator< Type > |
Allocator type of this DynamicVector instance. | |
using | TagType = Tag |
Tag type of this DynamicVector instance. | |
using | ReturnType = const Type & |
Return type for expression template evaluations. | |
using | CompositeType = const DynamicVector & |
Data type for composite expression templates. | |
using | Reference = Type & |
Reference to a non-constant vector value. | |
using | ConstReference = const Type & |
Reference to a constant vector value. | |
using | Pointer = Type * |
Pointer to a non-constant vector value. | |
using | ConstPointer = const Type * |
Pointer to a constant vector value. | |
using | Iterator = DenseIterator< Type, aligned > |
Iterator over non-constant elements. | |
using | ConstIterator = DenseIterator< const Type, aligned > |
Iterator over constant elements. | |
using | VectorType = DynamicVector< Type, TF, Alloc, Tag > |
Type of the vector. | |
Public Member Functions | |
template<typename Other , size_t Dim> | |
DynamicVector< Type, TF, Alloc, Tag > & | operator= (const Other(&array)[Dim]) & |
Array assignment to all vector elements. More... | |
template<typename Other , size_t Dim> | |
DynamicVector< Type, TF, Alloc, Tag > & | operator= (const std::array< Other, Dim > &array) & |
Array assignment to all vector elements. More... | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator= (const Vector< VT, TF > &rhs) & |
Assignment operator for different vectors. More... | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator+= (const Vector< VT, TF > &rhs) & |
Addition assignment operator for the addition of a vector ( ![]() | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator-= (const Vector< VT, TF > &rhs) & |
Subtraction assignment operator for the subtraction of a vector ( ![]() | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator*= (const Vector< VT, TF > &rhs) & |
Multiplication assignment operator for the multiplication of a vector ( ![]() | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator/= (const DenseVector< VT, TF > &rhs) & |
Division assignment operator for the division of a dense vector ( ![]() | |
template<typename VT > | |
DynamicVector< Type, TF, Alloc, Tag > & | operator%= (const Vector< VT, TF > &rhs) & |
Cross product assignment operator for the multiplication of a vector ( ![]() | |
template<typename Other > | |
DynamicVector< Type, TF, Alloc, Tag > & | scale (const Other &scalar) |
Scaling of the vector by the scalar value scalar ( ![]() | |
Destructor | |
~DynamicVector () | |
The destructor for DynamicVector. | |
Data access functions | |
Reference | operator[] (size_t index) noexcept |
Subscript operator for the direct access to the vector elements. More... | |
ConstReference | operator[] (size_t index) const noexcept |
Subscript operator for the direct access to the vector elements. More... | |
Reference | at (size_t index) |
Checked access to the vector elements. More... | |
ConstReference | at (size_t index) const |
Checked access to the vector elements. More... | |
Pointer | data () noexcept |
Low-level data access to the vector elements. More... | |
ConstPointer | data () const noexcept |
Low-level data access to the vector elements. More... | |
Iterator | begin () noexcept |
Returns an iterator to the first element of the dynamic vector. More... | |
ConstIterator | begin () const noexcept |
Returns an iterator to the first element of the dynamic vector. More... | |
ConstIterator | cbegin () const noexcept |
Returns an iterator to the first element of the dynamic vector. More... | |
Iterator | end () noexcept |
Returns an iterator just past the last element of the dynamic vector. More... | |
ConstIterator | end () const noexcept |
Returns an iterator just past the last element of the dynamic vector. More... | |
ConstIterator | cend () const noexcept |
Returns an iterator just past the last element of the dynamic vector. More... | |
Assignment operators | |
DynamicVector & | operator= (const Type &rhs) & |
Homogenous assignment to all vector elements. More... | |
DynamicVector & | operator= (initializer_list< Type > list) & |
List assignment to all vector elements. More... | |
template<typename Other , size_t Dim> | |
DynamicVector & | operator= (const Other(&array)[Dim]) & |
template<typename Other , size_t Dim> | |
DynamicVector & | operator= (const std::array< Other, Dim > &array) & |
DynamicVector & | operator= (const DynamicVector &rhs) & |
Copy assignment operator for DynamicVector. More... | |
DynamicVector & | operator= (DynamicVector &&rhs) &noexcept |
template<typename VT > | |
DynamicVector & | operator= (const Vector< VT, TF > &rhs) & |
template<typename VT > | |
DynamicVector & | operator+= (const Vector< VT, TF > &rhs) & |
template<typename VT > | |
DynamicVector & | operator-= (const Vector< VT, TF > &rhs) & |
template<typename VT > | |
DynamicVector & | operator*= (const Vector< VT, TF > &rhs) & |
template<typename VT > | |
DynamicVector & | operator/= (const DenseVector< VT, TF > &rhs) & |
template<typename VT > | |
DynamicVector & | operator%= (const Vector< VT, TF > &rhs) & |
Debugging functions | |
bool | isIntact () const noexcept |
Returns whether the invariants of the dynamic vector are intact. 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 | isAligned () const noexcept |
Returns whether the vector is properly aligned in memory. More... | |
bool | canSMPAssign () const noexcept |
Returns whether the vector can be used in SMP assignments. More... | |
BLAZE_ALWAYS_INLINE SIMDType | load (size_t index) const noexcept |
Load of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE SIMDType | loada (size_t index) const noexcept |
Aligned load of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE SIMDType | loadu (size_t index) const noexcept |
Unaligned load of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE void | store (size_t index, const SIMDType &value) noexcept |
Store of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE void | storea (size_t index, const SIMDType &value) noexcept |
Aligned store of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE void | storeu (size_t index, const SIMDType &value) noexcept |
Unaligned store of a SIMD element of the vector. More... | |
BLAZE_ALWAYS_INLINE void | stream (size_t index, const SIMDType &value) noexcept |
Aligned, non-temporal store of a SIMD element of the vector. More... | |
template<typename VT > | |
auto | assign (const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAssign_v< VT > > |
Default implementation of the assignment of a dense vector. More... | |
template<typename VT > | |
auto | assign (const DenseVector< VT, TF > &rhs) -> EnableIf_t< VectorizedAssign_v< VT > > |
template<typename VT > | |
void | assign (const SparseVector< VT, TF > &rhs) |
Default implementation of the assignment of a sparse vector. More... | |
template<typename VT > | |
auto | addAssign (const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedAddAssign_v< VT > > |
Default implementation of the addition assignment of a dense vector. More... | |
template<typename VT > | |
auto | addAssign (const DenseVector< VT, TF > &rhs) -> EnableIf_t< VectorizedAddAssign_v< VT > > |
template<typename VT > | |
void | addAssign (const SparseVector< VT, TF > &rhs) |
Default implementation of the addition assignment of a sparse vector. More... | |
template<typename VT > | |
auto | subAssign (const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedSubAssign_v< VT > > |
Default implementation of the subtraction assignment of a dense vector. More... | |
template<typename VT > | |
auto | subAssign (const DenseVector< VT, TF > &rhs) -> EnableIf_t< VectorizedSubAssign_v< VT > > |
template<typename VT > | |
void | subAssign (const SparseVector< VT, TF > &rhs) |
Default implementation of the subtraction assignment of a sparse vector. More... | |
template<typename VT > | |
auto | multAssign (const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedMultAssign_v< VT > > |
Default implementation of the multiplication assignment of a dense vector. More... | |
template<typename VT > | |
auto | multAssign (const DenseVector< VT, TF > &rhs) -> EnableIf_t< VectorizedMultAssign_v< VT > > |
template<typename VT > | |
void | multAssign (const SparseVector< VT, TF > &rhs) |
Default implementation of the multiplication assignment of a sparse vector. More... | |
template<typename VT > | |
auto | divAssign (const DenseVector< VT, TF > &rhs) -> DisableIf_t< VectorizedDivAssign_v< VT > > |
Default implementation of the division assignment of a dense vector. More... | |
template<typename VT > | |
auto | divAssign (const DenseVector< VT, TF > &rhs) -> EnableIf_t< VectorizedDivAssign_v< VT > > |
Conversion operators | |
BLAZE_ALWAYS_INLINE constexpr DynamicVector< Type, TF, Alloc, Tag > & | operator~ () noexcept |
CRTP-based conversion operation for non-constant vectors. More... | |
BLAZE_ALWAYS_INLINE constexpr const DynamicVector< Type, TF, Alloc, Tag > & | operator~ () const noexcept |
CRTP-based conversion operation for constant vectors. More... | |
constexpr DynamicVector< Type, TF, Alloc, Tag > & | operator* () noexcept |
CRTP-based conversion operation for non-constant vectors. More... | |
constexpr const DynamicVector< Type, TF, Alloc, Tag > & | operator* () const noexcept |
CRTP-based conversion operation for constant vectors. More... | |
Static Public Attributes | |
static constexpr bool | simdEnabled = IsVectorizable_v<Type> |
Compilation flag for SIMD optimization. More... | |
static constexpr bool | smpAssignable = !IsSMPAssignable_v<Type> |
Compilation flag for SMP assignments. More... | |
static constexpr bool | transposeFlag |
Transpose flag of the vector. | |
Private Attributes | |
Member variables | |
size_t | size_ |
The current size/dimension of the vector. | |
size_t | capacity_ |
The maximum capacity of the vector. | |
Type *BLAZE_RESTRICT | v_ |
The dynamically allocated vector elements. More... | |
BLAZE_NO_UNIQUE_ADDRESS Alloc | alloc_ |
The allocator of the vector. | |
Numeric functions | |
static constexpr size_t | SIMDSIZE = SIMDTrait<ElementType>::size |
The number of elements packed within a single SIMD element. | |
template<typename Other > | |
DynamicVector & | scale (const Other &scalar) |
Constructors | |
DynamicVector (const Alloc &alloc=Alloc{}) noexcept | |
The (default) constructor for DynamicVector. More... | |
DynamicVector (size_t n, const Alloc &alloc=Alloc{}) | |
Constructor for a vector of size n. For built-in types no initialization is performed! More... | |
DynamicVector (size_t n, const Type &init, const Alloc &alloc=Alloc{}) | |
Constructor for a homogeneous initialization of all n vector elements. More... | |
DynamicVector (initializer_list< Type > list, const Alloc &alloc=Alloc{}) | |
List initialization of all vector elements. More... | |
template<typename Other > | |
DynamicVector (size_t n, const Other *array, const Alloc &alloc=Alloc{}) | |
Array initialization of all vector elements. More... | |
template<typename Other , size_t Dim> | |
DynamicVector (const Other(&array)[Dim], const Alloc &alloc=Alloc{}) | |
Array initialization of all vector elements. More... | |
template<typename Other , size_t Dim> | |
DynamicVector (const std::array< Other, Dim > &array, const Alloc &alloc=Alloc{}) | |
Initialization of all vector elements from the given std::array. More... | |
DynamicVector (const DynamicVector &v) | |
The copy constructor for DynamicVector. More... | |
DynamicVector (DynamicVector &&v) noexcept | |
The move constructor for DynamicVector. More... | |
template<typename VT > | |
DynamicVector (const Vector< VT, TF > &v) | |
Conversion constructor from different vectors. More... | |
DynamicVector (size_t n, size_t capa, const Alloc &alloc, Uninitialized) | |
Auxiliary constructor for DynamicVector. More... | |
Utility functions | |
size_t | size () const noexcept |
Returns the current size/dimension of the vector. More... | |
size_t | spacing () const noexcept |
Returns the minimum capacity of the vector. More... | |
size_t | capacity () const noexcept |
Returns the maximum capacity of the vector. More... | |
size_t | nonZeros () const |
Returns the number of non-zero elements in the vector. More... | |
void | reset () |
Reset to the default initial values. More... | |
void | clear () |
Clearing the vector. More... | |
void | resize (size_t n, bool preserve=true) |
Changing the size of the vector. More... | |
void | extend (size_t n, bool preserve=true) |
Extending the size of the vector. More... | |
void | reserve (size_t n) |
Setting the minimum capacity of the vector. More... | |
void | shrinkToFit () |
Requesting the removal of unused capacity. More... | |
void | swap (DynamicVector &v) noexcept |
Swapping the contents of two vectors. More... | |
size_t | addPadding (size_t value) const noexcept |
Add the necessary amount of padding to the given value. More... | |
Efficient implementation of an arbitrary sized vector.
The DynamicVector class template is the representation of an arbitrary sized vector with dynamically allocated elements of arbitrary type. The type of the elements, the transpose flag, the type of the allocator, and the group tag of the vector can be specified via the four template parameters:
blaze::rowVector
) or a column vector (blaze::columnVector
). The default value is blaze::defaultTransposeFlag
.blaze::AlignedAllocator
.blaze::Group0
. See Grouping/Tagging for details.These contiguously stored elements can be directly accessed with the subscript operator. The numbering of the vector elements is
\f[\left(\begin{array}{*{5}{c}} 0 & 1 & 2 & \cdots & N-1 \\ \end{array}\right)\f]
The use of DynamicVector is very natural and intuitive. All operations (addition, subtraction, multiplication, scaling, ...) 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 DynamicVector:
|
inlinenoexcept |
The (default) constructor for DynamicVector.
alloc | Allocator for all memory allocations of this vector. |
|
inlineexplicit |
Constructor for a vector of size n. For built-in types no initialization is performed!
n | The size of the vector. |
alloc | Allocator for all memory allocations of this vector. |
|
inline |
Constructor for a homogeneous initialization of all n vector elements.
n | The size of the vector. |
init | The initial value of the vector elements. |
alloc | Allocator for all memory allocations of this vector. |
All vector elements are initialized with the specified value.
|
inline |
List initialization of all vector elements.
list | The initializer list. |
alloc | Allocator for all memory allocations of this vector. |
This constructor provides the option to explicitly initialize the elements of the vector within a constructor call:
The vector is sized according to the size of the initializer list and all its elements are (copy) assigned the elements of the given initializer list.
|
inline |
Array initialization of all vector elements.
n | The size of the vector. |
array | Dynamic array for the initialization. |
alloc | Allocator for all memory allocations of this vector. |
This constructor offers the option to directly initialize the elements of the vector with a dynamic array:
The vector is sized according to the specified size of the array and initialized with the values from the given array. Note that it is expected that the given array has at least n elements. Providing an array with less elements results in undefined behavior!
|
inline |
Array initialization of all vector elements.
array | Static array for the initialization. |
alloc | Allocator for all memory allocations of this vector. |
This constructor offers the option to directly initialize the elements of the vector with a static array:
The vector is sized according to the size of the static array and initialized with the values from the given static array. Missing values are initialized with default values (as e.g. the fourth element in the example).
|
inline |
Initialization of all vector elements from the given std::array.
array | The given std::array for the initialization. |
alloc | Allocator for all memory allocations of this vector. |
This constructor offers the option to directly initialize the elements of the vector with a std::array:
The vector is sized according to the size of the std::array and initialized with the values from the given std::array. Missing values are initialized with default values (as e.g. the fourth element in the example).
|
inline |
The copy constructor for DynamicVector.
v | Vector to be copied. |
The copy constructor is explicitly defined due to the required dynamic memory management and in order to enable/facilitate NRV optimization.
|
inlinenoexcept |
The move constructor for DynamicVector.
v | The vector to be moved into this instance. |
|
inline |
Conversion constructor from different vectors.
v | Vector to be copied. |
|
inlineprivate |
Auxiliary constructor for DynamicVector.
n | The size of the vector. |
capa | The initial capacity of the vector. |
alloc | Allocator for all memory allocations of this vector. |
std::bad_alloc | Allocation failed. |
|
inline |
Default implementation of the addition assignment of a dense vector.
SIMD optimized implementation of the addition assignment of a dense vector.
rhs | The right-hand side dense vector to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the addition assignment of a sparse vector.
rhs | The right-hand side sparse vector to be added. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inlineprivatenoexcept |
Add the necessary amount of padding to the given value.
value | The value to be padded. |
This function increments the given value by the necessary amount of padding based on the vector's data type Type.
|
inline |
Default implementation of the assignment of a dense vector.
SIMD optimized implementation of the assignment of a dense vector.
rhs | The right-hand side dense vector to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the assignment of a sparse vector.
rhs | The right-hand side sparse vector to be assigned. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Checked access to the vector elements.
index | Access index. The index has to be in the range ![]() |
std::out_of_range | Invalid vector access index. |
In contrast to the subscript operator this function always performs a check of the given access index.
|
inline |
Checked access to the vector elements.
index | Access index. The index has to be in the range ![]() |
std::out_of_range | Invalid vector access index. |
In contrast to the subscript operator this function always performs a check of the given access index.
|
inlinenoexcept |
Returns an iterator to the first element of the dynamic vector.
|
inlinenoexcept |
Returns an iterator to the first element of the dynamic 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 vector.
|
inlinenoexcept |
Returns an iterator to the first element of the dynamic vector.
|
inlinenoexcept |
Returns an iterator just past the last element of the dynamic vector.
|
inline |
|
inlinenoexcept |
Low-level data access to the vector elements.
This function returns a pointer to the internal storage of the dynamic vector.
|
inlinenoexcept |
Low-level data access to the vector elements.
This function returns a pointer to the internal storage of the dynamic vector.
|
inline |
Default implementation of the division assignment of a dense vector.
SIMD optimized implementation of the division assignment of a dense vector.
rhs | The right-hand side dense vector divisior. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
rhs | The right-hand side dense vector divisor. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inlinenoexcept |
Returns an iterator just past the last element of the dynamic vector.
|
inlinenoexcept |
Returns an iterator just past the last element of the dynamic vector.
|
inline |
Extending the size of the vector.
n | Number of additional vector elements. |
preserve | true if the old values of the vector should be preserved, false if not. |
This function increases the vector size by n elements. During this operation, new dynamic memory may be allocated in case the capacity of the vector is too small. Therefore this function potentially changes all vector elements. In order to preserve the old vector values, the preserve flag can be set to true. However, new vector elements of built-in type are not initialized!
|
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.
|
inlinenoexcept |
Returns whether the vector is properly aligned in memory.
This function returns whether the vector is guaranteed to be properly aligned in memory, i.e. whether the beginning and the end of the vector are guaranteed to conform to the alignment restrictions of the element type Type.
|
inlinenoexcept |
Returns whether the invariants of the dynamic vector are intact.
This function checks whether the invariants of the dynamic vector are intact, i.e. if its state is valid. In case the invariants are intact, the function returns true, else it will return false.
|
noexcept |
Load of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
This function performs a load of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
noexcept |
Aligned load of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
This function performs an aligned load of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
noexcept |
Unaligned load of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
This function performs an unaligned load of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
inline |
Default implementation of the multiplication assignment of a dense vector.
SIMD optimized implementation of the multiplication assignment of a dense vector.
rhs | The right-hand side dense vector to be multiplied. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the multiplication assignment of a sparse vector.
rhs | The right-hand side sparse vector to be multiplied. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Returns the number of non-zero elements in the vector.
This function returns the number of non-zero elements in the vector (i.e. the elements that compare unequal to their default value). Note that the number of non-zero elements is always less than or equal to the current size of the vector.
|
inline |
Cross product assignment operator for the multiplication of a vector ( ).
rhs | The right-hand side vector for the cross product. |
std::invalid_argument | Invalid vector size for cross product. |
In case the current size of any of the two vectors is not equal to 3, a std::invalid_argument exception is thrown.
|
constexprnoexceptinherited |
CRTP-based conversion operation for constant vectors.
This operator performs the CRTP-based type-safe downcast to the actual type VT of the vector. It will return a constant reference to the actual type VT.
|
constexprnoexceptinherited |
CRTP-based conversion operation for non-constant vectors.
This operator performs the CRTP-based type-safe downcast to the actual type VT of the vector. It will return a mutable reference to the actual type VT.
|
inline |
Multiplication assignment operator for the multiplication of a vector ( ).
rhs | The right-hand side vector to be multiplied with the vector. |
std::invalid_argument | Vector sizes do not match. |
In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.
|
inline |
Addition assignment operator for the addition of a vector ( ).
rhs | The right-hand side vector to be added to the vector. |
std::invalid_argument | Vector sizes do not match. |
In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.
|
inline |
Subtraction assignment operator for the subtraction of a vector ( ).
rhs | The right-hand side vector to be subtracted from the vector. |
std::invalid_argument | Vector sizes do not match. |
In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.
|
inline |
Division assignment operator for the division of a dense vector ( ).
rhs | The right-hand side dense vector divisor. |
std::invalid_argument | Vector sizes do not match. |
In case the current sizes of the two vectors don't match, a std::invalid_argument exception is thrown.
|
inline |
Copy assignment operator for DynamicVector.
rhs | Vector to be copied. |
The vector is resized according to the given N-dimensional vector and initialized as a copy of this vector.
|
inline |
Array assignment to all vector elements.
array | Static array for the assignment. |
This assignment operator offers the option to directly set all elements of the vector:
The vector is resized according to the size of the static array and assigned the values from the given static array. Missing values are initialized with default values (as e.g. the fourth element in the example).
|
inline |
Array assignment to all vector elements.
array | The given std::array for the assignment. |
This assignment operator offers the option to directly set all elements of the vector:
The vector is resized according to the size of the std::array and assigned the values from the given std::array. Missing values are initialized with default values (as e.g. the fourth element in the example).
|
inline |
Homogenous assignment to all vector elements.
rhs | Scalar value to be assigned to all vector elements. |
|
inline |
Assignment operator for different vectors.
rhs | Vector to be copied. |
The vector is resized according to the given vector and initialized as a copy of this vector.
|
inline |
List assignment to all vector elements.
list | The initializer list. |
This assignment operator offers the option to directly assign to all elements of the vector by means of an initializer list:
The vector is resized according to the size of the initializer list and all its elements are (copy) assigned the values from the given initializer list.
|
inlinenoexcept |
Subscript operator for the direct access to the vector elements.
index | Access index. The index has to be in the range ![]() |
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.
|
inlinenoexcept |
Subscript operator for the direct access to the vector elements.
index | Access index. The index has to be in the range ![]() |
This function only performs an index check in case BLAZE_USER_ASSERT() is active. In contrast, the at() function is guaranteed to perform a check of the given access index.
|
constexprnoexceptinherited |
CRTP-based conversion operation for constant vectors.
This operator performs the CRTP-based type-safe downcast to the actual type VT of the vector. It will return a constant reference to the actual type VT.
|
constexprnoexceptinherited |
CRTP-based conversion operation for non-constant vectors.
This operator performs the CRTP-based type-safe downcast to the actual type VT of the vector. It will return a mutable reference to the actual type VT.
|
inline |
Setting the minimum capacity of the vector.
n | The new minimum capacity of the vector. |
This function increases the capacity of the vector to at least n elements. The current values of the vector elements are preserved.
|
inline |
Reset to the default initial values.
|
inline |
Changing the size of the vector.
n | The new size of the vector. |
preserve | true if the old values of the vector should be preserved, false if not. |
This function resizes the vector using the given size to n. During this operation, new dynamic memory may be allocated in case the capacity of the vector is too small. Note that this function may invalidate all existing views (subvectors, ...) on the vector if it is used to shrink the vector. Additionally, the resize operation potentially changes all vector elements. In order to preserve the old vector values, the preserve flag can be set to true. However, new vector elements of built-in type are not initialized!
The following example illustrates the resize operation of a vector of size 2 to a vector of size 4. The new, uninitialized elements are marked with x:
\f[ \left(\begin{array}{*{2}{c}} 1 & 2 \\ \end{array}\right) \Longrightarrow \left(\begin{array}{*{4}{c}} 1 & 2 & x & x \\ \end{array}\right) \f]
|
inline |
Scaling of the vector by the scalar value scalar ( ).
scalar | The scalar value for the vector scaling. |
This function scales the vector by applying the given scalar value scalar to each element of the vector. For built-in and complex
data types it has the same effect as using the multiplication assignment operator:
|
inline |
Requesting the removal of unused capacity.
This function minimizes the capacity of the vector by removing unused capacity. Please note that due to padding the capacity might not be reduced exactly to size(). Please also note that in case a reallocation occurs, all iterators (including end() iterators), all pointers and references to elements of this vector are invalidated.
|
inlinenoexcept |
Returns the current size/dimension of the vector.
|
inlinenoexcept |
Returns the minimum capacity of the vector.
This function returns the minimum capacity of the vector, which corresponds to the current size plus padding.
|
noexcept |
Store of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
value | The SIMD element to be stored. |
This function performs a store of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
noexcept |
Aligned store of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
value | The SIMD element to be stored. |
This function performs an aligned store of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
noexcept |
Unaligned store of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
value | The SIMD element to be stored. |
This function performs an unaligned store of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
noexcept |
Aligned, non-temporal store of a SIMD element of the vector.
index | Access index. The index must be smaller than the number of vector elements. |
value | The SIMD element to be stored. |
This function performs an aligned, non-temporal store of a specific SIMD element of the dense vector. The index must be smaller than the number of vector elements and it must be a multiple of the number of values inside the SIMD element. This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors.
|
inline |
Default implementation of the subtraction assignment of a dense vector.
SIMD optimized implementation of the subtraction assignment of a dense vector.
rhs | The right-hand side dense vector to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inline |
Default implementation of the subtraction assignment of a sparse vector.
rhs | The right-hand side sparse vector to be subtracted. |
This function must NOT be called explicitly! It is used internally for the performance optimized evaluation of expression templates. Calling this function explicitly might result in erroneous results and/or in compilation errors. Instead of using this function use the assignment operator.
|
inlinenoexcept |
Swapping the contents of two vectors.
v | The vector to be swapped. |
|
staticconstexpr |
Compilation flag for SIMD optimization.
The simdEnabled compilation flag indicates whether expressions the vector is involved in can be optimized via SIMD operationss. In case the element type of the vector is a vectorizable data type, the simdEnabled compilation flag is set to true, otherwise it is set to false.
|
staticconstexpr |
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).
|
private |
The dynamically allocated vector elements.
Access to the vector elements is gained via the subscript operator. The order of the elements is