OLD | NEW |
1 #ifndef _COMPLEX_H | 1 #ifndef _COMPLEX_H |
2 #define _COMPLEX_H | 2 #define _COMPLEX_H |
3 | 3 |
4 #ifdef __cplusplus | 4 #ifdef __cplusplus |
5 extern "C" { | 5 extern "C" { |
6 #endif | 6 #endif |
7 | 7 |
8 #define complex _Complex | 8 #define complex _Complex |
9 #ifdef __GNUC__ | 9 #ifdef __GNUC__ |
10 #define _Complex_I (__extension__ (0.0f+1.0fi)) | 10 #define _Complex_I (__extension__(0.0f + 1.0fi)) |
11 #else | 11 #else |
12 #define _Complex_I (0.0f+1.0fi) | 12 #define _Complex_I (0.0f + 1.0fi) |
13 #endif | 13 #endif |
14 #define I _Complex_I | 14 #define I _Complex_I |
15 | 15 |
16 double complex cacos(double complex); | 16 double complex cacos(double complex); |
17 float complex cacosf(float complex); | 17 float complex cacosf(float complex); |
18 long double complex cacosl(long double complex); | 18 long double complex cacosl(long double complex); |
19 | 19 |
20 double complex casin(double complex); | 20 double complex casin(double complex); |
21 float complex casinf(float complex); | 21 float complex casinf(float complex); |
22 long double complex casinl(long double complex); | 22 long double complex casinl(long double complex); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 double complex cproj(double complex); | 96 double complex cproj(double complex); |
97 float complex cprojf(float complex); | 97 float complex cprojf(float complex); |
98 long double complex cprojl(long double complex); | 98 long double complex cprojl(long double complex); |
99 | 99 |
100 double creal(double complex); | 100 double creal(double complex); |
101 float crealf(float complex); | 101 float crealf(float complex); |
102 long double creall(long double complex); | 102 long double creall(long double complex); |
103 | 103 |
104 #ifndef __cplusplus | 104 #ifndef __cplusplus |
105 #define __CIMAG(x, t) \ | 105 #define __CIMAG(x, t) \ |
106 » (+(union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1]) | 106 (+(union { \ |
| 107 _Complex t __z; \ |
| 108 t __xy[2]; \ |
| 109 }){(_Complex t)(x)} \ |
| 110 .__xy[1]) |
107 | 111 |
108 #define creal(x) ((double)(x)) | 112 #define creal(x) ((double)(x)) |
109 #define crealf(x) ((float)(x)) | 113 #define crealf(x) ((float)(x)) |
110 #define creall(x) ((long double)(x)) | 114 #define creall(x) ((long double)(x)) |
111 | 115 |
112 #define cimag(x) __CIMAG(x, double) | 116 #define cimag(x) __CIMAG(x, double) |
113 #define cimagf(x) __CIMAG(x, float) | 117 #define cimagf(x) __CIMAG(x, float) |
114 #define cimagl(x) __CIMAG(x, long double) | 118 #define cimagl(x) __CIMAG(x, long double) |
115 #endif | 119 #endif |
116 | 120 |
117 #if __STDC_VERSION__ >= 201112L | 121 #if __STDC_VERSION__ >= 201112L |
118 #if defined(_Imaginary_I) | 122 #if defined(_Imaginary_I) |
119 #define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I*(t)(y)) | 123 #define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I * (t)(y)) |
120 #elif defined(__clang__) | 124 #elif defined(__clang__) |
121 #define __CMPLX(x, y, t) (+(_Complex t){ (t)(x), (t)(y) }) | 125 #define __CMPLX(x, y, t) (+(_Complex t){(t)(x), (t)(y)}) |
122 #else | 126 #else |
123 #define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y))) | 127 #define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y))) |
124 #endif | 128 #endif |
125 #define CMPLX(x, y) __CMPLX(x, y, double) | 129 #define CMPLX(x, y) __CMPLX(x, y, double) |
126 #define CMPLXF(x, y) __CMPLX(x, y, float) | 130 #define CMPLXF(x, y) __CMPLX(x, y, float) |
127 #define CMPLXL(x, y) __CMPLX(x, y, long double) | 131 #define CMPLXL(x, y) __CMPLX(x, y, long double) |
128 #endif | 132 #endif |
129 | 133 |
130 #ifdef __cplusplus | 134 #ifdef __cplusplus |
131 } | 135 } |
132 #endif | 136 #endif |
133 #endif | 137 #endif |
OLD | NEW |