1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
13 // pow(const complex<T>& x, const T& y);
18 #include "test_macros.h"
23 test(const std::complex<T
>& a
, const T
& b
, std::complex<T
> x
)
25 std::complex<T
> c
= pow(a
, b
);
26 is_about(real(c
), real(x
));
27 is_about(imag(c
), imag(x
));
34 test(std::complex<T
>(2, 3), T(2), std::complex<T
>(-5, 12));
39 const unsigned N
= sizeof(testcases
) / sizeof(testcases
[0]);
40 for (unsigned i
= 0; i
< N
; ++i
)
42 for (unsigned j
= 0; j
< N
; ++j
)
44 std::complex<double> r
= pow(testcases
[i
], real(testcases
[j
]));
45 std::complex<double> z
= exp(std::complex<double>(real(testcases
[j
])) * log(testcases
[i
]));
46 if (std::isnan(real(r
)))
47 assert(std::isnan(real(z
)));
50 assert(real(r
) == real(z
));
52 if (std::isnan(imag(r
)))
53 assert(std::isnan(imag(z
)));
56 assert(imag(r
) == imag(z
));