Skip to content

Reducing functions

absmaxof function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T absmaxof(const E1 &x)

Returns the greatest in magnitude of all the elements in x.

x must have its size and type specified.

Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T absmaxof(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::absmax());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L312

absminof function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T absminof(const E1 &x)

Returns the smallest in magnitude of all the elements in x.

x must have its size and type specified.

Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T absminof(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::absmin());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L300

dotproduct function

template <
    typename E1, typename E2,
    typename T = expression_value_type<
        decltype(std::declval<E1>() * std::declval<E2>())>,
    KFR_ACCEPT_EXPRESSIONS(E1, E2)>
T dotproduct(E1 &&x, E2 &&y)

Returns the dot product of two vectors.

x and y must have their sizes and types specified.

\[ x_0y_0 + x_1y_1 + \ldots + x_{N-1}y_{N-1} \]
Source code
template <typename E1, typename E2,
          typename T = expression_value_type<decltype(std::declval<E1>() * std::declval<E2>())>,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION T dotproduct(E1&& x, E2&& y)
{
    auto m    = std::forward<E1>(x) * std::forward<E2>(y);
    using E12 = decltype(m);
    static_assert(!is_infinite<E12>, "e1 must be a sized expression (use slice())");
    return reduce(std::move(m), fn::add());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L329

histogram function

template <typename E, typename TCount = uint32_t>
histogram_data<0, TCount> histogram(E &&expr, size_t bins)

Returns histogram of the expression data. Number of bins defined at runtime

Source code
template <typename E, typename TCount = uint32_t>
KFR_FUNCTION histogram_data<0, TCount> histogram(E&& expr, size_t bins)
{
    return sink(histogram_expression(std::forward<E>(expr), bins)).data;
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L407

template <size_t Bins, typename E,
          typename TCount = uint32_t>
histogram_data<Bins, TCount> histogram(E &&expr)

Returns histogram of the expression data. Number of bins defined at compile time

Source code
template <size_t Bins, typename E, typename TCount = uint32_t>
KFR_FUNCTION histogram_data<Bins, TCount> histogram(E&& expr)
{
    return sink(histogram_expression<Bins>(std::forward<E>(expr))).data;
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L417

histogram_expression function

template <typename E, typename TCount = uint32_t>
expression_histogram<0, E, TCount>
histogram_expression(E &&expr, size_t bins)

Returns expression that computes histogram as data flows through it. Number of bins defined at runtime

Source code
template <typename E, typename TCount = uint32_t>
KFR_FUNCTION expression_histogram<0, E, TCount> histogram_expression(E&& expr, size_t bins)
{
    return { std::forward<E>(expr), bins };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L387

template <size_t Bins, typename E,
          typename TCount = uint32_t>
expression_histogram<Bins, E, TCount>
histogram_expression(E &&expr)

Returns expression that computes histogram as data flows through it. Number of bins defined at compile time

Source code
template <size_t Bins, typename E, typename TCount = uint32_t>
KFR_FUNCTION expression_histogram<Bins, E, TCount> histogram_expression(E&& expr)
{
    return { std::forward<E>(expr), Bins };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L397

maxof function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T maxof(const E1 &x)

Returns the greatest of all the elements in x.

x must have its size and type specified.

Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T maxof(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::max());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L288

mean function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T mean(const E1 &x)

Returns the arithmetic mean of all the elements in x.

x must have its size and type specified.

\[ \frac{1}{N}(x_0 + x_1 + \ldots + x_{N-1}) \]
Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T mean(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::add(), fn_generic::pass_through(), fn::final_mean());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L264

minof function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T minof(const E1 &x)

Returns the smallest of all the elements in x.

x must have its size and type specified.

Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T minof(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::min());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L276

product function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T product(const E1 &x)

Returns the product of all the elements in x.

x must have its size and type specified.

\[ x_0 \cdot x_1 \cdot \ldots \cdot x_{N-1} \]
Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T product(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::mul());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L376

rms function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T rms(const E1 &x)

Returns the root mean square of all the elements in x.

x must have its size and type specified.

\[ \sqrt{\frac{1}{N}( x_0^2 + x_1^2 + \ldots + x_{N-1}^2)} \]
Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T rms(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::add(), fn::sqr(), fn::final_rootmean());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L346

sum function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T sum(const E1 &x)

Returns the sum of all the elements in x.

x must have its size and type specified.

\[ x_0 + x_1 + \ldots + x_{N-1} \]
Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T sum(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::add());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L249

sumsqr function

template <typename E1,
          typename T = expression_value_type<E1>,
          KFR_ENABLE_IF(is_input_expression<E1>)>
T sumsqr(const E1 &x)

Returns the sum of squares of all the elements in x.

x must have its size and type specified.

\[ x_0^2 + x_1^2 + \ldots + x_{N-1}^2 \]
Source code
template <typename E1, typename T = expression_value_type<E1>, KFR_ENABLE_IF(is_input_expression<E1>)>
KFR_FUNCTION T sumsqr(const E1& x)
{
    static_assert(!is_infinite<E1>, "e1 must be a sized expression (use slice())");
    return reduce(x, fn::add(), fn::sqr());
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/reduce.hpp#L361


Auto-generated from sources, Revision , https://github.com/kfrlib/kfr/blob//include/kfr/