KFR

Complex functions

complex

template<typename T>
class complex

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

std::complex.

c32

using c32 = complex<f32>

Alias for complex<f32>

Source:

using c32 = complex<f32>

c64

using c64 = complex<f64>

Alias for complex<f64>

Source:

using c64 = complex<f64>

cbase

using cbase = complex<fbase>

Alias for complex<fbase>

Source:

using cbase = complex<fbase>

vec

template<typename T, size_t N>
class vec

vec<> specialization for complex numbers. Implements all operators

cdupreal

template<typename T, size_t N>
vec<complex<T>, N> cdupreal(const vec<complex<T>, N> &x)

Returns vector of complex values with real part duplicated

Source:

template <typename T, size_t N>
CMT_INLINE vec<complex<T>, N> cdupreal(const vec<complex<T>, N>& x)

cdupimag

template<typename T, size_t N>
vec<complex<T>, N> cdupimag(const vec<complex<T>, N> &x)

Returns vector of complex values with imaginary part duplicated

Source:

template <typename T, size_t N>
CMT_INLINE vec<complex<T>, N> cdupimag(const vec<complex<T>, N>& x)

cswapreim

template<typename T, size_t N>
vec<complex<T>, N> cswapreim(const vec<complex<T>, N> &x)

Returns vector of complex values with real and imaginary parts swapped

Source:

template <typename T, size_t N>
CMT_INLINE vec<complex<T>, N> cswapreim(const vec<complex<T>, N>& x)

cnegreal

template<typename T, size_t N>
vec<complex<T>, N> cnegreal(const vec<complex<T>, N> &x)

Returns vector of complex values with real part negated

Source:

template <typename T, size_t N>
CMT_INLINE vec<complex<T>, N> cnegreal(const vec<complex<T>, N>& x)

cnegimag

template<typename T, size_t N>
vec<complex<T>, N> cnegimag(const vec<complex<T>, N> &x)

Returns vector of complex values with imaginary part negated

Source:

template <typename T, size_t N>
CMT_INLINE vec<complex<T>, N> cnegimag(const vec<complex<T>, N>& x)

real

template<typename T, KFR_ENABLE_IF(is_numeric<T>::value)>
constexpr T real(const T &value)

Returns the real part of the complex value

Source:

template <typename T, KFR_ENABLE_IF(is_numeric<T>::value)>
constexpr CMT_INLINE T real(const T& value)
{
    return value;
}
template<typename T>
constexpr T real(const complex<T> &value)

Returns the real part of the complex value

Source:

template <typename T>
constexpr CMT_INLINE T real(const complex<T>& value)
{
    return value.real();
}
template<typename T, size_t N>
constexpr vec<T, N> real(const vec<complex<T>, N> &value)

Returns the real part of the complex value

Source:

template <typename T, size_t N>
constexpr CMT_INLINE vec<T, N> real(const vec<complex<T>, N>& value)
{
    return even(compcast<T>(value));
}
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::real, E1> real(E1 &&x)

Returns the real part of the complex value

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
CMT_INLINE internal::expression_function<fn::real, E1> real(E1&& x)

imag

template<typename T>
constexpr T imag(const complex<T> &value)

Returns the imaginary part of the complex value

Source:

template <typename T>
constexpr CMT_INLINE T imag(const complex<T>& value)
{
    return value.imag();
}
template<typename T, size_t N>
constexpr vec<T, N> imag(const vec<complex<T>, N> &value)

Returns the imaginary part of the complex value

Source:

template <typename T, size_t N>
constexpr CMT_INLINE vec<T, N> imag(const vec<complex<T>, N>& value)
{
    return odd(compcast<T>(value));
}
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::imag, E1> imag(E1 &&x)

Returns the imaginary part of the complex value

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
CMT_INLINE internal::expression_function<fn::imag, E1> imag(E1&& x)

make_complex

template<typename T1, typename T2 = T1, size_t N, typename T = common_type<T1, T2>>
constexpr vec<complex<T>, N> make_complex(const vec<T1, N> &real, const vec<T2, N> &imag = T2(0))

Constructs complex value from real and imaginary parts

Source:

template <typename T1, typename T2 = T1, size_t N, typename T = common_type<T1, T2>>
constexpr CMT_INLINE vec<complex<T>, N> make_complex(const vec<T1, N>& real, const vec<T2, N>& imag = T2(0))
{
    return compcast<complex<T>>(interleave(cast<T>(real), cast<T>(imag)));
}
template<typename T1, typename T2 = T1, typename T = common_type<T1, T2>>
constexpr complex<T> make_complex(T1 real, T2 imag = T2(0))

Constructs complex value from real and imaginary parts

Source:

template <typename T1, typename T2 = T1, typename T = common_type<T1, T2>>
constexpr CMT_INLINE complex<T> make_complex(T1 real, T2 imag = T2(0))
{
    return complex<T>(cast<T>(real), cast<T>(imag));
}

csin

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 csin(const T1 &x)

Returns the sine of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 csin(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::csin, E1> csin(E1 &&x)

Returns template expression that returns the sine of the the complex value x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::csin, E1> csin(E1&& x)

csinh

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 csinh(const T1 &x)

Returns the hyperbolic sine of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 csinh(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::csinh, E1> csinh(E1 &&x)

Returns template expression that returns the hyperbolic sine of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::csinh, E1> csinh(E1&& x)

ccos

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 ccos(const T1 &x)

Returns the cosine of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 ccos(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::ccos, E1> ccos(E1 &&x)

Returns template expression that returns the cosine of the the complex value x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::ccos, E1> ccos(E1&& x)

ccosh

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 ccosh(const T1 &x)

Returns the hyperbolic cosine of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 ccosh(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::ccosh, E1> ccosh(E1 &&x)

Returns template expression that returns the hyperbolic cosine of the the complex value x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::ccosh, E1> ccosh(E1&& x)

cabs

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
realtype<T1> cabs(const T1 &x)

Returns the absolute value (magnitude) of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC realtype<T1> cabs(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cabs, E1> cabs(E1 &&x)

Returns template expression that returns the absolute value (magnitude) of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cabs, E1> cabs(E1&& x)

carg

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
realtype<T1> carg(const T1 &x)

Returns the phase angle (argument) of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC realtype<T1> carg(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::carg, E1> carg(E1 &&x)

Returns template expression that returns the phase angle (argument) of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::carg, E1> carg(E1&& x)

cconj

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 cconj(const T1 &x)

Returns the complex conjugate of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 cconj(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cconj, E1> cconj(E1 &&x)

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

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cconj, E1> cconj(E1&& x)

clog

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 clog(const T1 &x)

Returns the natural logarithm of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 clog(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::clog, E1> clog(E1 &&x)

Returns template expression that returns the natural logarithm of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::clog, E1> clog(E1&& x)

clog2

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 clog2(const T1 &x)

Returns the binary (base-2) logarithm of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 clog2(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::clog2, E1> clog2(E1 &&x)

Returns template expression that returns the binary (base-2) logarithm of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::clog2, E1> clog2(E1&& x)

clog10

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 clog10(const T1 &x)

Returns the common (base-10) logarithm of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 clog10(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::clog10, E1> clog10(E1 &&x)

Returns template expression that returns the common (base-10) logarithm of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::clog10, E1> clog10(E1&& x)

cexp

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 cexp(const T1 &x)

Returns \(e\) raised to the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 cexp(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cexp, E1> cexp(E1 &&x)

Returns template expression that returns \(e\) raised to the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cexp, E1> cexp(E1&& x)

cexp2

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 cexp2(const T1 &x)

Returns 2 raised to the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 cexp2(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cexp2, E1> cexp2(E1 &&x)

Returns template expression that returns 2 raised to the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cexp2, E1> cexp2(E1&& x)

cexp10

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 cexp10(const T1 &x)

Returns 10 raised to the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 cexp10(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cexp10, E1> cexp10(E1 &&x)

Returns template expression that returns 10 raised to the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cexp10, E1> cexp10(E1&& x)

polar

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 polar(const T1 &x)

Converts complex number to polar

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 polar(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::polar, E1> polar(E1 &&x)

Returns template expression that converts complex number to polar

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::polar, E1> polar(E1&& x)

cartesian

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 cartesian(const T1 &x)

Converts complex number to cartesian

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 cartesian(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::cartesian, E1> cartesian(E1 &&x)

Returns template expression that converts complex number to cartesian

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::cartesian, E1> cartesian(E1&& x)

csqrt

template<typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
T1 csqrt(const T1 &x)

Returns square root of the complex number x

Source:

template <typename T1, KFR_ENABLE_IF(is_numeric<T1>::value)>
KFR_FUNC T1 csqrt(const T1& x)
template<typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
internal::expression_function<fn::csqrt, E1> csqrt(E1 &&x)

Returns template expression that returns square root of the complex number x

Source:

template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>::value)>
KFR_FUNC internal::expression_function<fn::csqrt, E1> csqrt(E1&& x)