aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/complex
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-03-20 11:40:34 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-05-14 11:43:05 +0000
commit349cc55c9796c4596a5b9904cd3281af295f878f (patch)
tree410c5a785075730a35f1272ca6a7adf72222ad03 /contrib/llvm-project/libcxx/include/complex
parentcb2ae6163174b90e999326ecec3699ee093a5d43 (diff)
parentc0981da47d5696fe36474fcf86b4ce03ae3ff818 (diff)
Merge llvm-project main llvmorg-14-init-10186-gff7f2cfa959b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-14-init-10186-gff7f2cfa959b. PR: 261742 MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/libcxx/include/complex')
-rw-r--r--contrib/llvm-project/libcxx/include/complex11
1 files changed, 6 insertions, 5 deletions
diff --git a/contrib/llvm-project/libcxx/include/complex b/contrib/llvm-project/libcxx/include/complex
index fc52697f7749..6b74435c6101 100644
--- a/contrib/llvm-project/libcxx/include/complex
+++ b/contrib/llvm-project/libcxx/include/complex
@@ -1,5 +1,5 @@
// -*- C++ -*-
-//===--------------------------- complex ----------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -1056,6 +1056,9 @@ complex<_Tp>
exp(const complex<_Tp>& __x)
{
_Tp __i = __x.imag();
+ if (__i == 0) {
+ return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag()));
+ }
if (__libcpp_isinf_or_builtin(__x.real()))
{
if (__x.real() < _Tp(0))
@@ -1070,8 +1073,6 @@ exp(const complex<_Tp>& __x)
return complex<_Tp>(__x.real(), __i);
}
}
- else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
- return __x;
_Tp __e = exp(__x.real());
return complex<_Tp>(__e * cos(__i), __e * sin(__i));
}
@@ -1269,8 +1270,8 @@ tanh(const complex<_Tp>& __x)
if (__libcpp_isinf_or_builtin(__x.real()))
{
if (!__libcpp_isfinite_or_builtin(__x.imag()))
- return complex<_Tp>(_Tp(1), _Tp(0));
- return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
+ return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0));
+ return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag())));
}
if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0)
return __x;