base/include/rtai_math.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
#ifndef _RTAI_MATH_H
00027 #define _RTAI_MATH_H 1
00028 #define _MATH_H 1
00029
00030
#include <rtai_types.h>
00031
#include <features.h>
00032
00033 __BEGIN_DECLS
00034
00035
00036
00037
#include <bits/huge_val.h>
00038
00039
00040
#ifdef __USE_ISOC99
00041
# include <bits/nan.h>
00042
#endif
00043
00044
#include <bits/mathdef.h>
00045
00046
00047
00048
00049
00050
00051
00052 #define __MATHCALL(function,suffix, args) \
00053
__MATHDECL (_Mdouble_,function,suffix, args)
00054 #define __MATHDECL(type, function,suffix, args) \
00055
__MATHDECL_1(type, function,suffix, args); \
00056
__MATHDECL_1(type, __CONCAT(__,function),suffix, args)
00057 #define __MATHCALLX(function,suffix, args, attrib) \
00058
__MATHDECLX (_Mdouble_,function,suffix, args, attrib)
00059 #define __MATHDECLX(type, function,suffix, args, attrib) \
00060
__MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
00061
__MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
00062 #define __MATHDECL_1(type, function,suffix, args) \
00063
extern type __MATH_PRECNAME(function,suffix) args __THROW
00064
00065 #define _Mdouble_ double
00066 #define __MATH_PRECNAME(name,r) __CONCAT(name,r)
00067
00068 #define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_STD
00069 #define _Mdouble_END_NAMESPACE __END_NAMESPACE_STD
00070
00071
#include <bits/mathcalls.h>
00072
#undef _Mdouble_
00073
00074
#undef _Mdouble_BEGIN_NAMESPACE
00075
#undef _Mdouble_END_NAMESPACE
00076
00077
#undef __MATH_PRECNAME
00078
00079
#if defined __USE_MISC || defined __USE_ISOC99
00080
00081
00082
00083
00084
00085
# ifndef _Mfloat_
00086
# define _Mfloat_ float
00087
# endif
00088
# define _Mdouble_ _Mfloat_
00089
# ifdef __STDC__
00090
# define __MATH_PRECNAME(name,r) name##f##r
00091
# else
00092
# define __MATH_PRECNAME(name,r) namefr
00093
# endif
00094
00095
#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
00096
#define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
00097
00098
# include <bits/mathcalls.h>
00099
# undef _Mdouble_
00100
00101
# undef _Mdouble_BEGIN_NAMESPACE
00102
# undef _Mdouble_END_NAMESPACE
00103
00104
# undef __MATH_PRECNAME
00105
00106
# if (__STDC__ - 0 || __GNUC__ - 0) && !defined __NO_LONG_DOUBLE_MATH
00107
00108
00109
00110
# ifndef _Mlong_double_
00111
# define _Mlong_double_ long double
00112
# endif
00113
# define _Mdouble_ _Mlong_double_
00114
# ifdef __STDC__
00115
# define __MATH_PRECNAME(name,r) name##l##r
00116
# else
00117
# define __MATH_PRECNAME(name,r) namelr
00118
# endif
00119
00120
#define _Mdouble_BEGIN_NAMESPACE __BEGIN_NAMESPACE_C99
00121
#define _Mdouble_END_NAMESPACE __END_NAMESPACE_C99
00122
00123
# include <bits/mathcalls.h>
00124
# undef _Mdouble_
00125
00126
# undef _Mdouble_BEGIN_NAMESPACE
00127
# undef _Mdouble_END_NAMESPACE
00128
00129
# undef __MATH_PRECNAME
00130
00131
# endif
00132
00133
#endif
00134
#undef __MATHDECL_1
00135
#undef __MATHDECL
00136
#undef __MATHCALL
00137
00138
00139
#if defined __USE_MISC || defined __USE_XOPEN
00140
00141
extern int signgam;
00142
#endif
00143
00144
00145
00146
#if __USE_ISOC99
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
enum
00183 {
00184 FP_NAN,
00185
# define FP_NAN FP_NAN
00186
FP_INFINITE,
00187
# define FP_INFINITE FP_INFINITE
00188
FP_ZERO,
00189
# define FP_ZERO FP_ZERO
00190
FP_SUBNORMAL,
00191
# define FP_SUBNORMAL FP_SUBNORMAL
00192
FP_NORMAL
00193
# define FP_NORMAL FP_NORMAL
00194
};
00195
00196
00197
# ifdef __NO_LONG_DOUBLE_MATH
00198
# define fpclassify(x) \
00199
(sizeof (x) == sizeof (float) ? __fpclassifyf (x) : __fpclassify (x))
00200
# else
00201
# define fpclassify(x) \
00202
(sizeof (x) == sizeof (float) \
00203
? __fpclassifyf (x) \
00204
: sizeof (x) == sizeof (double) \
00205
? __fpclassify (x) : __fpclassifyl (x))
00206
# endif
00207
00208
00209
# ifdef __NO_LONG_DOUBLE_MATH
00210
# define signbit(x) \
00211
(sizeof (x) == sizeof (float) ? __signbitf (x) : __signbit (x))
00212
# else
00213
# define signbit(x) \
00214
(sizeof (x) == sizeof (float) \
00215
? __signbitf (x) \
00216
: sizeof (x) == sizeof (double) \
00217
? __signbit (x) : __signbitl (x))
00218
# endif
00219
00220
00221
# ifdef __NO_LONG_DOUBLE_MATH
00222
# define isfinite(x) \
00223
(sizeof (x) == sizeof (float) ? __finitef (x) : __finite (x))
00224
# else
00225
# define isfinite(x) \
00226
(sizeof (x) == sizeof (float) \
00227
? __finitef (x) \
00228
: sizeof (x) == sizeof (double) \
00229
? __finite (x) : __finitel (x))
00230
# endif
00231
00232
00233
# define isnormal(x) (fpclassify (x) == FP_NORMAL)
00234
00235
00236
00237
# ifdef __NO_LONG_DOUBLE_MATH
00238
# define isnan(x) \
00239
(sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
00240
# else
00241
# define isnan(x) \
00242
(sizeof (x) == sizeof (float) \
00243
? __isnanf (x) \
00244
: sizeof (x) == sizeof (double) \
00245
? __isnan (x) : __isnanl (x))
00246
# endif
00247
00248
00249
# ifdef __NO_LONG_DOUBLE_MATH
00250
# define isinf(x) \
00251
(sizeof (x) == sizeof (float) ? __isinff (x) : __isinf (x))
00252
# else
00253
# define isinf(x) \
00254
(sizeof (x) == sizeof (float) \
00255
? __isinff (x) \
00256
: sizeof (x) == sizeof (double) \
00257
? __isinf (x) : __isinfl (x))
00258
# endif
00259
00260
00261
# define MATH_ERRNO 1
00262
# define MATH_ERREXCEPT 2
00263
00264
#endif
00265
00266
#ifdef __USE_MISC
00267
00268
typedef enum
00269 {
00270 _IEEE_ = -1,
00271 _SVID_,
00272 _XOPEN_,
00273 _POSIX_,
00274 _ISOC_
00275 } _LIB_VERSION_TYPE;
00276
00277
00278
00279
00280
extern _LIB_VERSION_TYPE
_LIB_VERSION;
00281
#endif
00282
00283
00284
#ifdef __USE_SVID
00285
00286
00287
00288
00289
00290
# ifdef __cplusplus
00291
struct __exception
00292 # else
00293 struct exception
00294 # endif
00295 {
00296
int type;
00297
char *name;
00298
double arg1;
00299
double arg2;
00300
double retval;
00301 };
00302
00303
# ifdef __cplusplus
00304
extern int matherr (
struct __exception *__exc)
throw ();
00305
# else
00306
extern int matherr (
struct exception *__exc);
00307
# endif
00308
00309
# define X_TLOSS 1.41484755040568800000e+16
00310
00311
00312
# define DOMAIN 1
00313
# define SING 2
00314
# define OVERFLOW 3
00315
# define UNDERFLOW 4
00316
# define TLOSS 5
00317
# define PLOSS 6
00318
00319
00320
# define HUGE 3.40282347e+38F
00321
00322
#else
00323
00324
# ifdef __USE_XOPEN
00325
00326
# define MAXFLOAT 3.40282347e+38F
00327
# endif
00328
00329
#endif
00330
00331
00332
00333
#if defined __USE_BSD || defined __USE_XOPEN
00334
# define M_E 2.7182818284590452354
00335
# define M_LOG2E 1.4426950408889634074
00336
# define M_LOG10E 0.43429448190325182765
00337
# define M_LN2 0.69314718055994530942
00338
# define M_LN10 2.30258509299404568402
00339
# define M_PI 3.14159265358979323846
00340
# define M_PI_2 1.57079632679489661923
00341
# define M_PI_4 0.78539816339744830962
00342
# define M_1_PI 0.31830988618379067154
00343
# define M_2_PI 0.63661977236758134308
00344
# define M_2_SQRTPI 1.12837916709551257390
00345
# define M_SQRT2 1.41421356237309504880
00346
# define M_SQRT1_2 0.70710678118654752440
00347
#endif
00348
00349
00350
00351
00352
#ifdef __USE_GNU
00353
# define M_El 2.7182818284590452353602874713526625L
00354
# define M_LOG2El 1.4426950408889634073599246810018922L
00355
# define M_LOG10El 0.4342944819032518276511289189166051L
00356
# define M_LN2l 0.6931471805599453094172321214581766L
00357
# define M_LN10l 2.3025850929940456840179914546843642L
00358
# define M_PIl 3.1415926535897932384626433832795029L
00359
# define M_PI_2l 1.5707963267948966192313216916397514L
00360
# define M_PI_4l 0.7853981633974483096156608458198757L
00361
# define M_1_PIl 0.3183098861837906715377675267450287L
00362
# define M_2_PIl 0.6366197723675813430755350534900574L
00363
# define M_2_SQRTPIl 1.1283791670955125738961589031215452L
00364
# define M_SQRT2l 1.4142135623730950488016887242096981L
00365
# define M_SQRT1_2l 0.7071067811865475244008443621048490L
00366
#endif
00367
00368
00369
00370
00371
00372
#if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
00373
# define __NO_MATH_INLINES 1
00374
#endif
00375
00376
00377
#ifdef __USE_EXTERN_INLINES
00378
# include <bits/mathinline.h>
00379
#endif
00380
00381
00382
#if __USE_ISOC99
00383
00384
00385
00386
00387
00388
00389
00390
# ifndef isgreater
00391
# define isgreater(x, y) \
00392
(__extension__ \
00393
({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
00394
!isunordered (__x, __y) && __x > __y; }))
00395
# endif
00396
00397
00398
# ifndef isgreaterequal
00399
# define isgreaterequal(x, y) \
00400
(__extension__ \
00401
({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
00402
!isunordered (__x, __y) && __x >= __y; }))
00403
# endif
00404
00405
00406
# ifndef isless
00407
# define isless(x, y) \
00408
(__extension__ \
00409
({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
00410
!isunordered (__x, __y) && __x < __y; }))
00411
# endif
00412
00413
00414
# ifndef islessequal
00415
# define islessequal(x, y) \
00416
(__extension__ \
00417
({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
00418
!isunordered (__x, __y) && __x <= __y; }))
00419
# endif
00420
00421
00422
# ifndef islessgreater
00423
# define islessgreater(x, y) \
00424
(__extension__ \
00425
({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
00426
!isunordered (__x, __y) && (__x < __y || __y < __x); }))
00427
# endif
00428
00429
00430
# ifndef isunordered
00431
# define isunordered(u, v) \
00432
(__extension__ \
00433
({ __typeof__(u) __u = (u); __typeof__(v) __v = (v); \
00434
fpclassify (__u) == FP_NAN || fpclassify (__v) == FP_NAN; }))
00435
# endif
00436
00437
#endif
00438
00439 __END_DECLS
00440
00441
00442
00443 struct complex {
00444
double x;
00445
double y;
00446 };
00447
00448
double cabs __P((
struct complex));
00449
00450
double gamma_r(
double x,
int *signgamp);
00451
00452
long int rinttol(
double x);
00453
00454
long int roundtol(
double x);
00455
00456
#endif
Generated on Thu Nov 20 11:49:49 2008 for RTAI API by
1.3.8