00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __INFFT_H__
00023 #define __INFFT_H__
00024
00025 #include "config.h"
00026
00027 #include <math.h>
00028 #include <float.h>
00029
00030 #include <stdlib.h>
00031 #include <stdarg.h>
00032 #include <stddef.h>
00033
00034 #if HAVE_SYS_TYPES_H
00035 #include <sys/types.h>
00036 #endif
00037
00038 #if HAVE_STDINT_H
00039 #include <stdint.h>
00040 #endif
00041
00042 #if HAVE_INTTYPES_H
00043 #include <inttypes.h>
00044 #endif
00045
00046
00047 #define CONCAT(prefix, name) prefix ## name
00048 #if defined(NFFT_SINGLE)
00049 typedef float R;
00050 typedef float _Complex C;
00051 #define X(name) CONCAT(nfftf_, name)
00052 #elif defined(NFFT_LDOUBLE)
00053 typedef long double R;
00054 typedef long double _Complex C;
00055 #define X(name) CONCAT(nfftl_, name)
00056 #else
00057 typedef double R;
00058 typedef double _Complex C;
00059 #define X(name) CONCAT(nfft_, name)
00060 #endif
00061
00062 #ifdef NFFT_LDOUBLE
00063 # define K(x) ((R) x##L)
00064 #else
00065 # define K(x) ((R) x)
00066 #endif
00067 #define DK(name, value) const R name = K(value)
00068
00073 typedef ptrdiff_t INT;
00074
00075 #define IF(x,a,b) ((x)?(a):(b))
00076
00077 #define MIN(a,b) (((a)<(b))?(a):(b))
00078 #define MAX(a,b) (((a)>(b))?(a):(b))
00079 #define ABS(x) (((x)>K(0.0))?(x):(-(x)))
00080 #define SIGN(a) (((a)>=0)?1:-1)
00081
00082 #if defined(NFFT_LDOUBLE)
00083 #define LOG1P log1pl
00084 #if HAVE_DECL_LOG1PL == 0
00085 extern long double log1pl(const long double);
00086 #endif
00087 #define SQRT sqrtl
00088 #if HAVE_DECL_SQRTL == 0
00089 extern long double sqrtl(const long double);
00090 #endif
00091 #define TGAMMA tgammal
00092 #if HAVE_DECL_TGAMMAL == 0
00093 extern long double tgammal(const long double);
00094 #endif
00095 #define LGAMMA lgammal
00096 #if HAVE_DECL_LGAMMAL == 0
00097 extern long double lgammal(const long double);
00098 #endif
00099 #define LOG logl
00100 #if HAVE_DECL_LOGL == 0
00101 extern long double logl(const long double);
00102 #endif
00103 #define LOG2 log2l
00104 #if HAVE_DECL_LOG2L == 0
00105 extern long double log2l(const long double);
00106 #endif
00107 #define SIN sinl
00108 #if HAVE_DECL_SINL == 0
00109 extern long double sinl(const long double);
00110 #endif
00111 #define COS cosl
00112 #if HAVE_DECL_COSL == 0
00113 extern long double cosl(const long double);
00114 #endif
00115 #define ACOS acosl
00116 #if HAVE_DECL_ACOSL == 0
00117 extern long double acosl(const long double);
00118 #endif
00119 #define POW powl
00120 #if HAVE_DECL_POWL == 0
00121 extern long double powl(const long double, const long double);
00122 #endif
00123 #define EXP expl
00124 #if HAVE_DECL_EXPL == 0
00125 extern long double expl(const long double);
00126 #endif
00127 #define COPYSIGN copysignl
00128 #if HAVE_DECL_COPYSIGNL == 0
00129 extern long double copysignl(const long double, const long double);
00130 #endif
00131 #define LRINT lrintl
00132 #if HAVE_DECL_LRINTL == 0
00133 extern long int lrintl(const long double);
00134 #endif
00135 #elif defined(NFFT_SINGLE)
00136 #define LOG1P log1pf
00137 #if HAVE_DECL_LOG1PF == 0
00138 extern float log1pf(const float);
00139 #endif
00140 #define SQRT sqrtf
00141 #if HAVE_DECL_SQRTF == 0
00142 extern float sqrtf(const float);
00143 #endif
00144 #define >TGAMMA tgammaf
00145 #if HAVE_DECL_TGAMMAF == 0
00146 extern float tgammaf(const float);
00147 #endif
00148 #define LGAMMA lgammaf
00149 #if HAVE_DECL_LGAMMAF == 0
00150 extern float lgammaf(const float);
00151 #endif
00152 #define LOG logf
00153 #if HAVE_DECL_LOGF == 0
00154 extern float logf(const float);
00155 #endif
00156 #define LOG2 log2f
00157 #if HAVE_DECL_LOG2F == 0
00158 extern float log2f(const float);
00159 #endif
00160 #define SIN sinf
00161 #if HAVE_DECL_SINF == 0
00162 extern float sinf(const float);
00163 #endif
00164 #define COS cosf
00165 #if HAVE_DECL_COSF == 0
00166 extern float cosf(const float);
00167 #endif
00168 #define ACOS acosf
00169 #if HAVE_DECL_ACOSF == 0
00170 extern float acosf(const float);
00171 #endif
00172 #define POW powf
00173 #if HAVE_DECL_POWF == 0
00174 extern float powf(const float, const float);
00175 #endif
00176 #define EXP expf
00177 #if HAVE_DECL_EXPF == 0
00178 extern float expf(const float);
00179 #endif
00180 #define COPYSIGN copysignf
00181 #if HAVE_DECL_COPYSIGNF == 0
00182 extern float copysignf(const float, const float);
00183 #endif
00184 #define LRINT lrintf
00185 #if HAVE_DECL_LRINTF == 0
00186 extern long int lrintf(const float);
00187 #endif
00188 #else
00189 #define LOG1P log1p
00190 #if HAVE_DECL_LOG1P == 0
00191 extern double log1p(const double);
00192 #endif
00193 #define SQRT sqrt
00194 #if HAVE_DECL_SQRT == 0
00195 extern double sqrt(const double);
00196 #endif
00197 #define TGAMMA tgamma
00198 #if HAVE_DECL_TGAMMA == 0
00199 extern double tgamma(const double);
00200 #endif
00201 #define LGAMMA lgamma
00202 #if HAVE_DECL_LGAMMA == 0
00203 extern double lgamma(const double);
00204 #endif
00205 #define LOG log
00206 #if HAVE_DECL_LOG == 0
00207 extern double log(const double);
00208 #endif
00209 #define LOG2 log2
00210 #if HAVE_DECL_LOG2 == 0
00211 extern double log2(const double);
00212 #endif
00213 #define SIN sin
00214 #if HAVE_DECL_SIN == 0
00215 extern double sin(const double);
00216 #endif
00217 #define COS cos
00218 #if HAVE_DECL_COS == 0
00219 extern double cos(const double);
00220 #endif
00221 #define ACOS acos
00222 #if HAVE_DECL_ACOS == 0
00223 extern double acos(const double);
00224 #endif
00225 #define POW pow
00226 #if HAVE_DECL_POW == 0
00227 extern double pow(const double, const double);
00228 #endif
00229 #define EXP exp
00230 #if HAVE_DECL_EXP == 0
00231 extern double exp(const double);
00232 #endif
00233 #define COPYSIGN copysign
00234 #if HAVE_DECL_COPYSIGN == 0
00235 extern double copysign(const double, const double);
00236 #endif
00237 #define LRINT lrint
00238 #if HAVE_DECL_LRINT == 0
00239 extern long int lrint(const double);
00240 #endif
00241 #endif
00242
00243 #if defined(NFFT_LDOUBLE)
00244 # define CEIL ceill
00245 # define FLOOR floorl
00246 # define ROUND roundl
00247 # define FABS fabsl
00248 # define FMAX fmaxl
00249 # define FMIN fminl
00250 # define FREXP frexpl
00251 # define LDEXP ldexpl
00252 # define EPS LDBL_EPSILON
00253 # define R_MIN LDBL_MIN
00254 # define R_MAX LDBL_MAX
00255 # define R_MIN_EXP LDBL_MIN_EXP
00256 # define R_MAX_EXP LDBL_MAX_EXP
00257 # define R_MIN_10_EXP LDBL_MIN_10_EXP
00258 # define R_MAX_10_EXP LDBL_MAX_10_EXP
00259 # define R_DIG LDBL_DIG
00260 # define CREAL creall
00261 # define CIMAG cimagl
00262 #elif defined(NFFT_SINGLE)
00263 # define CEIL ceilf
00264 # define FLOOR floorf
00265 # define ROUND roundf
00266 # define FABS fabsf
00267 # define FMAX fmaxf
00268 # define FMIN fminf
00269 # define FREXP frexpf
00270 # define LDEXP ldexpf
00271 # define EPS FLT_EPSILON
00272 # define R_MIN FLT_MIN
00273 # define R_MAX FLT_MAX
00274 # define R_MIN_EXP FLT_MIN_EXP
00275 # define R_MAX_EXP FLT_MAX_EXP
00276 # define R_MIN_10_EXP FLT_MIN_10_EXP
00277 # define R_MAX_10_EXP FLT_MAX_10_EXP
00278 # define R_DIG FLT_DIG
00279 # define CREAL crealf
00280 # define CIMAG cimagf
00281 #else
00282 # define CEIL ceil
00283 # define FLOOR floor
00284 # define ROUND round
00285 # define FABS fabs
00286 # define FMAX fmax
00287 # define FMIN fmin
00288 # define FREXP frexp
00289 # define LDEXP ldexp
00290 # define EPS DBL_EPSILON
00291 # define R_MIN DBL_MIN
00292 # define R_MAX DBL_MAX
00293 # define R_MIN_EXP DBL_MIN_EXP
00294 # define R_MAX_EXP DBL_MAX_EXP
00295 # define R_MAX_10_EXP DBL_MAX_10_EXP
00296 # define R_MIN_10_EXP DBL_MIN_10_EXP
00297 # define R_DIG DBL_DIG
00298 # define CREAL creal
00299 # define CIMAG cimag
00300 #endif
00301
00302 #if HAVE_DECL_DRAND48 == 0
00303 extern double drand48(void);
00304 #endif
00305 #if HAVE_DECL_SRAND48 == 0
00306 extern void srand48(long int);
00307 #endif
00308 #define RAND ((R)drand48())
00309 #define R_RADIX FLT_RADIX
00310 #define II _Complex_I
00311
00312
00313 #if defined(NFFT_LDOUBLE)
00314 # define FE "LE"
00315 #elif defined(NFFT_SINGLE)
00316 # define FE "E"
00317 #else
00318 # define FE "lE"
00319 #endif
00320
00321 #define TRUE 1
00322 #define FALSE 0
00323
00325 #define UNUSED(x) (void)x
00326
00327 #endif