summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/complex
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libc++/include/complex')
-rw-r--r--contrib/libc++/include/complex381
1 files changed, 146 insertions, 235 deletions
diff --git a/contrib/libc++/include/complex b/contrib/libc++/include/complex
index f56138f..d41971b 100644
--- a/contrib/libc++/include/complex
+++ b/contrib/libc++/include/complex
@@ -245,9 +245,6 @@ template<class T, class charT, class traits>
#include <stdexcept>
#include <cmath>
#include <sstream>
-#if defined(_LIBCPP_NO_EXCEPTIONS)
- #include <cassert>
-#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -255,13 +252,13 @@ template<class T, class charT, class traits>
_LIBCPP_BEGIN_NAMESPACE_STD
-template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY complex;
+template<class _Tp> class _LIBCPP_TEMPLATE_VIS complex;
template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
template<class _Tp>
-class _LIBCPP_TYPE_VIS_ONLY complex
+class _LIBCPP_TEMPLATE_VIS complex
{
public:
typedef _Tp value_type;
@@ -319,11 +316,11 @@ public:
}
};
-template<> class _LIBCPP_TYPE_VIS_ONLY complex<double>;
-template<> class _LIBCPP_TYPE_VIS_ONLY complex<long double>;
+template<> class _LIBCPP_TEMPLATE_VIS complex<double>;
+template<> class _LIBCPP_TEMPLATE_VIS complex<long double>;
template<>
-class _LIBCPP_TYPE_VIS_ONLY complex<float>
+class _LIBCPP_TEMPLATE_VIS complex<float>
{
float __re_;
float __im_;
@@ -381,7 +378,7 @@ public:
};
template<>
-class _LIBCPP_TYPE_VIS_ONLY complex<double>
+class _LIBCPP_TEMPLATE_VIS complex<double>
{
double __re_;
double __im_;
@@ -439,7 +436,7 @@ public:
};
template<>
-class _LIBCPP_TYPE_VIS_ONLY complex<long double>
+class _LIBCPP_TEMPLATE_VIS complex<long double>
{
long double __re_;
long double __im_;
@@ -602,39 +599,39 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __bc = __b * __c;
_Tp __x = __ac - __bd;
_Tp __y = __ad + __bc;
- if (isnan(__x) && isnan(__y))
+ if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
{
bool __recalc = false;
- if (isinf(__a) || isinf(__b))
+ if (__libcpp_isinf(__a) || __libcpp_isinf(__b))
{
- __a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
- if (isnan(__c))
+ __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ if (__libcpp_isnan(__c))
__c = copysign(_Tp(0), __c);
- if (isnan(__d))
+ if (__libcpp_isnan(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
- if (isinf(__c) || isinf(__d))
+ if (__libcpp_isinf(__c) || __libcpp_isinf(__d))
{
- __c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
- if (isnan(__a))
+ __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ if (__libcpp_isnan(__a))
__a = copysign(_Tp(0), __a);
- if (isnan(__b))
+ if (__libcpp_isnan(__b))
__b = copysign(_Tp(0), __b);
__recalc = true;
}
- if (!__recalc && (isinf(__ac) || isinf(__bd) ||
- isinf(__ad) || isinf(__bc)))
+ if (!__recalc && (__libcpp_isinf(__ac) || __libcpp_isinf(__bd) ||
+ __libcpp_isinf(__ad) || __libcpp_isinf(__bc)))
{
- if (isnan(__a))
+ if (__libcpp_isnan(__a))
__a = copysign(_Tp(0), __a);
- if (isnan(__b))
+ if (__libcpp_isnan(__b))
__b = copysign(_Tp(0), __b);
- if (isnan(__c))
+ if (__libcpp_isnan(__c))
__c = copysign(_Tp(0), __c);
- if (isnan(__d))
+ if (__libcpp_isnan(__d))
__d = copysign(_Tp(0), __d);
__recalc = true;
}
@@ -677,7 +674,7 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __c = __w.real();
_Tp __d = __w.imag();
_Tp __logbw = logb(fmax(fabs(__c), fabs(__d)));
- if (isfinite(__logbw))
+ if (__libcpp_isfinite(__logbw))
{
__ilogbw = static_cast<int>(__logbw);
__c = scalbn(__c, -__ilogbw);
@@ -686,24 +683,24 @@ operator/(const complex<_Tp>& __z, const complex<_Tp>& __w)
_Tp __denom = __c * __c + __d * __d;
_Tp __x = scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
_Tp __y = scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
- if (isnan(__x) && isnan(__y))
+ if (__libcpp_isnan(__x) && __libcpp_isnan(__y))
{
- if ((__denom == _Tp(0)) && (!isnan(__a) || !isnan(__b)))
+ if ((__denom == _Tp(0)) && (!__libcpp_isnan(__a) || !__libcpp_isnan(__b)))
{
__x = copysign(_Tp(INFINITY), __c) * __a;
__y = copysign(_Tp(INFINITY), __c) * __b;
}
- else if ((isinf(__a) || isinf(__b)) && isfinite(__c) && isfinite(__d))
+ else if ((__libcpp_isinf(__a) || __libcpp_isinf(__b)) && __libcpp_isfinite(__c) && __libcpp_isfinite(__d))
{
- __a = copysign(isinf(__a) ? _Tp(1) : _Tp(0), __a);
- __b = copysign(isinf(__b) ? _Tp(1) : _Tp(0), __b);
+ __a = copysign(__libcpp_isinf(__a) ? _Tp(1) : _Tp(0), __a);
+ __b = copysign(__libcpp_isinf(__b) ? _Tp(1) : _Tp(0), __b);
__x = _Tp(INFINITY) * (__a * __c + __b * __d);
__y = _Tp(INFINITY) * (__b * __c - __a * __d);
}
- else if (isinf(__logbw) && __logbw > _Tp(0) && isfinite(__a) && isfinite(__b))
+ else if (__libcpp_isinf(__logbw) && __logbw > _Tp(0) && __libcpp_isfinite(__a) && __libcpp_isfinite(__b))
{
- __c = copysign(isinf(__c) ? _Tp(1) : _Tp(0), __c);
- __d = copysign(isinf(__d) ? _Tp(1) : _Tp(0), __d);
+ __c = copysign(__libcpp_isinf(__c) ? _Tp(1) : _Tp(0), __c);
+ __d = copysign(__libcpp_isinf(__d) ? _Tp(1) : _Tp(0), __d);
__x = _Tp(0) * (__a * __c + __b * __d);
__y = _Tp(0) * (__b * __c - __a * __d);
}
@@ -795,45 +792,41 @@ operator!=(const _Tp& __x, const complex<_Tp>& __y)
// 26.3.7 values:
-// real
+template <class _Tp, bool = is_integral<_Tp>::value,
+ bool = is_floating_point<_Tp>::value
+ >
+struct __libcpp_complex_overload_traits {};
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_Tp
-real(const complex<_Tp>& __c)
+// Integral Types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, true, false>
{
- return __c.real();
-}
+ typedef double _ValueType;
+ typedef complex<double> _ComplexType;
+};
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-long double
-real(long double __re)
+// Floating point types
+template <class _Tp>
+struct __libcpp_complex_overload_traits<_Tp, false, true>
{
- return __re;
-}
+ typedef _Tp _ValueType;
+ typedef complex<_Tp> _ComplexType;
+};
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-double
-real(double __re)
-{
- return __re;
-}
+// real
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
-real(_Tp __re)
+_Tp
+real(const complex<_Tp>& __c)
{
- return __re;
+ return __c.real();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-float
-real(float __re)
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+real(_Tp __re)
{
return __re;
}
@@ -848,35 +841,10 @@ imag(const complex<_Tp>& __c)
return __c.imag();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-long double
-imag(long double __re)
-{
- return 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-double
-imag(double __re)
-{
- return 0;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
-imag(_Tp __re)
-{
- return 0;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-float
-imag(float __re)
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
+imag(_Tp)
{
return 0;
}
@@ -901,25 +869,22 @@ arg(const complex<_Tp>& __c)
return atan2(__c.imag(), __c.real());
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-long double
-arg(long double __re)
+typename enable_if<
+ is_same<_Tp, long double>::value,
+ long double
+>::type
+arg(_Tp __re)
{
return atan2l(0.L, __re);
}
-inline _LIBCPP_INLINE_VISIBILITY
-double
-arg(double __re)
-{
- return atan2(0., __re);
-}
-
template<class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
- is_integral<_Tp>::value,
+ is_integral<_Tp>::value || is_same<_Tp, double>::value,
double
>::type
arg(_Tp __re)
@@ -927,9 +892,13 @@ arg(_Tp __re)
return atan2(0., __re);
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-float
-arg(float __re)
+typename enable_if<
+ is_same<_Tp, float>::value,
+ float
+>::type
+arg(_Tp __re)
{
return atan2f(0.F, __re);
}
@@ -941,44 +910,20 @@ inline _LIBCPP_INLINE_VISIBILITY
_Tp
norm(const complex<_Tp>& __c)
{
- if (isinf(__c.real()))
+ if (__libcpp_isinf(__c.real()))
return abs(__c.real());
- if (isinf(__c.imag()))
+ if (__libcpp_isinf(__c.imag()))
return abs(__c.imag());
return __c.real() * __c.real() + __c.imag() * __c.imag();
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-long double
-norm(long double __re)
-{
- return __re * __re;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-double
-norm(double __re)
-{
- return __re * __re;
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_integral<_Tp>::value,
- double
->::type
+typename __libcpp_complex_overload_traits<_Tp>::_ValueType
norm(_Tp __re)
{
- return (double)__re * __re;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-float
-norm(float __re)
-{
- return __re * __re;
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ValueType _ValueType;
+ return static_cast<_ValueType>(__re) * __re;
}
// conj
@@ -991,38 +936,16 @@ conj(const complex<_Tp>& __c)
return complex<_Tp>(__c.real(), -__c.imag());
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-complex<long double>
-conj(long double __re)
-{
- return complex<long double>(__re);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-complex<double>
-conj(double __re)
-{
- return complex<double>(__re);
-}
-
-template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_integral<_Tp>::value,
- complex<double>
->::type
+typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
conj(_Tp __re)
{
- return complex<double>(__re);
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
}
-inline _LIBCPP_INLINE_VISIBILITY
-complex<float>
-conj(float __re)
-{
- return complex<float>(__re);
-}
+
// proj
@@ -1032,48 +955,36 @@ complex<_Tp>
proj(const complex<_Tp>& __c)
{
std::complex<_Tp> __r = __c;
- if (isinf(__c.real()) || isinf(__c.imag()))
+ if (__libcpp_isinf(__c.real()) || __libcpp_isinf(__c.imag()))
__r = complex<_Tp>(INFINITY, copysign(_Tp(0), __c.imag()));
return __r;
}
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-complex<long double>
-proj(long double __re)
-{
- if (isinf(__re))
- __re = abs(__re);
- return complex<long double>(__re);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-complex<double>
-proj(double __re)
+typename enable_if
+<
+ is_floating_point<_Tp>::value,
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
+>::type
+proj(_Tp __re)
{
- if (isinf(__re))
+ if (__libcpp_isinf(__re))
__re = abs(__re);
- return complex<double>(__re);
+ return complex<_Tp>(__re);
}
-template<class _Tp>
+template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value,
- complex<double>
+ typename __libcpp_complex_overload_traits<_Tp>::_ComplexType
>::type
proj(_Tp __re)
{
- return complex<double>(__re);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-complex<float>
-proj(float __re)
-{
- if (isinf(__re))
- __re = abs(__re);
- return complex<float>(__re);
+ typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType;
+ return _ComplexType(__re);
}
// polar
@@ -1082,25 +993,25 @@ template<class _Tp>
complex<_Tp>
polar(const _Tp& __rho, const _Tp& __theta = _Tp(0))
{
- if (isnan(__rho) || signbit(__rho))
+ if (__libcpp_isnan(__rho) || signbit(__rho))
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
- if (isnan(__theta))
+ if (__libcpp_isnan(__theta))
{
- if (isinf(__rho))
+ if (__libcpp_isinf(__rho))
return complex<_Tp>(__rho, __theta);
return complex<_Tp>(__theta, __theta);
}
- if (isinf(__theta))
+ if (__libcpp_isinf(__theta))
{
- if (isinf(__rho))
+ if (__libcpp_isinf(__rho))
return complex<_Tp>(__rho, _Tp(NAN));
return complex<_Tp>(_Tp(NAN), _Tp(NAN));
}
_Tp __x = __rho * cos(__theta);
- if (isnan(__x))
+ if (__libcpp_isnan(__x))
__x = 0;
_Tp __y = __rho * sin(__theta);
- if (isnan(__y))
+ if (__libcpp_isnan(__y))
__y = 0;
return complex<_Tp>(__x, __y);
}
@@ -1131,13 +1042,13 @@ template<class _Tp>
complex<_Tp>
sqrt(const complex<_Tp>& __x)
{
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
if (__x.real() > _Tp(0))
- return complex<_Tp>(__x.real(), isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
- return complex<_Tp>(isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
+ return complex<_Tp>(__x.real(), __libcpp_isnan(__x.imag()) ? __x.imag() : copysign(_Tp(0), __x.imag()));
+ return complex<_Tp>(__libcpp_isnan(__x.imag()) ? __x.imag() : _Tp(0), copysign(__x.real(), __x.imag()));
}
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
}
@@ -1149,21 +1060,21 @@ complex<_Tp>
exp(const complex<_Tp>& __x)
{
_Tp __i = __x.imag();
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
if (__x.real() < _Tp(0))
{
- if (!isfinite(__i))
+ if (!__libcpp_isfinite(__i))
__i = _Tp(1);
}
- else if (__i == 0 || !isfinite(__i))
+ else if (__i == 0 || !__libcpp_isfinite(__i))
{
- if (isinf(__i))
+ if (__libcpp_isinf(__i))
__i = _Tp(NAN);
return complex<_Tp>(__x.real(), __i);
}
}
- else if (isnan(__x.real()) && __x.imag() == 0)
+ else if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
return __x;
_Tp __e = exp(__x.real());
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
@@ -1221,23 +1132,23 @@ complex<_Tp>
asinh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
- if (isnan(__x.imag()))
+ if (__libcpp_isnan(__x.imag()))
return __x;
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (isnan(__x.real()))
+ if (__libcpp_isnan(__x.real()))
{
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
if (__x.imag() == 0)
return __x;
return complex<_Tp>(__x.real(), __x.real());
}
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(copysign(__x.imag(), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) + _Tp(1)));
return complex<_Tp>(copysign(__z.real(), __x.real()), copysign(__z.imag(), __x.imag()));
@@ -1250,11 +1161,11 @@ complex<_Tp>
acosh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
- if (isnan(__x.imag()))
+ if (__libcpp_isnan(__x.imag()))
return complex<_Tp>(abs(__x.real()), __x.imag());
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
{
if (__x.real() > 0)
return complex<_Tp>(__x.real(), copysign(__pi * _Tp(0.25), __x.imag()));
@@ -1265,13 +1176,13 @@ acosh(const complex<_Tp>& __x)
return complex<_Tp>(-__x.real(), copysign(__pi, __x.imag()));
return complex<_Tp>(__x.real(), copysign(_Tp(0), __x.imag()));
}
- if (isnan(__x.real()))
+ if (__libcpp_isnan(__x.real()))
{
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(abs(__x.imag()), __x.real());
return complex<_Tp>(__x.real(), __x.real());
}
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(abs(__x.imag()), copysign(__pi/_Tp(2), __x.imag()));
complex<_Tp> __z = log(__x + sqrt(pow(__x, _Tp(2)) - _Tp(1)));
return complex<_Tp>(copysign(__z.real(), _Tp(0)), copysign(__z.imag(), __x.imag()));
@@ -1284,21 +1195,21 @@ complex<_Tp>
atanh(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
- if (isnan(__x.imag()))
+ if (__libcpp_isnan(__x.imag()))
{
- if (isinf(__x.real()) || __x.real() == 0)
+ if (__libcpp_isinf(__x.real()) || __x.real() == 0)
return complex<_Tp>(copysign(_Tp(0), __x.real()), __x.imag());
return complex<_Tp>(__x.imag(), __x.imag());
}
- if (isnan(__x.real()))
+ if (__libcpp_isnan(__x.real()))
{
return complex<_Tp>(__x.real(), __x.real());
}
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
return complex<_Tp>(copysign(_Tp(0), __x.real()), copysign(__pi/_Tp(2), __x.imag()));
}
@@ -1316,11 +1227,11 @@ template<class _Tp>
complex<_Tp>
sinh(const complex<_Tp>& __x)
{
- if (isinf(__x.real()) && !isfinite(__x.imag()))
+ if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.real() == 0 && !isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(__x.real(), _Tp(NAN));
- if (__x.imag() == 0 && !isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
return __x;
return complex<_Tp>(sinh(__x.real()) * cos(__x.imag()), cosh(__x.real()) * sin(__x.imag()));
}
@@ -1331,13 +1242,13 @@ template<class _Tp>
complex<_Tp>
cosh(const complex<_Tp>& __x)
{
- if (isinf(__x.real()) && !isfinite(__x.imag()))
+ if (__libcpp_isinf(__x.real()) && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(abs(__x.real()), _Tp(NAN));
- if (__x.real() == 0 && !isfinite(__x.imag()))
+ if (__x.real() == 0 && !__libcpp_isfinite(__x.imag()))
return complex<_Tp>(_Tp(NAN), __x.real());
if (__x.real() == 0 && __x.imag() == 0)
return complex<_Tp>(_Tp(1), __x.imag());
- if (__x.imag() == 0 && !isfinite(__x.real()))
+ if (__x.imag() == 0 && !__libcpp_isfinite(__x.real()))
return complex<_Tp>(abs(__x.real()), __x.imag());
return complex<_Tp>(cosh(__x.real()) * cos(__x.imag()), sinh(__x.real()) * sin(__x.imag()));
}
@@ -1348,19 +1259,19 @@ template<class _Tp>
complex<_Tp>
tanh(const complex<_Tp>& __x)
{
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
- if (!isfinite(__x.imag()))
+ if (!__libcpp_isfinite(__x.imag()))
return complex<_Tp>(_Tp(1), _Tp(0));
return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
}
- if (isnan(__x.real()) && __x.imag() == 0)
+ if (__libcpp_isnan(__x.real()) && __x.imag() == 0)
return __x;
_Tp __2r(_Tp(2) * __x.real());
_Tp __2i(_Tp(2) * __x.imag());
_Tp __d(cosh(__2r) + cos(__2i));
_Tp __2rsh(sinh(__2r));
- if (isinf(__2rsh) && isinf(__d))
+ if (__libcpp_isinf(__2rsh) && __libcpp_isinf(__d))
return complex<_Tp>(__2rsh > _Tp(0) ? _Tp(1) : _Tp(-1),
__2i > _Tp(0) ? _Tp(0) : _Tp(-0.));
return complex<_Tp>(__2rsh/__d, sin(__2i)/__d);
@@ -1383,11 +1294,11 @@ complex<_Tp>
acos(const complex<_Tp>& __x)
{
const _Tp __pi(atan2(+0., -0.));
- if (isinf(__x.real()))
+ if (__libcpp_isinf(__x.real()))
{
- if (isnan(__x.imag()))
+ if (__libcpp_isnan(__x.imag()))
return complex<_Tp>(__x.imag(), __x.real());
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
{
if (__x.real() < _Tp(0))
return complex<_Tp>(_Tp(0.75) * __pi, -__x.imag());
@@ -1397,13 +1308,13 @@ acos(const complex<_Tp>& __x)
return complex<_Tp>(__pi, signbit(__x.imag()) ? -__x.real() : __x.real());
return complex<_Tp>(_Tp(0), signbit(__x.imag()) ? __x.real() : -__x.real());
}
- if (isnan(__x.real()))
+ if (__libcpp_isnan(__x.real()))
{
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__x.real(), -__x.imag());
return complex<_Tp>(__x.real(), __x.real());
}
- if (isinf(__x.imag()))
+ if (__libcpp_isinf(__x.imag()))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
if (__x.real() == 0 && (__x.imag() == 0 || isnan(__x.imag())))
return complex<_Tp>(__pi/_Tp(2), -__x.imag());
OpenPOWER on IntegriCloud