File indexing completed on 2025-01-18 10:00:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef __GSL_COMPLEX_H__
0022 #define __GSL_COMPLEX_H__
0023
0024 #undef __BEGIN_DECLS
0025 #undef __END_DECLS
0026 #ifdef __cplusplus
0027 # define __BEGIN_DECLS extern "C" {
0028 # define __END_DECLS }
0029 #else
0030 # define __BEGIN_DECLS
0031 # define __END_DECLS
0032 #endif
0033
0034 __BEGIN_DECLS
0035
0036
0037
0038 typedef double * gsl_complex_packed ;
0039 typedef float * gsl_complex_packed_float ;
0040 typedef long double * gsl_complex_packed_long_double ;
0041
0042 typedef const double * gsl_const_complex_packed ;
0043 typedef const float * gsl_const_complex_packed_float ;
0044 typedef const long double * gsl_const_complex_packed_long_double ;
0045
0046
0047
0048 typedef double * gsl_complex_packed_array ;
0049 typedef float * gsl_complex_packed_array_float ;
0050 typedef long double * gsl_complex_packed_array_long_double ;
0051
0052 typedef const double * gsl_const_complex_packed_array ;
0053 typedef const float * gsl_const_complex_packed_array_float ;
0054 typedef const long double * gsl_const_complex_packed_array_long_double ;
0055
0056
0057
0058
0059
0060
0061
0062 typedef double * gsl_complex_packed_ptr ;
0063 typedef float * gsl_complex_packed_float_ptr ;
0064 typedef long double * gsl_complex_packed_long_double_ptr ;
0065
0066 typedef const double * gsl_const_complex_packed_ptr ;
0067 typedef const float * gsl_const_complex_packed_float_ptr ;
0068 typedef const long double * gsl_const_complex_packed_long_double_ptr ;
0069
0070
0071
0072
0073
0074
0075
0076
0077 #if defined(__GNUC__) && (__GNUC__ < 7)
0078 # define GSL_COMPLEX_LEGACY 1
0079 #endif
0080
0081 #if !defined(GSL_COMPLEX_LEGACY) && \
0082 defined(_Complex_I) && \
0083 defined(complex) && \
0084 defined(I) && \
0085 defined(__STDC__) && (__STDC__ == 1) && \
0086 defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
0087
0088 # define GSL_COMPLEX_DEFINE(R, C) typedef R _Complex C ;
0089
0090 # define GSL_COMPLEX_P(zp) (&(zp))
0091 # define GSL_COMPLEX_EQ(z1,z2) ((z1) == (z2))
0092 # define GSL_SET_COMPLEX(zp,x,y) (*(zp) = (x) + I * (y))
0093
0094 # define GSL_REAL(z) (_Generic((z), \
0095 complex float : ((float *) &(z)), \
0096 complex double : ((double *) &(z)), \
0097 complex long double : ((long double *) &(z)))[0])
0098
0099 # define GSL_IMAG(z) (_Generic((z), \
0100 complex float : ((float *) &(z)), \
0101 complex double : ((double *) &(z)), \
0102 complex long double : ((long double *) &(z)))[1])
0103
0104 # define GSL_COMPLEX_P_REAL(zp) GSL_REAL(*(zp))
0105 # define GSL_COMPLEX_P_IMAG(zp) GSL_IMAG(*(zp))
0106 # define GSL_SET_REAL(zp,x) do { GSL_REAL(*(zp)) = (x); } while(0)
0107 # define GSL_SET_IMAG(zp,x) do { GSL_IMAG(*(zp)) = (x); } while(0)
0108
0109 #else
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121 # define GSL_COMPLEX_DEFINE(R, C) typedef struct { R dat[2]; } C ;
0122
0123 # define GSL_REAL(z) ((z).dat[0])
0124 # define GSL_IMAG(z) ((z).dat[1])
0125 # define GSL_COMPLEX_P(zp) ((zp)->dat)
0126 # define GSL_COMPLEX_P_REAL(zp) ((zp)->dat[0])
0127 # define GSL_COMPLEX_P_IMAG(zp) ((zp)->dat[1])
0128 # define GSL_COMPLEX_EQ(z1,z2) (((z1).dat[0] == (z2).dat[0]) && ((z1).dat[1] == (z2).dat[1]))
0129
0130 # define GSL_SET_COMPLEX(zp,x,y) do {(zp)->dat[0]=(x); (zp)->dat[1]=(y);} while(0)
0131 # define GSL_SET_REAL(zp,x) do {(zp)->dat[0]=(x);} while(0)
0132 # define GSL_SET_IMAG(zp,y) do {(zp)->dat[1]=(y);} while(0)
0133
0134 #endif
0135
0136 GSL_COMPLEX_DEFINE(double, gsl_complex)
0137 GSL_COMPLEX_DEFINE(long double, gsl_complex_long_double)
0138 GSL_COMPLEX_DEFINE(float, gsl_complex_float)
0139
0140 #define GSL_SET_COMPLEX_PACKED(zp,n,x,y) do {*((zp)+2*(n))=(x); *((zp)+(2*(n)+1))=(y);} while(0)
0141
0142 __END_DECLS
0143
0144 #endif