Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions libcxx/include/complex
Original file line number Diff line number Diff line change
Expand Up @@ -1059,16 +1059,15 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> log10(const complex<_Tp>& __x) {

// sqrt

_LIBCPP_HIDE_FROM_ABI inline _Complex float __csqrt(_Complex float __v) { return __builtin_csqrtf(__v); }

_LIBCPP_HIDE_FROM_ABI inline _Complex double __csqrt(_Complex double __v) { return __builtin_csqrt(__v); }

_LIBCPP_HIDE_FROM_ABI inline _Complex long double __csqrt(_Complex long double __v) { return __builtin_csqrtl(__v); }

template <class _Tp>
_LIBCPP_HIDE_FROM_ABI complex<_Tp> sqrt(const complex<_Tp>& __x) {
if (std::isinf(__x.imag()))
return complex<_Tp>(_Tp(INFINITY), __x.imag());
if (std::isinf(__x.real())) {
if (__x.real() > _Tp(0))
return complex<_Tp>(__x.real(), std::isnan(__x.imag()) ? __x.imag() : std::copysign(_Tp(0), __x.imag()));
return complex<_Tp>(std::isnan(__x.imag()) ? __x.imag() : _Tp(0), std::copysign(__x.real(), __x.imag()));
}
return std::polar(std::sqrt(std::abs(__x)), std::arg(__x) / _Tp(2));
return complex<_Tp>(__from_builtin_tag(), std::__csqrt(__x.__builtin()));
}

// exp
Expand Down
Loading