Reductions

sum

template<typename V, typename T = vector_value_type<V>>
inline T kernel_float::sum(const V &input)

Sum the items in the given vector input.

Example

vec<int, 5> x = {5, 0, 2, 1, 0};
int y = sum(x);  // Returns 8

max

template<typename V, typename T = vector_value_type<V>>
inline T kernel_float::max(const V &input)

Find the maximum element in the given vector input.

Example

vec<int, 5> x = {5, 0, 2, 1, 0};
int y = max(x);  // Returns 5

min

template<typename V, typename T = vector_value_type<V>>
inline T kernel_float::min(const V &input)

Find the minimum element in the given vector input.

Example

vec<int, 5> x = {5, 0, 2, 1, 0};
int y = min(x);  // Returns 0

product

template<typename V, typename T = vector_value_type<V>>
inline T kernel_float::product(const V &input)

Multiply the items in the given vector input.

Example

vec<int, 5> x = {5, 0, 2, 1, 0};
int y = product(x);  // Returns 5*0*2*1*0 = 0

all

template<typename V>
inline bool kernel_float::all(const V &input)

Check if all elements in the given vector input are non-zero. An element v is considered non-zero if bool(v)==true.

any

template<typename V>
inline bool kernel_float::any(const V &input)

Check if any element in the given vector input is non-zero. An element v is considered non-zero if bool(v)==true.

count

template<typename T = int, typename V>
inline T kernel_float::count(const V &input)

Count the number of non-zero items in the given vector input. An element v is considered non-zero if bool(v)==true.

Example

vec<int, 5> x = {5, 0, 2, 1, 0};
int y = count(x);  // Returns 3 (5, 2, 1 are non-zero)

dot

template<typename L, typename R, typename T = promoted_vector_value_type<L, R>>
inline T kernel_float::dot(const L &left, const R &right)

Compute the dot product of the given vectors left and right

Example

vec<int, 3> x = {1, 2, 3};
vec<int, 3> y = {4, 5, 6};
int y = dot(x, y);  // Returns 1*4+2*5+3*6 = 32