1#ifndef _GLUCAT_SCALAR_H
2#define _GLUCAT_SCALAR_H
37#include <boost/numeric/ublas/traits.hpp>
46 template<
typename Scalar_T >
83 isInf(
const Scalar_T& val) ->
bool
86 bool_to_type< std::numeric_limits<Scalar_T>::has_infinity >() );
93 isNaN(
const Scalar_T& val) ->
bool
96 bool_to_type< std::numeric_limits<Scalar_T>::has_quiet_NaN >() );
106 bool_to_type< std::numeric_limits<Scalar_T>::has_quiet_NaN >() )
108 bool_to_type< std::numeric_limits<Scalar_T>::has_infinity >() );
117 return std::numeric_limits<Scalar_T>::has_quiet_NaN
118 ? std::numeric_limits<Scalar_T>::quiet_NaN()
119 : Scalar_T(std::log(0.0));
127 {
return static_cast<int>(val); }
134 {
return static_cast<double>(val); }
137 template <
typename Other_Scalar_T >
142 {
return static_cast<Scalar_T
>(val); }
154 fmod(
const Scalar_T& lhs,
const Scalar_T& rhs) -> Scalar_T
155 {
return std::fmod(lhs, rhs); }
161 conj(
const Scalar_T& val) -> Scalar_T
168 real(
const Scalar_T& val) -> Scalar_T
175 imag(
const Scalar_T& val) -> Scalar_T
176 {
return Scalar_T(0); }
182 abs(
const Scalar_T& val) -> Scalar_T
183 {
return boost::numeric::ublas::type_traits<Scalar_T>::UBLAS_ABS(val); }
190 {
return Scalar_T(3.14159265358979323); }
197 {
return Scalar_T(0.693147180559945309); }
203 pow(
const Scalar_T& val,
int n) -> Scalar_T
204 {
return std::pow(val, n); }
210 sqrt(
const Scalar_T& val) -> Scalar_T
211 {
return boost::numeric::ublas::type_traits<Scalar_T>::UBLAS_SQRT(val); }
217 exp(
const Scalar_T& val) -> Scalar_T
218 {
return std::exp(val); }
224 log(
const Scalar_T& val) -> Scalar_T
225 {
return std::log(val); }
231 log2(
const Scalar_T& val) -> Scalar_T
238 cos(
const Scalar_T& val) -> Scalar_T
239 {
return std::cos(val); }
245 acos(
const Scalar_T& val) -> Scalar_T
246 {
return std::acos(val); }
252 cosh(
const Scalar_T& val) -> Scalar_T
253 {
return std::cosh(val); }
259 sin(
const Scalar_T& val) -> Scalar_T
260 {
return std::sin(val); }
266 asin(
const Scalar_T& val) -> Scalar_T
267 {
return std::asin(val); }
273 sinh(
const Scalar_T& val) -> Scalar_T
274 {
return std::sinh(val); }
280 tan(
const Scalar_T& val) -> Scalar_T
281 {
return std::tan(val); }
287 atan(
const Scalar_T& val) -> Scalar_T
288 {
return std::atan(val); }
294 tanh(
const Scalar_T& val) -> Scalar_T
295 {
return std::tanh(val); }
300 template<
typename Scalar_T >
303 log2(
const Scalar_T& x) -> Scalar_T
Extra traits which extend numeric limits.
static auto log2(const Scalar_T &val) -> Scalar_T
Log base 2.
static auto isNaN(const Scalar_T &val, bool_to_type< false >) -> bool
Smart isnan specialised for Scalar_T without quiet NaN.
static auto isInf(const Scalar_T &val, bool_to_type< true >) -> bool
Smart isinf specialised for Scalar_T with infinity.
static auto sqrt(const Scalar_T &val) -> Scalar_T
Square root of scalar.
static auto fmod(const Scalar_T &lhs, const Scalar_T &rhs) -> Scalar_T
Modulo function for scalar.
static auto NaN() -> Scalar_T
Smart NaN.
static auto real(const Scalar_T &val) -> Scalar_T
Real part of scalar.
static auto exp(const Scalar_T &val) -> Scalar_T
Exponential.
static auto conj(const Scalar_T &val) -> Scalar_T
Complex conjugate of scalar.
static auto isNaN_or_isInf(const Scalar_T &val) -> bool
Smart isnan or isinf.
static auto sin(const Scalar_T &val) -> Scalar_T
Sine of scalar.
static auto abs(const Scalar_T &val) -> Scalar_T
Absolute value of scalar.
static auto ln_2() -> Scalar_T
log(2)
static auto isNaN(const Scalar_T &val, bool_to_type< true >) -> bool
Smart isnan specialised for Scalar_T with quiet NaN.
static auto to_scalar_t(const Other_Scalar_T &val) -> Scalar_T
Cast to Scalar_T.
static auto isInf(const Scalar_T &val) -> bool
Smart isinf.
static auto cosh(const Scalar_T &val) -> Scalar_T
Hyperbolic cosine of scalar.
static auto to_double(const Scalar_T &val) -> double
Cast to double.
static auto cos(const Scalar_T &val) -> Scalar_T
Cosine of scalar.
static auto asin(const Scalar_T &val) -> Scalar_T
Inverse sine of scalar.
static auto log(const Scalar_T &val) -> Scalar_T
Logarithm of scalar.
static auto isInf(const Scalar_T &val, bool_to_type< false >) -> bool
Smart isinf specialised for Scalar_T without infinity.
static auto sinh(const Scalar_T &val) -> Scalar_T
Hyperbolic sine of scalar.
static auto tanh(const Scalar_T &val) -> Scalar_T
Hyperbolic tangent of scalar.
static auto imag(const Scalar_T &val) -> Scalar_T
Imaginary part of scalar.
static auto pi() -> Scalar_T
Pi.
static auto pow(const Scalar_T &val, int n) -> Scalar_T
Integer power.
static auto isNaN(const Scalar_T &val) -> bool
Smart isnan.
static auto acos(const Scalar_T &val) -> Scalar_T
Inverse cosine of scalar.
static auto to_int(const Scalar_T &val) -> int
Cast to int.
static auto tan(const Scalar_T &val) -> Scalar_T
Tangent of scalar.
static auto atan(const Scalar_T &val) -> Scalar_T
Inverse tangent of scalar.
auto log2(const Scalar_T &x) -> Scalar_T
Log base 2 of scalar.