]>
Commit | Line | Data |
---|---|---|
ecddf99e | 1 | // { dg-do run { xfail broken_cplxf_arg } } |
75d1ddc1 | 2 | |
83ffe9cd | 3 | // Copyright (C) 2004-2023 Free Software Foundation, Inc. |
52ddaf41 PK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
52ddaf41 PK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
52ddaf41 PK |
19 | |
20 | // 26.2.8 complex transcendentals | |
21 | ||
22 | #include <complex> | |
23 | #include <limits> | |
24 | #include <testsuite_hooks.h> | |
25 | ||
26 | template<typename T> | |
27 | void test01_do(T a, T b) | |
28 | { | |
29 | using namespace std; | |
52ddaf41 PK |
30 | typedef complex<T> cplx; |
31 | ||
c6feb697 | 32 | T eps = numeric_limits<T>::epsilon() * 100; |
52ddaf41 PK |
33 | |
34 | cplx ref = pow(cplx(a, T()), cplx(b, T())); | |
35 | cplx res1 = pow(a, cplx(b, T())); | |
36 | cplx res2 = pow(cplx(a, T()), b); | |
37 | ||
38 | VERIFY( abs(ref - res1) < eps ); | |
39 | VERIFY( abs(ref - res2) < eps ); | |
40 | VERIFY( abs(res1 - res2) < eps ); | |
41 | } | |
42 | ||
43 | // libstdc++/13450 | |
44 | void test01() | |
45 | { | |
46 | float f1 = -1.0f; | |
47 | float f2 = 0.5f; | |
48 | test01_do(f1, f2); | |
49 | ||
50 | f1 = -3.2f; | |
51 | f2 = 1.4f; | |
52 | test01_do(f1, f2); | |
53 | ||
54 | double d1 = -1.0; | |
55 | double d2 = 0.5; | |
56 | test01_do(d1, d2); | |
57 | ||
58 | d1 = -3.2; | |
59 | d2 = 1.4; | |
60 | test01_do(d1, d2); | |
61 | ||
30cc5540 JM |
62 | #if __LDBL_MANT_DIG__ != 106 |
63 | /* For IBM long double, epsilon is too small (since 1.0 plus any | |
64 | double is representable) to be able to expect results within | |
65 | epsilon * 100 (which may be much less than 1ulp for a particular | |
66 | long double value). */ | |
52ddaf41 PK |
67 | long double ld1 = -1.0l; |
68 | long double ld2 = 0.5l; | |
69 | test01_do(ld1, ld2); | |
70 | ||
71 | ld1 = -3.2l; | |
72 | ld2 = 1.4l; | |
73 | test01_do(ld1, ld2); | |
30cc5540 | 74 | #endif |
52ddaf41 PK |
75 | } |
76 | ||
77 | int main() | |
78 | { | |
79 | test01(); | |
80 | return 0; | |
81 | } |