Commit cda85450 authored by Robert Maynard's avatar Robert Maynard Committed by Kitware Robot
Browse files

Merge topic 'better_FloatingPointReturnType'

a9e64c4b

 FloatPointReturnType is float if 'T' is < 32bytes instead of being double.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Kenneth Moreland's avatarKenneth Moreland <kmorel@sandia.gov>
Acked-by: Thomas Otahal's avatarThomas Otahal <tjotaha@sandia.gov>
Merge-request: !1048
parents 747c5c90 a9e64c4b
......@@ -88,41 +88,24 @@ static inline VTKM_EXEC_CONT vtkm::Float64 Pi_4()
namespace detail
{
template <typename T>
struct FloatingPointReturnCondition
: std::enable_if<
std::is_same<typename vtkm::VecTraits<T>::ComponentType, vtkm::Float32>::value ||
std::is_same<typename vtkm::VecTraits<T>::ComponentType, const vtkm::Float32>::value>
{
};
template <typename T, typename = void>
struct FloatingPointReturnType
{
using Type = vtkm::Float64;
};
template <typename T>
struct FloatingPointReturnType<T, typename FloatingPointReturnCondition<T>::type>
{
using Type = vtkm::Float32;
using ctype = typename vtkm::VecTraits<T>::ComponentType;
using representable_as_float_type =
std::integral_constant<bool,
((sizeof(ctype) < sizeof(float)) ||
std::is_same<ctype, vtkm::Float32>::value)>;
using Type = typename std::conditional<representable_as_float_type::value,
vtkm::Float32,
vtkm::Float64>::type;
};
} // namespace detail
/// Compute the sine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Sin(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sin)(static_cast<vtkm::Float64>(x));
#else
return std::sin(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Sin(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 Sin(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(sin)(x);
......@@ -130,8 +113,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Sin(v
return std::sin(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Sin(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 Sin(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sin)(x);
......@@ -139,6 +122,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Sin(v
return std::sin(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Sin(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::Sin(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> Sin(
const vtkm::Vec<T, N>& x)
......@@ -174,17 +163,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the cosine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Cos(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cos)(static_cast<vtkm::Float64>(x));
#else
return std::cos(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Cos(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 Cos(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(cos)(x);
......@@ -192,8 +172,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Cos(v
return std::cos(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Cos(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 Cos(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cos)(x);
......@@ -201,6 +181,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Cos(v
return std::cos(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Cos(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::Cos(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> Cos(
const vtkm::Vec<T, N>& x)
......@@ -236,17 +222,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the tangent of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Tan(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(tan)(static_cast<vtkm::Float64>(x));
#else
return std::tan(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Tan(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 Tan(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(tan)(x);
......@@ -254,8 +231,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Tan(v
return std::tan(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Tan(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 Tan(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(tan)(x);
......@@ -263,6 +240,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Tan(v
return std::tan(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Tan(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::Tan(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> Tan(
const vtkm::Vec<T, N>& x)
......@@ -298,17 +281,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the arc sine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ASin(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(asin)(static_cast<vtkm::Float64>(x));
#else
return std::asin(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ASin(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ASin(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(asin)(x);
......@@ -316,8 +290,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ASin(
return std::asin(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ASin(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ASin(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(asin)(x);
......@@ -325,6 +299,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ASin(
return std::asin(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ASin(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ASin(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ASin(
const vtkm::Vec<T, N>& x)
......@@ -360,17 +340,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the arc cosine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ACos(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(acos)(static_cast<vtkm::Float64>(x));
#else
return std::acos(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ACos(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ACos(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(acos)(x);
......@@ -378,8 +349,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ACos(
return std::acos(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ACos(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ACos(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(acos)(x);
......@@ -387,6 +358,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ACos(
return std::acos(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ACos(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ACos(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ACos(
const vtkm::Vec<T, N>& x)
......@@ -422,17 +399,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the arc tangent of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ATan(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(atan)(static_cast<vtkm::Float64>(x));
#else
return std::atan(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ATan(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ATan(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(atan)(x);
......@@ -440,8 +408,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ATan(
return std::atan(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ATan(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ATan(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(atan)(x);
......@@ -449,6 +417,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ATan(
return std::atan(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ATan(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ATan(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ATan(
const vtkm::Vec<T, N>& x)
......@@ -504,17 +478,8 @@ static inline VTKM_EXEC_CONT vtkm::Float64 ATan2(vtkm::Float64 x, vtkm::Float64
/// Compute the hyperbolic sine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type SinH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sinh)(static_cast<vtkm::Float64>(x));
#else
return std::sinh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type SinH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 SinH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(sinh)(x);
......@@ -522,8 +487,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type SinH(
return std::sinh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type SinH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 SinH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sinh)(x);
......@@ -531,6 +496,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type SinH(
return std::sinh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type SinH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::SinH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> SinH(
const vtkm::Vec<T, N>& x)
......@@ -566,17 +537,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the hyperbolic cosine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type CosH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cosh)(static_cast<vtkm::Float64>(x));
#else
return std::cosh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type CosH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 CosH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(cosh)(x);
......@@ -584,8 +546,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type CosH(
return std::cosh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type CosH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 CosH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cosh)(x);
......@@ -593,6 +555,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type CosH(
return std::cosh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type CosH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::CosH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> CosH(
const vtkm::Vec<T, N>& x)
......@@ -628,17 +596,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the hyperbolic tangent of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type TanH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(tanh)(static_cast<vtkm::Float64>(x));
#else
return std::tanh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type TanH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 TanH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(tanh)(x);
......@@ -646,8 +605,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type TanH(
return std::tanh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type TanH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 TanH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(tanh)(x);
......@@ -655,6 +614,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type TanH(
return std::tanh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type TanH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::TanH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> TanH(
const vtkm::Vec<T, N>& x)
......@@ -690,17 +655,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the hyperbolic arc sine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ASinH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(asinh)(static_cast<vtkm::Float64>(x));
#else
return std::asinh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ASinH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ASinH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(asinh)(x);
......@@ -708,8 +664,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ASinH
return std::asinh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ASinH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ASinH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(asinh)(x);
......@@ -717,6 +673,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ASinH
return std::asinh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ASinH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ASinH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ASinH(
const vtkm::Vec<T, N>& x)
......@@ -752,17 +714,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the hyperbolic arc cosine of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ACosH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(acosh)(static_cast<vtkm::Float64>(x));
#else
return std::acosh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ACosH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ACosH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(acosh)(x);
......@@ -770,8 +723,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ACosH
return std::acosh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ACosH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ACosH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(acosh)(x);
......@@ -779,6 +732,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ACosH
return std::acosh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ACosH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ACosH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ACosH(
const vtkm::Vec<T, N>& x)
......@@ -814,17 +773,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the hyperbolic arc tangent of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ATanH(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(atanh)(static_cast<vtkm::Float64>(x));
#else
return std::atanh(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ATanH(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 ATanH(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(atanh)(x);
......@@ -832,8 +782,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type ATanH
return std::atanh(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ATanH(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 ATanH(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(atanh)(x);
......@@ -841,6 +791,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type ATanH
return std::atanh(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type ATanH(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::ATanH(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> ATanH(
const vtkm::Vec<T, N>& x)
......@@ -896,17 +852,8 @@ static inline VTKM_EXEC_CONT vtkm::Float64 Pow(vtkm::Float64 x, vtkm::Float64 y)
/// Compute the square root of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Sqrt(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sqrt)(static_cast<vtkm::Float64>(x));
#else
return std::sqrt(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Sqrt(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 Sqrt(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(sqrt)(x);
......@@ -914,8 +861,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Sqrt(
return std::sqrt(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Sqrt(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 Sqrt(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(sqrt)(x);
......@@ -923,6 +870,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Sqrt(
return std::sqrt(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Sqrt(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::Sqrt(static_cast<RT>(x));
}
template <typename T, vtkm::IdComponent N>
static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<T>::Type, N> Sqrt(
const vtkm::Vec<T, N>& x)
......@@ -1026,17 +979,8 @@ static inline VTKM_EXEC_CONT vtkm::Vec<typename detail::FloatingPointReturnType<
/// Compute the cube root of \p x.
///
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Cbrt(T x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cbrt)(static_cast<vtkm::Float64>(x));
#else
return std::cbrt(static_cast<vtkm::Float64>(x));
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Cbrt(vtkm::Float32 x)
inline VTKM_EXEC_CONT vtkm::Float32 Cbrt(vtkm::Float32 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_32(cbrt)(x);
......@@ -1044,8 +988,8 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float32>::Type Cbrt(
return std::cbrt(x);
#endif
}
template <>
inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Cbrt(vtkm::Float64 x)
inline VTKM_EXEC_CONT vtkm::Float64 Cbrt(vtkm::Float64 x)
{
#ifdef VTKM_CUDA
return VTKM_CUDA_MATH_FUNCTION_64(cbrt)(x);
......@@ -1053,6 +997,12 @@ inline VTKM_EXEC_CONT detail::FloatingPointReturnType<vtkm::Float64>::Type Cbrt(
return std::cbrt(x);
#endif
}
template <typename T>
static inline VTKM_EXEC_CONT typename detail::FloatingPointReturnType<T>::Type Cbrt(const T& x)
{
using RT = typename detail::FloatingPointReturnType<T>::Type;
return vtkm::Cbrt(