OpenKalman
Namespaces | Classes | Typedefs | Functions | Variables
OpenKalman::values Namespace Reference

Definition for values::abs. More...

Namespaces

 internal
 Definition of utilities for atan functions.
 

Classes

struct  consteval_operation
 An operation involving some number of values. More...
 
struct  fixed_2pi
 A fixed version of 2*pi. More...
 
struct  fixed_cast
 A fixed value cast from another fixed value. More...
 
struct  fixed_half_pi
 A fixed version of pi/2. More...
 
struct  fixed_minus_half_pi
 A fixed version of -pi/2. More...
 
struct  fixed_minus_pi
 A fixed version of -pi. More...
 
struct  fixed_partial_ordering_equivalent
 A fixed version of std::partial_ordering::equivalent. More...
 
struct  fixed_partial_ordering_greater
 A fixed version of std::partial_ordering::greater. More...
 
struct  fixed_partial_ordering_less
 A fixed version of std::partial_ordering::less. More...
 
struct  fixed_partial_ordering_unordered
 A fixed version of std::partial_ordering::unordered. More...
 
struct  fixed_pi
 A fixed version of pi. More...
 
struct  fixed_value
 
struct  fixed_value_of
 The fixed value associated with a fixed. More...
 
struct  fixed_value_of< T, std::enable_if_t< fixed< T > > >
 
struct  real_type_of
 Obtain the real type associated with a value (typically a complex number). More...
 
struct  real_type_of< T, std::enable_if_t< value< T > > >
 
struct  unbounded_size_t
 A type reflecting an unbound size. More...
 
struct  value_type_of
 Obtain the underlying value type associated with a value. More...
 
struct  value_type_of< T, std::void_t< decltype(to_value_type(std::declval< T >()))> >
 

Typedefs

template<typename Operation , typename... Args>
using operation_t = decltype(operation(std::declval< Operation && >(), std::declval< Args && >()...))
 The resulting type from an values::operation.
 
template<typename T >
using real_type_of_t = typename real_type_of< T >::type
 Helper template for real_type_of.
 
template<typename T >
using value_type_of_t = typename value_type_of< T >::type
 Helper template for value_type_of.
 

Functions

template<typename T , std::enable_if_t< fixed< T > and not complex< T >, int > = 0>
 fixed_value (const T &) -> fixed_value< typename fixed_value_of< T >::value_type, values::real(fixed_value_of_v< T >), values::imag(fixed_value_of_v< T >)>
 
template<typename T , typename Arg , std::enable_if_t<(not number< T > or not complex< Arg >) and std::is_same_v< T, std::decay_t< T >> and detail::value_type_convertible< Arg, T >::value, int > = 0>
decltype(auto) constexpr cast_to (Arg &&arg)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename Operation , typename... Args>
 consteval_operation (const Operation &, const Args &...) -> consteval_operation< Operation, Args... >
 Deduction guide.
 
template<typename Operation , typename... Args>
constexpr auto operation (Operation &&op, Args &&...args)
 A potentially constant-evaluated operation involving some number of values. More...
 
template<typename Arg >
decltype(auto) constexpr to_value_type (Arg &&arg)
 Convert, if necessary, a fixed or dynamic value to its underlying base type.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto abs (const Arg &arg)
 A constexpr alternative to std::abs.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto acos (const Arg &arg)
 Constexpr alternative to the std::acos function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto acosh (const Arg &arg)
 Constexpr alternative to the std::acosh function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto asin (const Arg &arg)
 Constexpr alternative to the std::asin function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto asinh (const Arg &arg)
 Constexpr alternative to the std::asinh function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto atan (const Arg &arg)
 Constexpr alternative to the std::atan function.
 
template<typename Y , typename X , std::enable_if_t< value< Y > and value< X >, int > = 0>
constexpr auto atan2 (const Y &y_arg, const X &x_arg)
 Constexpr alternative to the std::atan2 function. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto atanh (const Arg &arg)
 Constexpr alternative to the std::atanh function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto conj (const Arg &arg)
 A constexpr function for the complex conjugate of a (complex) number.
 
template<typename Mag , typename Sgn >
constexpr auto copysign (const Mag &mag, const Sgn &sgn)
 A constexpr function for copysign. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto cos (const Arg &arg)
 Constexpr alternative to the std::cos function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto cosh (const Arg &arg)
 Constexpr alternative to the std::cosh function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto exp (const Arg &arg)
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto expm1 (const Arg &arg)
 Constexpr alternative to the std::expm1 function (exponential function minus 1). More...
 
template<typename X , typename Y >
constexpr auto fmod (const X &x, const Y &y)
 A constexpr function for fmod. More...
 
template<typename... Args, std::enable_if_t<(... and value< Args >) and(sizeof...(Args) > 0>
constexpr auto hypot (const Args &...args)
 A constexpr alternative to std::hypot. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto imag (const Arg &arg)
 A constexpr function to obtain the imaginary part of a (complex) number. More...
 
template<typename Arg >
constexpr bool isinf (const Arg &arg)
 Constexpr alternative to std::isinf. More...
 
template<typename Arg >
constexpr bool isnan (const Arg &arg)
 Constexpr alternative to std::isnan. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto log (const Arg &arg)
 Constexpr alternative to the std::log function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto log1p (const Arg &arg)
 Constexpr alternative to the std::log1p function, where log1p(x) = log(x+1). More...
 
template<typename Arg , typename Exponent >
constexpr auto pow (const Arg &arg, const Exponent &exponent)
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto real (const Arg &arg)
 A constexpr function to obtain the real part of a (complex) number. More...
 
template<typename Arg , std::enable_if_t< value< Arg > and not complex< value_type_of_t< Arg >>, int > = 0>
constexpr auto signbit (const Arg &arg)
 A constexpr function analogous to std::signbit. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto sin (const Arg &arg)
 Constexpr alternative to the std::sin function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto sinh (const Arg &arg)
 Constexpr alternative to the std::sinh function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto sqrt (const Arg &arg)
 A constexpr alternative to std::sqrt. More...
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto tan (const Arg &arg)
 Constexpr alternative to the std::tan function.
 
template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto tanh (const Arg &arg)
 

Variables

template<typename T >
constexpr bool complex = value<T> and detail::complex_impl<std::decay_t<T>>::value
 T is a value that reduces to std::complex or a custom complex type.
 
template<typename T >
constexpr bool dynamic
 T is a value that is not fixed at compile time. More...
 
template<typename T >
constexpr bool fixed
 T is a value that is determinable at compile time. More...
 
template<typename T , auto N, auto comp = &stdex::is_eq, unsigned int epsilon_factor = 0U>
constexpr bool fixed_value_compares_with = detail::fixed_value_compares_with_impl<T, N, comp, epsilon_factor>::value
 T has a fixed value that compares with N in a particular way based on parameter comp. More...
 
template<typename T >
constexpr bool floating
 T is a floating-point value. More...
 
template<typename T >
constexpr bool index
 T is an index value. More...
 
template<typename T >
constexpr bool integral = value<T> and detail::reduces_to_integral<T>::value
 T is an integral value.
 
template<typename T >
constexpr bool not_complex
 T is a value in which either its type is not complex or its imaginary component is 0. More...
 
template<typename T >
constexpr bool number
 T is a numerical field type. More...
 
constexpr unbounded_size_t unbounded_size {}
 An instance of unbounded_size_t;.
 
template<typename T >
constexpr bool size
 T is either an index representing a size, or unbounded_size_t, which indicates that the size is unbounded. More...
 
template<typename T , typename U , auto comp = &stdex::is_eq, applicability a = applicability::guaranteed>
constexpr bool size_compares_with
 T and U are sizes that compare in a particular way based on parameter comp. More...
 
template<typename T >
constexpr bool value = detail::value_impl<T>::value
 T is a fixed or dynamic value that is reducible to a number.
 
template<typename T >
constexpr auto fixed_value_of_v = fixed_value_of<T>::value
 Helper template for fixed_value_of.
 

Detailed Description

Definition for values::abs.

Definition for values::tanh.

Definition for values::tan.

Definition for values::sqrt.

Definition for values::sinh.

Definition for values::sin.

Definition for values::signbit.

Definition for values::pow.

Definition for values::log1p.

Definition for values::log.

Definition for values::isnan.

Definition for values::isinf.

Definition for values::hypot.

Definition for values::fmod.

Definition for values::expm1.

Definition for values::exp.

Definition for values::cosh.

Definition for values::cos.

Definition for values::copysign.

Definition for values::atanh.

Definition for values::atan2.

Definition for values::atan.

Definition for values::asinh.

Definition for values::asin.

Definition for values::acosh.

Definition for values::acos.

Function Documentation

◆ atan2()

template<typename Y , typename X , std::enable_if_t< value< Y > and value< X >, int > = 0>
constexpr auto OpenKalman::values::atan2 ( const Y &  y_arg,
const X &  x_arg 
)

Constexpr alternative to the std::atan2 function.

Unlike the standard function, this one accepts complex arguments.

◆ copysign()

template<typename Mag , typename Sgn >
constexpr auto OpenKalman::values::copysign ( const Mag &  mag,
const Sgn &  sgn 
)

A constexpr function for copysign.

If the compiler offers a constexpr version of std::copysign, it will be called. Otherwise, this function determines the sign of sgn and potentially negates mag.

Note
In most pre-c++23 compilations, this function will be inaccurate if the sgn argument is either -NaN or -0.0. This is because prior to the c++23 standard library, there was no way to determine, at compile time, the sign of either ±NaN or ±0.0.
Parameters
magThe magnitude of the result.
sgnA value reflecting the sign of the result.

◆ expm1()

template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto OpenKalman::values::expm1 ( const Arg &  arg)

Constexpr alternative to the std::expm1 function (exponential function minus 1).

Thus uses a Maclaurin series expansion For floating-point values, or multiplication for integral values.

Note
This function allows a complex argument, even though the C++ standard does not as of at least C++23.

◆ fmod()

template<typename X , typename Y >
constexpr auto OpenKalman::values::fmod ( const X &  x,
const Y &  y 
)

A constexpr function for fmod.

If the compiler offers a constexpr version of std::fmod, it will be called. Otherwise, this function returns x - iquot * y, where iquot is x / y with its fractional part truncated.

Note
This will cause an exception unless std::numeric_limits<std::intmax_t>::lowest() <= iquot <= std::numeric_limits<std::intmax_t>::max().

◆ hypot()

template<typename... Args, std::enable_if_t<(... and value< Args >) and(sizeof...(Args) > 0>
constexpr auto OpenKalman::values::hypot ( const Args &...  args)

A constexpr alternative to std::hypot.

This version can take one or more parameters (not limited to 2 or 3 as std::hypot is). Also, this function can take complex arguments

◆ imag()

template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto OpenKalman::values::imag ( const Arg &  arg)

A constexpr function to obtain the imaginary part of a (complex) number.

If arg is complex, arg must either match std::imag(values::to_value_type(arg)) or some defined function imag(values::to_value_type(arg)). If arg is not complex and no imag function is defined, the result will be

  • static_cast<double>(0) if Arg is integral or
  • static_cast<std::decay_t<Arg>>(0) otherwise.

◆ isinf()

template<typename Arg >
constexpr bool OpenKalman::values::isinf ( const Arg &  arg)

Constexpr alternative to std::isinf.

Checks whether the input is positive or negative infinity.

◆ isnan()

template<typename Arg >
constexpr bool OpenKalman::values::isnan ( const Arg &  arg)

Constexpr alternative to std::isnan.

Checks whether the input is not a number (NaN).

◆ log1p()

template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto OpenKalman::values::log1p ( const Arg &  arg)

Constexpr alternative to the std::log1p function, where log1p(x) = log(x+1).

Unlike the standard function, this one accepts complex arguments.

◆ operation()

template<typename Operation , typename... Args>
constexpr auto OpenKalman::values::operation ( Operation &&  op,
Args &&...  args 
)

A potentially constant-evaluated operation involving some number of values.

In this unspecialized case, the operation is not constant-evaluated.

Template Parameters
OperationAn operation taking sizeof...(Args) parameters
ArgsA set of values

◆ real()

template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto OpenKalman::values::real ( const Arg &  arg)

A constexpr function to obtain the real part of a (complex) number.

If arg is complex, arg must either match std::real(values::to_value_type(arg)) or some defined function real(values::to_value_type(arg)). If arg is not complex and no real function is defined, the result will be

  • static_cast<double>(std::forward<Arg>(arg)) if Arg is integral or
  • static_cast<std::decay_t<Arg>>(std::forward<Arg>(arg)) otherwise.

◆ signbit()

template<typename Arg , std::enable_if_t< value< Arg > and not complex< value_type_of_t< Arg >>, int > = 0>
constexpr auto OpenKalman::values::signbit ( const Arg &  arg)

A constexpr function analogous to std::signbit.

If the compiler offers a constexpr version of std::signbit, it will be called. Otherwise, the argument will be compared with zero.

Note
In most pre-c++23 compilations, this function will be inaccurate if the argument is either -NaN or -0.0. This is because prior to the c++23 standard library, there was no way to determine, at compile time, the sign of either ±NaN or ±0.0.

◆ sqrt()

template<typename Arg , std::enable_if_t< value< Arg >, int > = 0>
constexpr auto OpenKalman::values::sqrt ( const Arg &  arg)

A constexpr alternative to std::sqrt.

Uses the Newton-Raphson method

// Code for a purely integral version: T lo = 0 , hi = x / 2 + 1; while (lo != hi) { const T mid = (lo + hi + 1) / 2; if (x / mid < mid) hi = mid - 1; else lo = mid; } return lo;

Variable Documentation

◆ dynamic

template<typename T >
constexpr bool OpenKalman::values::dynamic
Initial value:
=
(not fixed<T>)

T is a value that is not fixed at compile time.

◆ fixed

template<typename T >
constexpr bool OpenKalman::values::fixed
Initial value:
=
stdex::default_initializable<std::decay_t<T>> and
(internal::has_value_member<std::decay_t<T>>::value or
(internal::call_result_is_defined<std::decay_t<T>>::value and internal::call_result_is_constexpr<std::decay_t<T>>::value))
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

T is a value that is determinable at compile time.

Todo:
Include objects that can be implicitly converted to a number at compile time?

◆ fixed_value_compares_with

template<typename T , auto N, auto comp = &stdex::is_eq, unsigned int epsilon_factor = 0U>
constexpr bool OpenKalman::values::fixed_value_compares_with = detail::fixed_value_compares_with_impl<T, N, comp, epsilon_factor>::value

T has a fixed value that compares with N in a particular way based on parameter comp.

Template Parameters
compA consteval-callable object taking the comparison result (e.g., std::partial_ordering) and returning a bool value
epsilon_factorAn epsilon value to account for rounding error. This is multiplied by std::numeric_limits<std::decay_t<T::epsilon(), if it exists. If it is zero, the match must be exact.

◆ floating

template<typename T >
constexpr bool OpenKalman::values::floating
Initial value:
=
value<T> and (not integral<T>) and (not complex<T>)

T is a floating-point value.

◆ index

template<typename T >
constexpr bool OpenKalman::values::index
Initial value:
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

T is an index value.

◆ not_complex

template<typename T >
constexpr bool OpenKalman::values::not_complex
Initial value:
=
value<T> and (not complex<T> or detail::imaginary_part_is_zero<std::decay_t<T>>())

T is a value in which either its type is not complex or its imaginary component is 0.

◆ number

template<typename T >
constexpr bool OpenKalman::values::number
Initial value:
=
interface::number_traits<std::decay_t<T>>::is_specialized

T is a numerical field type.

T can be any arithmetic, complex, or custom number type in which certain traits in interface::number_traits are defined and typical math operations (+, -, *, /, and ==) are also defined.

◆ size

template<typename T >
constexpr bool OpenKalman::values::size
Initial value:
=
index<T> or stdex::same_as<std::decay_t<T>, unbounded_size_t>

T is either an index representing a size, or unbounded_size_t, which indicates that the size is unbounded.

◆ size_compares_with

template<typename T , typename U , auto comp = &stdex::is_eq, applicability a = applicability::guaranteed>
constexpr bool OpenKalman::values::size_compares_with
Initial value:
=
size<T> and
size<U> and
detail::size_compares_with_impl<T, U, comp, a>()

T and U are sizes that compare in a particular way based on parameter comp.

Template Parameters
compA consteval-callable object taking the comparison result (e.g., std::partial_ordering) and returning a bool value