Skip to content

Expressions

abs function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::abs, E1> abs(E1 &&x)

Returns template expression that returns the absolute value of x.

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_FUNCTION expression_function<fn::abs, E1> abs(E1&& x)
{
    return { fn::abs(), std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L302

absmax function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::absmax, E1, E2> absmax(E1 &&x,
                                               E2 &&y)

Returns the greater in magnitude of two values. Accepts and returns expressions.

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION expression_function<fn::absmax, E1, E2> absmax(E1&& x, E2&& y)
{
    return { fn::absmax(), std::forward<E1>(x), std::forward<E2>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L338

absmin function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::absmin, E1, E2> absmin(E1 &&x,
                                               E2 &&y)

Returns the smaller in magnitude of two values. Accepts and returns expressions.

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION expression_function<fn::absmin, E1, E2> absmin(E1&& x, E2&& y)
{
    return { fn::absmin(), std::forward<E1>(x), std::forward<E2>(y) };
}

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

add function

template <typename... E, KFR_ACCEPT_EXPRESSIONS(E...)>
expression_function<fn::add, E...> add(E &&...x)

Returns template expression that returns sum of all the arguments passed to a function.

Source code
template <typename... E, KFR_ACCEPT_EXPRESSIONS(E...)>
KFR_INTRINSIC expression_function<fn::add, E...> add(E&&... x)
{
    return { fn::add(), std::forward<E>(x)... };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L52

adjacent function

template <typename Fn, typename E1>
expression_adjacent<Fn, E1> adjacent(Fn &&fn, E1 &&e1)

Returns template expression that returns the result of calling \(fn(x_i, x_{i-1})\)

Source code
template <typename Fn, typename E1>
KFR_INTRINSIC expression_adjacent<Fn, E1> adjacent(Fn&& fn, E1&& e1)
{
    return { std::forward<Fn>(fn), std::forward<E1>(e1) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/basic_expressions.hpp#L995

cconj function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::cconj, E1> cconj(E1 &&x)

Returns template expression that returns the complex conjugate of the complex number x

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_FUNCTION expression_function<fn::cconj, E1> cconj(E1&& x)
{
    return { fn::cconj(), std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L277

clamp function

template <typename E1, typename E2, typename E3,
          KFR_ACCEPT_EXPRESSIONS(E1, E2, E3)>
expression_function<fn::clamp, E1, E2, E3>
clamp(E1 &&x, E2 &&lo, E3 &&hi)

Creates an expression that returns the first argument clamped to a range [lo, hi]

Source code
template <typename E1, typename E2, typename E3, KFR_ACCEPT_EXPRESSIONS(E1, E2, E3)>
KFR_FUNCTION expression_function<fn::clamp, E1, E2, E3> clamp(E1&& x, E2&& lo, E3&& hi)
{
    return { fn::clamp(), std::forward<E1>(x), std::forward<E2>(lo), std::forward<E3>(hi) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L400

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::clamp, E1, E2> clamp(E1 &&x,
                                             E2 &&hi)

Creates an expression that returns the first argument clamped to a range [0, hi]

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION expression_function<fn::clamp, E1, E2> clamp(E1&& x, E2&& hi)
{
    return { fn::clamp(), std::forward<E1>(x), std::forward<E2>(hi) };
}

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

complex

complex class

template <typename> complex

Represents the complex numbers. If KFR_STD_COMPLEX is defined, then kfr::complex is an alias for std::complex.

Source code
template <typename>
struct complex

https://github.com/kfrlib/kfr/blob//include/kfr/base/expression.hpp#L56

cub function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::cub, E1> cub(E1 &&x)

Returns template expression that returns cube of x.

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_INTRINSIC expression_function<fn::cub, E1> cub(E1&& x)
{
    return { fn::cub(), std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L180

dimensions function

template <index_t Dims, typename E1>
expression_dimensions<Dims, E1> dimensions(E1 &&e1)

Returns template expression with gien number of dimensions

Source code
template <index_t Dims, typename E1>
KFR_INTRINSIC expression_dimensions<Dims, E1> dimensions(E1&& e1)
{
    static_assert(Dims >= expression_dims<E1>, "Number of dimensions must be greater or equal");
    return { std::forward<E1>(e1) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/basic_expressions.hpp#L1069

floor function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::floor, E1> floor(E1 &&x)

Returns the largest integer value not greater than x. Accepts and returns expressions.

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_FUNCTION expression_function<fn::floor, E1> floor(E1&& x)
{
    return { fn::floor(), std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L345

imag function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::imag, E1> imag(E1 &&x)

Returns the imaginary part of the complex value

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_INTRINSIC expression_function<fn::imag, E1> imag(E1&& x)
{
    return { fn::imag{}, std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L270

linspace function

template <typename T = void, bool precise = false, bool truncated = false, typename T1, typename T2,
          typename Tout = or_type<T, ftype<std::common_type_t<T1, T2>>>>
 expression_linspace<Tout, truncated> linspace(T1 start, T2 stop, size_t size,
                                                            bool endpoint = false, cbool_t<truncated> =

Returns evenly spaced numbers over a specified interval.


start The starting value of the sequence
stop The end value of the sequence. if endpoint is false, the last value is excluded
size Number of samples to generate
endpoint If true, stop is the last sample. Otherwise, it is not included @tparam truncated If true, linspace returns exactly size elements, otherwise, returns infinite sequence @tparam precise No longer used since KFR5, calculations are always precise

Source code
template <typename T = void, bool precise = false, bool truncated = false, typename T1, typename T2,
          typename Tout = or_type<T, ftype<std::common_type_t<T1, T2>>>>
KFR_INTRINSIC expression_linspace<Tout, truncated> linspace(T1 start, T2 stop, size_t size,
                                                            bool endpoint = false, cbool_t<truncated> = {})
{
    return { static_cast<Tout>(start), static_cast<Tout>(stop), size, endpoint };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/basic_expressions.hpp#L738

make_complex function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::make_complex, E1, E2>
make_complex(E1 &&re, E2 &&im)

Constructs complex value from real and imaginary parts

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_INTRINSIC expression_function<fn::make_complex, E1, E2> make_complex(E1&& re, E2&& im)
{
    return { fn::make_complex{}, std::forward<E1>(re), std::forward<E2>(im) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L220

max function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::max, E1, E2> max(E1 &&x, E2 &&y)

Returns the greater of two values. Accepts and returns expressions.

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION expression_function<fn::max, E1, E2> max(E1&& x, E2&& y)
{
    return { fn::max(), std::forward<E1>(x), std::forward<E2>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L320

min function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::min, E1, E2> min(E1 &&x, E2 &&y)

Returns the smaller of two values. Accepts and returns expressions.

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_FUNCTION expression_function<fn::min, E1, E2> min(E1&& x, E2&& y)
{
    return { fn::min(), std::forward<E1>(x), std::forward<E2>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L311

mul function

template <typename... E, KFR_ACCEPT_EXPRESSIONS(E...)>
expression_function<fn::mul, E...> mul(E &&...x)

Returns template expression that returns product of all the arguments passed to a function.

Source code
template <typename... E, KFR_ACCEPT_EXPRESSIONS(E...)>
KFR_INTRINSIC expression_function<fn::mul, E...> mul(E&&... x)
{
    return { fn::mul(), std::forward<E>(x)... };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L67

real function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::real, E1> real(E1 &&x)

Returns the real part of the complex value

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_INTRINSIC expression_function<fn::real, E1> real(E1&& x)
{
    return { fn::real{}, std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L263

rebind function

template <typename Fn, typename... OldArgs,
          typename... NewArgs>
expression_function<Fn, NewArgs...>
rebind(const expression_function<Fn, OldArgs...> &e,
       NewArgs &&...args)

Construct a new expression using the same function as in e and new arguments
e an expression
args new arguments for the function

Source code
template <typename Fn, typename... OldArgs, typename... NewArgs>
KFR_FUNCTION expression_function<Fn, NewArgs...> rebind(const expression_function<Fn, OldArgs...>& e,
                                                        NewArgs&&... args)
{
    return expression_function<Fn, NewArgs...>(Fn{ e.fn }, std::forward<NewArgs>(args)...);
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/expression.hpp#L872

satadd function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::satadd, E1, E2> satadd(E1 &&x,
                                               E2 &&y)

Creates an expression that adds two arguments using saturation

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_INTRINSIC expression_function<fn::satadd, E1, E2> satadd(E1&& x, E2&& y)
{
    return { fn::satadd(), std::forward<E1>(x), std::forward<E2>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L414

satsub function

template <typename E1, typename E2,
          KFR_ACCEPT_EXPRESSIONS(E1, E2)>
expression_function<fn::satsub, E1, E2> satsub(E1 &&x,
                                               E2 &&y)

Creates an expression that subtracts two arguments using saturation

Source code
template <typename E1, typename E2, KFR_ACCEPT_EXPRESSIONS(E1, E2)>
KFR_INTRINSIC expression_function<fn::satsub, E1, E2> satsub(E1&& x, E2&& y)
{
    return { fn::satsub(), std::forward<E1>(x), std::forward<E2>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L421

select function

template <typename E1, typename E2, typename E3,
          KFR_ACCEPT_EXPRESSIONS(E1, E2, E3)>
expression_function<fn::select, E1, E2, E3>
select(E1 &&m, E2 &&x, E3 &&y)

Returns template expression that returns x if m is true, otherwise return y. Order of the arguments is same as in ternary operator.

Source code
template <typename E1, typename E2, typename E3, KFR_ACCEPT_EXPRESSIONS(E1, E2, E3)>
KFR_FUNCTION expression_function<fn::select, E1, E2, E3> select(E1&& m, E2&& x, E3&& y)
{
    return { fn::select(), std::forward<E1>(m), std::forward<E2>(x), std::forward<E3>(y) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L293

sink function

template <size_t width = 0, index_t Axis = infinite_size,
          typename E,
          typename Traits = expression_traits<E>>
const E &sink(E &&expr)

Read the expression expr through the whole range.
expr the input expression @return the input expression is returned

Source code
template <size_t width = 0, index_t Axis = infinite_size, typename E, typename Traits = expression_traits<E>>
KFR_FUNCTION const E& sink(E&& expr)
{
    static_assert(!Traits::get_shape().has_infinity());
    process<width, Axis>(expression_discard<expression_value_type<E>, expression_dims<E>>{}, expr);
    return expr;
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/expression.hpp#L854

sqr function

template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
expression_function<fn::sqr, E1> sqr(E1 &&x)

Returns template expression that returns square of x.

Source code
template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)>
KFR_INTRINSIC expression_function<fn::sqr, E1> sqr(E1&& x)
{
    return { fn::sqr(), std::forward<E1>(x) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/simd_expressions.hpp#L171

symmlinspace function

template <typename T, bool precise = false, bool truncated = false, typename Tout = ftype<T>>
 expression_linspace<Tout, truncated> symmlinspace(T symsize, size_t size,
                                                                cbool_t<truncated> =

Returns evenly spaced numbers over a specified interval.


symsize The sequence will have interval [-symsize..symsize]
size Number of samples to generate @tparam truncated If true, linspace returns exactly size elements, otherwise, returns infinite sequence @tparam precise No longer used since KFR5, calculations are always precise

Source code
template <typename T, bool precise = false, bool truncated = false, typename Tout = ftype<T>>
KFR_INTRINSIC expression_linspace<Tout, truncated> symmlinspace(T symsize, size_t size,
                                                                cbool_t<truncated> = {})
{
    return { symmetric_linspace, static_cast<Tout>(symsize), size, true };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/basic_expressions.hpp#L752

trace function

template <typename E1> expression_trace<E1> trace(E1 &&e1)

Returns template expression that prints all processed values for debug

Source code
template <typename E1>
KFR_INTRINSIC expression_trace<E1> trace(E1&& e1)
{
    return { std::forward<E1>(e1) };
}

https://github.com/kfrlib/kfr/blob//include/kfr/base/basic_expressions.hpp#L1024


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