Types
vector
-
template<typename T, typename E, class S>
struct vector : public S Container that store fixed number of elements of type
T
.It is not recommended to use this class directly, instead, use the type
vec<T, N>
which is an alias forvector<T, extent<N>, vector_storage<T, E>>
.- Template Parameters:
T – The type of the values stored within the vector.
E – The size of this vector. Should be of type
extent<N>
.S – The object’s storage class. Should be the type
vector_storage<T, E>
Public Functions
-
inline storage_type &storage()
Returns a reference to the underlying storage type.
-
inline const storage_type &storage() const
Returns a reference to the underlying storage type.
-
template<typename ...Is>
inline select_type<self_type, Is...> select(const Is&... indices) Selects elements from the this vector based on the specified indices.
Example
vec<float, 6> input = {0, 10, 20, 30, 40, 50}; vec<float, 4> vec1 = select(input, 0, 4, 4, 2); // [0, 40, 40, 20] vec<int, 4> indices = {0, 4, 4, 2}; vec<float, 4> vec2 = select(input, indices); // [0, 40, 40, 20]
-
template<typename R, RoundingMode Mode = RoundingMode::ANY>
inline vector<R, extent_type> cast() const Cast the elements of this vector to type
R
and returns a new vector.
-
template<size_t... Ns>
inline vector<T, extent<Ns...>> broadcast(extent<Ns...> new_size = {}) const Broadcast this vector into a new size
(Ns...)
.
-
template<typename F>
inline vector<result_t<F, T>, E> map(F fun) const Apply the given function
F
to each element of this vector and returns a new vector with the results.
-
template<typename F>
inline T reduce(F fun) const Reduce the elements of the given vector input into a single value using the function
F
.This function should be a binary function that takes two elements and returns one element. The order in which the elements are reduced is not specified and depends on the reduction function and the vector type.
Public Static Functions
-
static inline constexpr size_t size()
Returns the number of elements in this vector.