![]() |
Blaze
3.6
|
Modules | |
Dense Vectors | |
Sparse Vectors | |
Classes | |
struct | blaze::Vector< VT, TF > |
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-dimensional) dense and sparse vector classes within the Blaze library. It provides an abstraction from the actual type of the vector, but enables a conversion back to this type via the 'Curiously Recurring Template Pattern' (CRTP). More... | |
Functions | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::Iterator | blaze::begin (Vector< VT, TF > &vector) |
Returns an iterator to the first element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::ConstIterator | blaze::begin (const Vector< VT, TF > &vector) |
Returns an iterator to the first element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::ConstIterator | blaze::cbegin (const Vector< VT, TF > &vector) |
Returns an iterator to the first element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::Iterator | blaze::end (Vector< VT, TF > &vector) |
Returns an iterator just past the last element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::ConstIterator | blaze::end (const Vector< VT, TF > &vector) |
Returns an iterator just past the last element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE VT::ConstIterator | blaze::cend (const Vector< VT, TF > &vector) |
Returns an iterator just past the last element of the given vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE constexpr size_t | blaze::size (const Vector< VT, TF > &vector) noexcept |
Returns the current size/dimension of the vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE size_t | blaze::capacity (const Vector< VT, TF > &vector) noexcept |
Returns the maximum capacity of the vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE size_t | blaze::nonZeros (const Vector< VT, TF > &vector) |
Returns the number of non-zero elements in the vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE void | blaze::resize (Vector< VT, TF > &vector, size_t n, bool preserve) |
Changing the size of the vector. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE void | blaze::shrinkToFit (Vector< VT, TF > &vector) |
Requesting the removal of unused capacity. More... | |
template<typename VT , bool TF> | |
BLAZE_ALWAYS_INLINE constexpr bool | blaze::isEmpty (const Vector< VT, TF > &vector) noexcept |
Checks if the given vector is empty. More... | |
template<typename VT1 , bool TF1, typename VT2 , bool TF2> | |
BLAZE_ALWAYS_INLINE bool | blaze::isSame (const Vector< VT1, TF1 > &a, const Vector< VT2, TF2 > &b) noexcept |
Returns whether the two given vectors represent the same observable state. More... | |
Vector global functions | |
template<typename VT , bool TF> | |
const VT::ResultType | blaze::evaluate (const Vector< VT, TF > &vector) |
Evaluates the given vector expression. More... | |
Vector functions | |
template<typename VT , bool TF> | |
bool | blaze::isUniform (const Vector< VT, TF > &v) |
Checks if the given vector is a uniform vector. More... | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::inner (const Vector< T1, false > &lhs, const Vector< T2, false > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::inner (const Vector< T1, false > &lhs, const Vector< T2, true > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::inner (const Vector< T1, true > &lhs, const Vector< T2, false > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::inner (const Vector< T1, true > &lhs, const Vector< T2, true > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , bool TF1, typename T2 , bool TF2> | |
decltype(auto) | blaze::dot (const Vector< T1, TF1 > &lhs, const Vector< T2, TF2 > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , bool TF1, typename T2 , bool TF2> | |
decltype(auto) | blaze::operator, (const Vector< T1, TF1 > &lhs, const Vector< T2, TF2 > &rhs) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::outer (const Vector< T1, false > &lhs, const Vector< T2, false > &rhs) |
Multiplication operator for the outer product of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::outer (const Vector< T1, false > &lhs, const Vector< T2, true > &rhs) |
Multiplication operator for the outer product of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::outer (const Vector< T1, true > &lhs, const Vector< T2, false > &rhs) |
Multiplication operator for the outer product of two vectors ( ![]() | |
template<typename T1 , typename T2 > | |
decltype(auto) | blaze::outer (const Vector< T1, true > &lhs, const Vector< T2, true > &rhs) |
Multiplication operator for the outer product of two vectors ( ![]() | |
template<typename VT , bool TF> | |
decltype(auto) | blaze::reverse (const Vector< VT, TF > &v) |
Reverse the elements of a vector. More... | |
Vector operators | |
template<typename VT , bool TF> | |
std::ostream & | blaze::operator<< (std::ostream &os, const Vector< VT, TF > &v) |
Global output operator for dense and sparse vectors. More... | |
BLAZE_ALWAYS_INLINE VT::Iterator blaze::begin | ( | Vector< VT, TF > & | vector | ) |
Returns an iterator to the first element of the given vector.
vector | The given dense or sparse vector. |
BLAZE_ALWAYS_INLINE VT::ConstIterator blaze::begin | ( | const Vector< VT, TF > & | vector | ) |
Returns an iterator to the first element of the given vector.
vector | The given dense or sparse vector. |
|
noexcept |
Returns the maximum capacity of the vector.
vector | The given vector. |
BLAZE_ALWAYS_INLINE VT::ConstIterator blaze::cbegin | ( | const Vector< VT, TF > & | vector | ) |
Returns an iterator to the first element of the given vector.
vector | The given dense or sparse vector. |
BLAZE_ALWAYS_INLINE VT::ConstIterator blaze::cend | ( | const Vector< VT, TF > & | vector | ) |
Returns an iterator just past the last element of the given vector.
vector | The given dense or sparse vector. |
decltype(auto) blaze::dot | ( | const Vector< T1, TF1 > & | lhs, |
const Vector< T2, TF2 > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
BLAZE_ALWAYS_INLINE VT::Iterator blaze::end | ( | Vector< VT, TF > & | vector | ) |
Returns an iterator just past the last element of the given vector.
vector | The given dense or sparse vector. |
BLAZE_ALWAYS_INLINE VT::ConstIterator blaze::end | ( | const Vector< VT, TF > & | vector | ) |
Returns an iterator just past the last element of the given vector.
vector | The given dense or sparse vector. |
|
inline |
Evaluates the given vector expression.
vector | The vector to be evaluated. |
This function forces an evaluation of the given vector expression and enables an automatic deduction of the correct result type of an operation. The following code example demonstrates its intended use for the multiplication of a dense and a sparse vector:
In this scenario, the evaluate() function assists in deducing the exact result type of the operation via the 'auto' keyword. Please note that if evaluate() is used in this way, no temporary vector is created and no copy operation is performed. Instead, the result is directly written to the target vector due to the return value optimization (RVO). However, if evaluate() is used in combination with an explicit target type, a temporary will be created and a copy operation will be performed if the used type differs from the type returned from the function:
Sometimes it might be desirable to explicitly evaluate a sub-expression within a larger expression. However, please note that evaluate() is not intended to be used for this purpose. This task is more elegantly and efficiently handled by the eval() function:
In contrast to the evaluate() function, eval() can take the complete expression into account and therefore can guarantee the most efficient way to evaluate it.
decltype(auto) blaze::inner | ( | const Vector< T1, false > & | lhs, |
const Vector< T2, false > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
decltype(auto) blaze::inner | ( | const Vector< T1, false > & | lhs, |
const Vector< T2, true > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
decltype(auto) blaze::inner | ( | const Vector< T1, true > & | lhs, |
const Vector< T2, false > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
decltype(auto) blaze::inner | ( | const Vector< T1, true > & | lhs, |
const Vector< T2, true > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
|
noexcept |
Checks if the given vector is empty.
vector | The vector to be checked. |
This function checks if the total number of elements of the given vector is zero. If the total number of elements is zero the function returns true, otherwise it returns false.
|
noexcept |
Returns whether the two given vectors represent the same observable state.
a | The first vector to be tested for its state. |
b | The second vector to be tested for its state. |
The isSame function provides an abstract interface for testing if the two given vectors represent the same observable state. This happens for instance in case a
and b
refer to the same vector or in case a
and b
are aliases for the same vector. In case both vectors represent the same observable state, the function returns true, other it returns false.
|
inline |
Checks if the given vector is a uniform vector.
v | The vector to be checked. |
This function checks if the given dense or sparse vector is a uniform vector. The vector is considered to be uniform if all its elements are identical. The following code example demonstrates the use of the function:
Optionally, it is possible to switch between strict semantics (blaze::strict) and relaxed semantics (blaze::relaxed):
It is also possible to check if a vector expression results in a uniform vector:
However, note that this might require the complete evaluation of the expression, including the generation of a temporary vector.
BLAZE_ALWAYS_INLINE size_t blaze::nonZeros | ( | const Vector< VT, TF > & | vector | ) |
Returns the number of non-zero elements in the vector.
vector | The given vector. |
Note that the number of non-zero elements is always less than or equal to the current size of the vector.
decltype(auto) blaze::operator, | ( | const Vector< T1, TF1 > & | lhs, |
const Vector< T2, TF2 > & | rhs | ||
) |
Multiplication operator for the scalar product (dot/inner product) of two vectors ( ).
lhs | The left-hand side vector for the scalar product. |
rhs | The right-hand side vector for the scalar product. |
|
inline |
Global output operator for dense and sparse vectors.
os | Reference to the output stream. |
v | Reference to a constant vector object. |
decltype(auto) blaze::outer | ( | const Vector< T1, false > & | lhs, |
const Vector< T2, false > & | rhs | ||
) |
Multiplication operator for the outer product of two vectors ( ).
lhs | The left-hand side vector for the outer product. |
rhs | The right-hand side vector for the outer product. |
decltype(auto) blaze::outer | ( | const Vector< T1, false > & | lhs, |
const Vector< T2, true > & | rhs | ||
) |
Multiplication operator for the outer product of two vectors ( ).
lhs | The left-hand side vector for the outer product. |
rhs | The right-hand side vector for the outer product. |
decltype(auto) blaze::outer | ( | const Vector< T1, true > & | lhs, |
const Vector< T2, false > & | rhs | ||
) |
Multiplication operator for the outer product of two vectors ( ).
lhs | The left-hand side vector for the outer product. |
rhs | The right-hand side vector for the outer product. |
decltype(auto) blaze::outer | ( | const Vector< T1, true > & | lhs, |
const Vector< T2, true > & | rhs | ||
) |
Multiplication operator for the outer product of two vectors ( ).
lhs | The left-hand side vector for the outer product. |
rhs | The right-hand side vector for the outer product. |
BLAZE_ALWAYS_INLINE void blaze::resize | ( | Vector< VT, TF > & | vector, |
size_t | n, | ||
bool | preserve | ||
) |
Changing the size of the vector.
vector | The given vector to be resized. |
n | The new size of the vector. |
preserve | true if the old values of the vector should be preserved, false if not. |
std::invalid_argument | Vector cannot be resized. |
This function provides a unified interface to resize dense and sparse vectors. In contrast to the resize()
member function, which is only available on resizable vector types, this function can be used on both resizable and non-resizable vectors. In case the given vector type VT is resizable (i.e. provides a resize()
function), the type-specific resize()
member function is called. Depending on the type VT, this may result in the allocation of new dynamic memory and the invalidation of existing views (subvectors, ...). In case VT is non-resizable (i.e. does not provide a resize()
function) and if the specified size is not identical to the current size of the vector, a std::invalid_argument exception is thrown.
decltype(auto) blaze::reverse | ( | const Vector< VT, TF > & | v | ) |
Reverse the elements of a vector.
v | The vector to be reversed. |
This function reverses the elements of a dense or sparse vector. The following examples demonstrates this by means of a dense vector:
BLAZE_ALWAYS_INLINE void blaze::shrinkToFit | ( | Vector< VT, TF > & | vector | ) |
Requesting the removal of unused capacity.
vector | The given vector to be shrunk. |
This function tries to minimize the capacity of the vector by removing unused capacity. Please note that in case of a shrinkable vector, due to padding the capacity might not be reduced exactly to the size of the vector. 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. In case of an unshrinkable vector the function has no effect.
|
noexcept |
Returns the current size/dimension of the vector.
vector | The given vector. |