![]() |
Blaze 3.9
|
Modules | |
Dense Vectors | |
Sparse Vectors | |
Classes | |
class | blaze::Vector< VT, TF > |
Base class for N-dimensional vectors. More... | |
Vector global 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> | |
constexpr void | blaze::reset (Vector< VT, TF > &vector) |
Resetting the given vector. More... | |
template<typename VT , bool TF> | |
constexpr void | blaze::reset (Vector< VT, TF > &&vector) |
Resetting the given temporary vector. More... | |
template<typename VT , bool TF> | |
constexpr void | blaze::clear (Vector< VT, TF > &vector) |
Clearing the given vector. More... | |
template<typename VT , bool TF> | |
constexpr void | blaze::clear (Vector< VT, TF > &&vector) |
Clearing the given temporary 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> | |
VT::ResultType | blaze::evaluate (const Vector< VT, TF > &vector) |
Evaluates the given vector expression. More... | |
template<bool B, typename VT , bool TF> | |
decltype(auto) | blaze::evaluateIf (const Vector< VT, TF > &vector) |
Conditional evaluation of the given vector expression. 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 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 VT1 , bool TF1, typename VT2 , bool TF2> | |
decltype(auto) | blaze::inner (const Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) |
Scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename VT1 , bool TF1, typename VT2 , bool TF2> | |
decltype(auto) | blaze::dot (const Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) |
Scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename VT1 , bool TF1, typename VT2 , bool TF2> | |
decltype(auto) | blaze::operator, (const Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) |
Scalar product (dot/inner product) of two vectors ( ![]() | |
template<typename VT1 , bool TF1, typename VT2 , bool TF2> | |
decltype(auto) | blaze::outer (const Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) |
Outer product of two vectors ( ![]() | |
template<typename VT1 , typename VT2 , bool TF> | |
decltype(auto) | blaze::cross (const Vector< VT1, TF > &lhs, const Vector< VT2, TF > &rhs) |
Cross product of two vectors ( ![]() | |
template<typename VT > | |
decltype(auto) | blaze::reverse (VT &&v) |
Reverse the elements of a vector. More... | |
template<typename VT , bool TF> | |
decltype(auto) | blaze::pow2 (const Vector< VT, TF > &v) |
Computes the square for each single element of the vector v. More... | |
template<typename VT , bool TF> | |
decltype(auto) | blaze::pow3 (const Vector< VT, TF > &v) |
Computes the cube for each single element of the vector v. More... | |
template<typename VT , bool TF> | |
decltype(auto) | blaze::pow4 (const Vector< VT, TF > &v) |
Computes the quadruple for each single element of the vector v. 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::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. |
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. |
|
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. |
|
constexpr |
Clearing the given temporary vector.
vector | The temporary vector to be cleared. |
|
constexpr |
Clearing the given vector.
vector | The vector to be cleared. |
|
inline |
Cross product of two vectors ( ).
lhs | The left-hand side vector for the cross product. |
rhs | The right-hand side vector for the cross product. |
std::invalid_argument | Invalid vector size for cross product. |
This function computes the cross product of two vectors:
The function returns an expression representing a dense vector of the higher-order element type of the two involved vector element types VT1::ElementType and VT2::ElementType. Both vector types VT1 and VT2 as well as the two element types VT1::ElementType and VT2::ElementType have to be supported by the CrossTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.
|
inline |
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. |
This function represents the scalar product (inner product) of two vectors:
The function returns a scalar value of the higher-order element type of the two involved vector element types VT1::ElementType and VT2::ElementType. Both vector types VT1 and VT2 as well as the two element types VT1::ElementType and VT2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.
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. |
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. |
|
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.
|
inline |
Conditional evaluation of the given vector expression.
vector | The vector to be evaluated. |
In case the given compile time condition evaluates to true, this function evaluates the the given vector expression by means of the evaluate() function. Otherwise the function returns a reference to the given vector expression.
|
inline |
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. |
This function represents the scalar product (inner product) of two vectors:
The function returns a scalar value of the higher-order element type of the two involved vector element types VT1::ElementType and VT2::ElementType. Both vector types VT1 and VT2 as well as the two element types VT1::ElementType and VT2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.
|
constexprnoexcept |
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.
|
inline |
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. |
This function represents the scalar product (inner product) of two vectors:
The function returns a scalar value of the higher-order element type of the two involved vector element types VT1::ElementType and VT2::ElementType. Both vector types VT1 and VT2 as well as the two element types VT1::ElementType and VT2::ElementType have to be supported by the MultTrait class template.
In case the current sizes of the two given vectors don't match, a std::invalid_argument is thrown.
|
inline |
Global output operator for dense and sparse vectors.
os | Reference to the output stream. |
v | Reference to a constant vector object. |
|
inline |
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. |
This function represents the outer product between two vectors:
The operator returns an expression representing a matrix of the higher-order element type of the two involved element types VT1::ElementType and VT2::ElementType.
|
inline |
Computes the square for each single element of the vector v.
v | The input vector. |
The pow2() function computes the square for each element of the input vector v. The function returns an expression representing this operation.
The following example demonstrates the use of the pow2() function:
|
inline |
Computes the cube for each single element of the vector v.
v | The input vector. |
The pow3() function computes the cube for each element of the input vector v. The function returns an expression representing this operation.
The following example demonstrates the use of the pow3() function:
|
inline |
Computes the quadruple for each single element of the vector v.
v | The input vector. |
The pow4() function computes the quadruple for each element of the input vector v. The function returns an expression representing this operation.
The following example demonstrates the use of the pow4() function:
|
constexpr |
Resetting the given temporary vector.
vector | The temporary vector to be resetted. |
|
constexpr |
Resetting the given vector.
vector | The vector to be resetted. |
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.
|
inline |
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.
|
constexprnoexcept |
Returns the current size/dimension of the vector.
vector | The given vector. |