| [aad342c] | 1 | /* The header math.h declares two types and many common mathematical operations
|
|---|
| 2 | * and defines several macros.
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifndef _MATH_
|
|---|
| 6 | #define _MATH_
|
|---|
| 7 | #pragma CIVL ACSL
|
|---|
| 8 | /* Types */
|
|---|
| 9 | #ifndef FLT_EVAL_METHOD
|
|---|
| 10 | #define FLT_EVAL_METHOD 0
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #if (FLT_EVAL_METHOD == 0)
|
|---|
| 14 | #define float_t float // floating-point type at least
|
|---|
| 15 | //as wide as 'float' used to evaluate
|
|---|
| 16 | //'float' expression.
|
|---|
| 17 | #define double_t double // floating-point type at least
|
|---|
| 18 | //as wide as 'double' used to evaluate
|
|---|
| 19 | //'double' expression.
|
|---|
| 20 | #elif (FLT_EVAL_METHOD == 1)
|
|---|
| 21 | #define float_t double
|
|---|
| 22 | #define double_t double
|
|---|
| 23 | #elif (FLT_EVAL_METHOD == 2)
|
|---|
| 24 | #define float_t long double
|
|---|
| 25 | #define double_t long double
|
|---|
| 26 | #else // Implementation defined.
|
|---|
| 27 | #define float_t float
|
|---|
| 28 | #define double_t double
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | /* Macros */
|
|---|
| 32 | //In CIVL implementation, they better be abstract functions.
|
|---|
| 33 | //TODO: Make PI an abstract function with assumptions.
|
|---|
| 34 | //3.14 < PI < 3.15
|
|---|
| 35 | #define M_E 2.7182818284590452354
|
|---|
| 36 | #define M_LOG2E 1.4426950408889634074
|
|---|
| 37 | #define M_LOG10E 0.43429448190325182765
|
|---|
| 38 | #define M_LN2 0.69314718055994530942
|
|---|
| 39 | #define M_LN10 2.30258509299404568402
|
|---|
| 40 | #define M_PI 3.14159265358979323846
|
|---|
| 41 | #define M_PI_2 M_PI/2.0 //1.57079632679489661923
|
|---|
| 42 | #define M_PI_4 0.78539816339744830962
|
|---|
| 43 | #define M_1_PI 0.31830988618379067154
|
|---|
| 44 | #define M_2_PI 0.63661977236758134308
|
|---|
| 45 | #define M_2_SQRTPI 1.12837916709551257390
|
|---|
| 46 | #define M_SQRT2 1.41421356237309504880
|
|---|
| 47 | #define M_SQRT1_2 0.70710678118654752440
|
|---|
| 48 | #define HUGE_VAL 3.40282347e+38F
|
|---|
| 49 | #define HUGE_VALF 3.40282347e+38F
|
|---|
| 50 | #define HUGE_VALL 3.40282347e+38F
|
|---|
| 51 | #define INFINITY (1/0)
|
|---|
| 52 | #define NAN sqrt(-1)
|
|---|
| 53 |
|
|---|
| 54 | typedef enum {
|
|---|
| 55 | FP_INFINITE,
|
|---|
| 56 | FP_NAN,
|
|---|
| 57 | FP_ZERO,
|
|---|
| 58 | FP_NORMAL,
|
|---|
| 59 | FP_SUBNORMAL
|
|---|
| 60 | }number_classification;
|
|---|
| 61 |
|
|---|
| 62 | #define FP_FAST_FMA 1
|
|---|
| 63 | #define FP_FAST_FMAF 1
|
|---|
| 64 | #define FP_FAST_FMAL 1
|
|---|
| 65 |
|
|---|
| 66 | typedef enum {
|
|---|
| 67 | MATH_ERRNO = 2,
|
|---|
| 68 | MATH_ERREXCEPT = 3
|
|---|
| 69 | }math_errhandling;
|
|---|
| 70 |
|
|---|
| 71 | // Macro functions
|
|---|
| 72 | #define fpclassify(x) \
|
|---|
| 73 | ((sizeof(x) == sizeof(float)) ? __fpclassifyf(x) : \
|
|---|
| 74 | (sizeof(x) == sizeof(double)) ? __fpclassifyd(x) : \
|
|---|
| 75 | __fpclassifyl(x))
|
|---|
| 76 | #define isfinite(x) \
|
|---|
| 77 | ((sizeof(x) == sizeof(float)) ? __isfinitef(x) : \
|
|---|
| 78 | (sizeof(x) == sizeof(double)) ? __isfinited(x) : \
|
|---|
| 79 | __isfinitel(x))
|
|---|
| 80 | #define isinf(x) \
|
|---|
| 81 | ((sizeof(x) == sizeof(float)) ? __isinff(x) : \
|
|---|
| 82 | (sizeof(x) == sizeof(double)) ? __isinfd(x) : \
|
|---|
| 83 | __isinfl(x))
|
|---|
| 84 | #define isnan(x) \
|
|---|
| 85 | ((sizeof(x) == sizeof(float)) ? __isnanf(x) : \
|
|---|
| 86 | (sizeof(x) == sizeof(double)) ? __isnand(x) : \
|
|---|
| 87 | __isnanl(x))
|
|---|
| 88 | #define isnormal(x) \
|
|---|
| 89 | ((sizeof(x) == sizeof(float)) ? __isnormalf(x) : \
|
|---|
| 90 | (sizeof(x) == sizeof(double)) ? __isnormald(x) : \
|
|---|
| 91 | __isnormall(x))
|
|---|
| 92 | #define signbit(x) \
|
|---|
| 93 | ((sizeof(x) == sizeof(float)) ? __signbitf(x) : \
|
|---|
| 94 | (sizeof(x) == sizeof(double)) ? __signbitd(x) : \
|
|---|
| 95 | __signbitl(x))
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | int __fpclassifyf (float x);
|
|---|
| 99 | int __fpclassifyd (double x);
|
|---|
| 100 | int __fpclassifyl (long double x);
|
|---|
| 101 | int __isfinitef (float x);
|
|---|
| 102 | int __isfinited (double x);
|
|---|
| 103 | int __isfinitel (long double x);
|
|---|
| 104 | int __isinff (float x);
|
|---|
| 105 | int __isinfd (double x);
|
|---|
| 106 | int __isinfl (long double x);
|
|---|
| 107 | int __isnanf (float x);
|
|---|
| 108 | int __isnand (double x);
|
|---|
| 109 | int __isnanl (long double x);
|
|---|
| 110 | int __isnormalf (float x);
|
|---|
| 111 | int __isnormald (double x);
|
|---|
| 112 | int __isnormall (long double x);
|
|---|
| 113 | int __signbitf (float x);
|
|---|
| 114 | int __signbitd (double x);
|
|---|
| 115 | int __signbitl (long double x);
|
|---|
| 116 |
|
|---|
| 117 | //trigonomatric functions
|
|---|
| 118 | /*@ pure;
|
|---|
| 119 | @*/
|
|---|
| 120 | double acos(double x);
|
|---|
| 121 | /*@ pure;
|
|---|
| 122 | @*/
|
|---|
| 123 | float acosf(float x);
|
|---|
| 124 | /*@ pure;
|
|---|
| 125 | @*/
|
|---|
| 126 | long double acosl(long double x);
|
|---|
| 127 | /*@ pure;
|
|---|
| 128 | @*/
|
|---|
| 129 | double asin(double x);
|
|---|
| 130 | /*@ pure;
|
|---|
| 131 | @*/
|
|---|
| 132 | float asinf(float x);
|
|---|
| 133 | /*@ pure;
|
|---|
| 134 | @*/
|
|---|
| 135 | long double asinl(long double x);
|
|---|
| 136 | /*@ pure;
|
|---|
| 137 | @*/
|
|---|
| 138 | double atan(double x);
|
|---|
| 139 | /*@ pure;
|
|---|
| 140 | @*/
|
|---|
| 141 | float atanf(float x);
|
|---|
| 142 | /*@ pure;
|
|---|
| 143 | @*/
|
|---|
| 144 | long double atanl(long double x);
|
|---|
| 145 | /*@ pure;
|
|---|
| 146 | @*/
|
|---|
| 147 | double atan2(double y, double x);
|
|---|
| 148 | /*@ pure;
|
|---|
| 149 | @*/
|
|---|
| 150 | float atan2f(float y, float x);
|
|---|
| 151 | /*@ pure;
|
|---|
| 152 | @*/
|
|---|
| 153 | long double atan2l(long double y, long double x);
|
|---|
| 154 | /*@ pure;
|
|---|
| 155 | @*/
|
|---|
| 156 | double cos(double x);
|
|---|
| 157 | /*@ pure;
|
|---|
| 158 | @*/
|
|---|
| 159 | float cosf(float x);
|
|---|
| 160 | /*@ pure;
|
|---|
| 161 | @*/
|
|---|
| 162 | long double cosl(long double x);
|
|---|
| 163 | /*@ pure;
|
|---|
| 164 | @*/
|
|---|
| 165 | double sin(double x);
|
|---|
| 166 | /*@ pure;
|
|---|
| 167 | @*/
|
|---|
| 168 | float sinf(float x);
|
|---|
| 169 | /*@ pure;
|
|---|
| 170 | @*/
|
|---|
| 171 | long double sinl(long double x);
|
|---|
| 172 | /*@ pure;
|
|---|
| 173 | @*/
|
|---|
| 174 | double tan(double x);
|
|---|
| 175 | /*@ pure;
|
|---|
| 176 | @*/
|
|---|
| 177 | float tanf(float x);
|
|---|
| 178 | /*@ pure;
|
|---|
| 179 | @*/
|
|---|
| 180 | long double tanl(long double x);
|
|---|
| 181 |
|
|---|
| 182 | //hyperbolic functions
|
|---|
| 183 | /*@ pure;
|
|---|
| 184 | @*/
|
|---|
| 185 | double acosh(double x);
|
|---|
| 186 | /*@ pure;
|
|---|
| 187 | @*/
|
|---|
| 188 | float acoshf(float x);
|
|---|
| 189 | /*@ pure;
|
|---|
| 190 | @*/
|
|---|
| 191 | long double acoshl(long double x);
|
|---|
| 192 | /*@ pure;
|
|---|
| 193 | @*/
|
|---|
| 194 | double asinh(double x);
|
|---|
| 195 | /*@ pure;
|
|---|
| 196 | @*/
|
|---|
| 197 | float asinhf(float x);
|
|---|
| 198 | /*@ pure;
|
|---|
| 199 | @*/
|
|---|
| 200 | long double asinhl(long double x);
|
|---|
| 201 | /*@ pure;
|
|---|
| 202 | @*/
|
|---|
| 203 | double atan(double x);
|
|---|
| 204 | /*@ pure;
|
|---|
| 205 | @*/
|
|---|
| 206 | float atanf(float x);
|
|---|
| 207 | /*@ pure;
|
|---|
| 208 | @*/
|
|---|
| 209 | long double atanl(long double x);
|
|---|
| 210 | /*@ pure;
|
|---|
| 211 | @*/
|
|---|
| 212 | double atanh(double x);
|
|---|
| 213 | /*@ pure;
|
|---|
| 214 | @*/
|
|---|
| 215 | float atanhf(float x);
|
|---|
| 216 | /*@ pure;
|
|---|
| 217 | @*/
|
|---|
| 218 | long double atanhl(long double x);
|
|---|
| 219 | /*@ pure;
|
|---|
| 220 | @*/
|
|---|
| 221 | double cosh(double x);
|
|---|
| 222 | /*@ pure;
|
|---|
| 223 | @*/
|
|---|
| 224 | float coshf(float x);
|
|---|
| 225 | /*@ pure;
|
|---|
| 226 | @*/
|
|---|
| 227 | long double coshl(long double x);
|
|---|
| 228 | /*@ pure;
|
|---|
| 229 | @*/
|
|---|
| 230 | double sinh(double x);
|
|---|
| 231 | /*@ pure;
|
|---|
| 232 | @*/
|
|---|
| 233 | float sinhf(float x);
|
|---|
| 234 | /*@ pure;
|
|---|
| 235 | @*/
|
|---|
| 236 | long double sinhl(long double x);
|
|---|
| 237 | /*@ pure;
|
|---|
| 238 | @*/
|
|---|
| 239 | double tanh(double x);
|
|---|
| 240 | /*@ pure;
|
|---|
| 241 | @*/
|
|---|
| 242 | float tanhf(float x);
|
|---|
| 243 | /*@ pure;
|
|---|
| 244 | @*/
|
|---|
| 245 | long double tanhl(long double x);
|
|---|
| 246 |
|
|---|
| 247 | //exponential and logistic functions
|
|---|
| 248 | /*@ pure;
|
|---|
| 249 | @*/
|
|---|
| 250 | double exp(double x);
|
|---|
| 251 | /*@ pure;
|
|---|
| 252 | @*/
|
|---|
| 253 | float expf(float x);
|
|---|
| 254 | /*@ pure;
|
|---|
| 255 | @*/
|
|---|
| 256 | long double expl(long double x);
|
|---|
| 257 | /*@ pure;
|
|---|
| 258 | @*/
|
|---|
| 259 | double exp2(double x);
|
|---|
| 260 | /*@ pure;
|
|---|
| 261 | @*/
|
|---|
| 262 | float exp2f(float x);
|
|---|
| 263 | /*@ pure;
|
|---|
| 264 | @*/
|
|---|
| 265 | long double exp2l(long double x);
|
|---|
| 266 | /*@ pure;
|
|---|
| 267 | @*/
|
|---|
| 268 | double expm1(double x);
|
|---|
| 269 | /*@ pure;
|
|---|
| 270 | @*/
|
|---|
| 271 | float expm1f(float x);
|
|---|
| 272 | /*@ pure;
|
|---|
| 273 | @*/
|
|---|
| 274 | long double expm1l(long double x);
|
|---|
| 275 | /*@ pure;
|
|---|
| 276 | @*/
|
|---|
| 277 | double frexp(double value, int *exp);
|
|---|
| 278 | /*@ pure;
|
|---|
| 279 | @*/
|
|---|
| 280 | float frexpf(float value, int *exp);
|
|---|
| 281 | /*@ pure;
|
|---|
| 282 | @*/
|
|---|
| 283 | long double frexpl(long double value, int *exp);
|
|---|
| 284 | /*@ pure;
|
|---|
| 285 | @*/
|
|---|
| 286 | int ilogb(double x);
|
|---|
| 287 | /*@ pure;
|
|---|
| 288 | @*/
|
|---|
| 289 | int ilogbf(float x);
|
|---|
| 290 | /*@ pure;
|
|---|
| 291 | @*/
|
|---|
| 292 | int ilogbl(long double x);
|
|---|
| 293 | /*@ pure;
|
|---|
| 294 | @*/
|
|---|
| 295 | double ldexp(double x, int exp);
|
|---|
| 296 | /*@ pure;
|
|---|
| 297 | @*/
|
|---|
| 298 | float ldexpf(float x, int exp);
|
|---|
| 299 | /*@ pure;
|
|---|
| 300 | @*/
|
|---|
| 301 | long double ldexpl(long double x, int exp);
|
|---|
| 302 | /*@ pure;
|
|---|
| 303 | @*/
|
|---|
| 304 | double log(double x);
|
|---|
| 305 | /*@ pure;
|
|---|
| 306 | @*/
|
|---|
| 307 | float logf(float x);
|
|---|
| 308 | /*@ pure;
|
|---|
| 309 | @*/
|
|---|
| 310 | long double logl(long double x);
|
|---|
| 311 | /*@ pure;
|
|---|
| 312 | @*/
|
|---|
| 313 | double log10(double x);
|
|---|
| 314 | /*@ pure;
|
|---|
| 315 | @*/
|
|---|
| 316 | float log10f(float x);
|
|---|
| 317 | /*@ pure;
|
|---|
| 318 | @*/
|
|---|
| 319 | long double log10l(long double x);
|
|---|
| 320 | /*@ pure;
|
|---|
| 321 | @*/
|
|---|
| 322 | double log1p(double x);
|
|---|
| 323 | /*@ pure;
|
|---|
| 324 | @*/
|
|---|
| 325 | float log1pf(float x);
|
|---|
| 326 | /*@ pure;
|
|---|
| 327 | @*/
|
|---|
| 328 | long double log1pl(long double x);
|
|---|
| 329 | /*@ pure;
|
|---|
| 330 | @*/
|
|---|
| 331 | double log2(double x);
|
|---|
| 332 | /*@ pure;
|
|---|
| 333 | @*/
|
|---|
| 334 | float log2f(float x);
|
|---|
| 335 | /*@ pure;
|
|---|
| 336 | @*/
|
|---|
| 337 | long double log2l(long double x);
|
|---|
| 338 | /*@ pure;
|
|---|
| 339 | @*/
|
|---|
| 340 | double logb(double x);
|
|---|
| 341 | /*@ pure;
|
|---|
| 342 | @*/
|
|---|
| 343 | float logbf(float x);
|
|---|
| 344 | /*@ pure;
|
|---|
| 345 | @*/
|
|---|
| 346 | long double logbl(long double x);
|
|---|
| 347 | /*@ pure;
|
|---|
| 348 | @*/
|
|---|
| 349 | double modf(double value, double * iptr);
|
|---|
| 350 | /*@ pure;
|
|---|
| 351 | @*/
|
|---|
| 352 | float modff(float value, float * iptr);
|
|---|
| 353 | /*@ pure;
|
|---|
| 354 | @*/
|
|---|
| 355 | long double modfl(long double value, long double * iptr);
|
|---|
| 356 | /*@ pure;
|
|---|
| 357 | @*/
|
|---|
| 358 | double scalbn(double x, int n);
|
|---|
| 359 | /*@ pure;
|
|---|
| 360 | @*/
|
|---|
| 361 | float scalbnf(float x, int n);
|
|---|
| 362 | /*@ pure;
|
|---|
| 363 | @*/
|
|---|
| 364 | long double scalbnl(long double x, int n);
|
|---|
| 365 | /*@ pure;
|
|---|
| 366 | @*/
|
|---|
| 367 | double scalbln(double x, int n);
|
|---|
| 368 | /*@ pure;
|
|---|
| 369 | @*/
|
|---|
| 370 | float scalblnf(float x, int n);
|
|---|
| 371 | /*@ pure;
|
|---|
| 372 | @*/
|
|---|
| 373 | long double scalblnl(long double x, int n);
|
|---|
| 374 |
|
|---|
| 375 | //power and absolute-value functions
|
|---|
| 376 | /*@ pure;
|
|---|
| 377 | @*/
|
|---|
| 378 | double cbrt(double x);
|
|---|
| 379 | /*@ pure;
|
|---|
| 380 | @*/
|
|---|
| 381 | float cbrtf(float x);
|
|---|
| 382 | /*@ pure;
|
|---|
| 383 | @*/
|
|---|
| 384 | long double cbrtl(long double x);
|
|---|
| 385 | /*@ pure;
|
|---|
| 386 | @*/
|
|---|
| 387 | double fabs(double x);
|
|---|
| 388 | /*@ pure;
|
|---|
| 389 | @*/
|
|---|
| 390 | float fabsf(float x);
|
|---|
| 391 | /*@ pure;
|
|---|
| 392 | @*/
|
|---|
| 393 | long double fabsl(long double x);
|
|---|
| 394 | /*@ pure;
|
|---|
| 395 | @*/
|
|---|
| 396 | double hypot(double x, double y);
|
|---|
| 397 | /*@ pure;
|
|---|
| 398 | @*/
|
|---|
| 399 | float hypotf(float x, float y);
|
|---|
| 400 | /*@ pure;
|
|---|
| 401 | @*/
|
|---|
| 402 | long double hypotl(long double x, long double y);
|
|---|
| 403 | /*@ pure;
|
|---|
| 404 | @*/
|
|---|
| 405 | double pow(double x, double y);
|
|---|
| 406 | /*@ pure;
|
|---|
| 407 | @*/
|
|---|
| 408 | float powf(float x, float y);
|
|---|
| 409 | /*@ pure;
|
|---|
| 410 | @*/
|
|---|
| 411 | long double powl(long double x, long double y);
|
|---|
| 412 | /*@ pure;
|
|---|
| 413 | @*/
|
|---|
| 414 | double sqrt(double x);
|
|---|
| 415 | /*@ pure;
|
|---|
| 416 | @*/
|
|---|
| 417 | float sqrtf(float x);
|
|---|
| 418 | /*@ pure;
|
|---|
| 419 | @*/
|
|---|
| 420 | long double sqrtl(long double x);
|
|---|
| 421 |
|
|---|
| 422 | //error and gamma functions
|
|---|
| 423 | /*@ pure;
|
|---|
| 424 | @*/
|
|---|
| 425 | double erf(double x);
|
|---|
| 426 | /*@ pure;
|
|---|
| 427 | @*/
|
|---|
| 428 | float erff(float x);
|
|---|
| 429 | /*@ pure;
|
|---|
| 430 | @*/
|
|---|
| 431 | long double erfl(long double x);
|
|---|
| 432 | /*@ pure;
|
|---|
| 433 | @*/
|
|---|
| 434 | double erfc(double x);
|
|---|
| 435 | /*@ pure;
|
|---|
| 436 | @*/
|
|---|
| 437 | float erfcf(float x);
|
|---|
| 438 | /*@ pure;
|
|---|
| 439 | @*/
|
|---|
| 440 | long double erfcl(long double x);
|
|---|
| 441 | /*@ pure;
|
|---|
| 442 | @*/
|
|---|
| 443 | double lgamma(double x);
|
|---|
| 444 | /*@ pure;
|
|---|
| 445 | @*/
|
|---|
| 446 | float lgammaf(float x);
|
|---|
| 447 | /*@ pure;
|
|---|
| 448 | @*/
|
|---|
| 449 | long double lgammal(long double x);
|
|---|
| 450 | /*@ pure;
|
|---|
| 451 | @*/
|
|---|
| 452 | double tgamma(double x);
|
|---|
| 453 | /*@ pure;
|
|---|
| 454 | @*/
|
|---|
| 455 | float tgammaf(float x);
|
|---|
| 456 | /*@ pure;
|
|---|
| 457 | @*/
|
|---|
| 458 | long double tgammal(long double x);
|
|---|
| 459 |
|
|---|
| 460 | //nearest integer functions
|
|---|
| 461 | /*@ pure;
|
|---|
| 462 | @ executes_when \true;
|
|---|
| 463 | @*/
|
|---|
| 464 | $system double ceil(double x);
|
|---|
| 465 |
|
|---|
| 466 | /*@ pure;
|
|---|
| 467 | @ executes_when \true;
|
|---|
| 468 | @*/
|
|---|
| 469 | $system float ceilf(float x);
|
|---|
| 470 |
|
|---|
| 471 | /*@ pure;
|
|---|
| 472 | @ executes_when \true;
|
|---|
| 473 | @*/
|
|---|
| 474 | $system long double ceill(long double x);
|
|---|
| 475 |
|
|---|
| 476 | /*@ pure;
|
|---|
| 477 | @ executes_when \true;
|
|---|
| 478 | @*/
|
|---|
| 479 | $system double floor(double x);
|
|---|
| 480 |
|
|---|
| 481 | /*@ pure;
|
|---|
| 482 | @ executes_when \true;
|
|---|
| 483 | @*/
|
|---|
| 484 | $system float floorf(float x);
|
|---|
| 485 |
|
|---|
| 486 | /*@ pure;
|
|---|
| 487 | @ executes_when \true;
|
|---|
| 488 | @*/
|
|---|
| 489 | $system long double floorl(long double x);
|
|---|
| 490 |
|
|---|
| 491 | /*@ pure;
|
|---|
| 492 | @*/
|
|---|
| 493 | double nearbyint(double x);
|
|---|
| 494 | /*@ pure;
|
|---|
| 495 | @*/
|
|---|
| 496 | float nearbyintf(float x);
|
|---|
| 497 | /*@ pure;
|
|---|
| 498 | @*/
|
|---|
| 499 | long double nearbyintl(long double x);
|
|---|
| 500 | /*@ pure;
|
|---|
| 501 | @*/
|
|---|
| 502 | double rint(double x);
|
|---|
| 503 | /*@ pure;
|
|---|
| 504 | @*/
|
|---|
| 505 | float rintf(float x);
|
|---|
| 506 | /*@ pure;
|
|---|
| 507 | @*/
|
|---|
| 508 | long double rintl(long double x);
|
|---|
| 509 | /*@ pure;
|
|---|
| 510 | @*/
|
|---|
| 511 | long int lrint(double x);
|
|---|
| 512 | /*@ pure;
|
|---|
| 513 | @*/
|
|---|
| 514 | long int lrintf(float x);
|
|---|
| 515 | /*@ pure;
|
|---|
| 516 | @*/
|
|---|
| 517 | long int lrintl(long double x);
|
|---|
| 518 | /*@ pure;
|
|---|
| 519 | @*/
|
|---|
| 520 | long long int llrint(double x);
|
|---|
| 521 | /*@ pure;
|
|---|
| 522 | @*/
|
|---|
| 523 | long long int llrintf(float x);
|
|---|
| 524 | /*@ pure;
|
|---|
| 525 | @*/
|
|---|
| 526 | long long int llrintl(long double x);
|
|---|
| 527 | /*@ pure;
|
|---|
| 528 | @*/
|
|---|
| 529 | double round(double x);
|
|---|
| 530 | /*@ pure;
|
|---|
| 531 | @*/
|
|---|
| 532 | float roundf(float x);
|
|---|
| 533 | /*@ pure;
|
|---|
| 534 | @*/
|
|---|
| 535 | long double roundl(long double x);
|
|---|
| 536 | /*@ pure;
|
|---|
| 537 | @*/
|
|---|
| 538 | long int lround(double x);
|
|---|
| 539 | /*@ pure;
|
|---|
| 540 | @*/
|
|---|
| 541 | long int lroundf(float x);
|
|---|
| 542 | /*@ pure;
|
|---|
| 543 | @*/
|
|---|
| 544 | long int lroundl(long double x);
|
|---|
| 545 | /*@ pure;
|
|---|
| 546 | @*/
|
|---|
| 547 | long long int llround(double x);
|
|---|
| 548 | /*@ pure;
|
|---|
| 549 | @*/
|
|---|
| 550 | long long int llroundf(float x);
|
|---|
| 551 | /*@ pure;
|
|---|
| 552 | @*/
|
|---|
| 553 | long long int llroundl(long double x);
|
|---|
| 554 | /*@ pure;
|
|---|
| 555 | @*/
|
|---|
| 556 | double trunc(double x);
|
|---|
| 557 | /*@ pure;
|
|---|
| 558 | @*/
|
|---|
| 559 | float truncf(float x);
|
|---|
| 560 | /*@ pure;
|
|---|
| 561 | @*/
|
|---|
| 562 | long double truncl(long double x);
|
|---|
| 563 |
|
|---|
| 564 | //remainder
|
|---|
| 565 | /*@ pure;
|
|---|
| 566 | @*/
|
|---|
| 567 | double fmod(double x, double y);
|
|---|
| 568 | /*@ pure;
|
|---|
| 569 | @*/
|
|---|
| 570 | float fmodf(float x, float y);
|
|---|
| 571 | /*@ pure;
|
|---|
| 572 | @*/
|
|---|
| 573 | long double fmodl(long double x, long double y);
|
|---|
| 574 | /*@ pure;
|
|---|
| 575 | @*/
|
|---|
| 576 | double remainder(double x, double y);
|
|---|
| 577 | /*@ pure;
|
|---|
| 578 | @*/
|
|---|
| 579 | float remainderf(float x, float y);
|
|---|
| 580 | /*@ pure;
|
|---|
| 581 | @*/
|
|---|
| 582 | long double remainderl(long double x, long double y);
|
|---|
| 583 | /*@ pure;
|
|---|
| 584 | @*/
|
|---|
| 585 | double remquo(double x, double y, int *quo);
|
|---|
| 586 | /*@ pure;
|
|---|
| 587 | @*/
|
|---|
| 588 | float remquof(float x, float y, int *quo);
|
|---|
| 589 | /*@ pure;
|
|---|
| 590 | @*/
|
|---|
| 591 | long double remquol(long double x, long double y, int *quo);
|
|---|
| 592 |
|
|---|
| 593 | //Manipulation functions
|
|---|
| 594 | /*@ pure;
|
|---|
| 595 | @*/
|
|---|
| 596 | double copysign(double x, double y);
|
|---|
| 597 | /*@ pure;
|
|---|
| 598 | @*/
|
|---|
| 599 | float copysignf(float x, float y);
|
|---|
| 600 | /*@ pure;
|
|---|
| 601 | @*/
|
|---|
| 602 | long double copysignl(long double x, long double y);
|
|---|
| 603 | /*@ pure;
|
|---|
| 604 | @*/
|
|---|
| 605 | double nan(const char *tagp);
|
|---|
| 606 | /*@ pure;
|
|---|
| 607 | @*/
|
|---|
| 608 | float nanf(const char *tagp);
|
|---|
| 609 | /*@ pure;
|
|---|
| 610 | @*/
|
|---|
| 611 | long double nanl(const char *tagp);
|
|---|
| 612 | /*@ pure;
|
|---|
| 613 | @*/
|
|---|
| 614 | double nextafter(double x, double y);
|
|---|
| 615 | /*@ pure;
|
|---|
| 616 | @*/
|
|---|
| 617 | float nextafterf(float x, float y);
|
|---|
| 618 | /*@ pure;
|
|---|
| 619 | @*/
|
|---|
| 620 | long double nextafterl(long double x, long double y);
|
|---|
| 621 | /*@ pure;
|
|---|
| 622 | @*/
|
|---|
| 623 | double nexttoward(double x, long double y);
|
|---|
| 624 | /*@ pure;
|
|---|
| 625 | @*/
|
|---|
| 626 | float nexttowardf(float x, long double y);
|
|---|
| 627 | /*@ pure;
|
|---|
| 628 | @*/
|
|---|
| 629 | long double nexttowardl(long double x, long double y);
|
|---|
| 630 |
|
|---|
| 631 | // Maximum, minimum and positive difference functions
|
|---|
| 632 | /*@ pure;
|
|---|
| 633 | @*/
|
|---|
| 634 | double fdim(double x, double y);
|
|---|
| 635 | /*@ pure;
|
|---|
| 636 | @*/
|
|---|
| 637 | float fdimf(float x, float y);
|
|---|
| 638 | /*@ pure;
|
|---|
| 639 | @*/
|
|---|
| 640 | long double fdiml(long double x, long double y);
|
|---|
| 641 | /*@ pure;
|
|---|
| 642 | @*/
|
|---|
| 643 | double fmax(double x, double y);
|
|---|
| 644 | /*@ pure;
|
|---|
| 645 | @*/
|
|---|
| 646 | float fmaxf(float x, float y);
|
|---|
| 647 | /*@ pure;
|
|---|
| 648 | @*/
|
|---|
| 649 | long double fmaxl(long double x, long double y);
|
|---|
| 650 | /*@ pure;
|
|---|
| 651 | @*/
|
|---|
| 652 | double fmin(double x, double y);
|
|---|
| 653 | /*@ pure;
|
|---|
| 654 | @*/
|
|---|
| 655 | float fminf(float x, float y);
|
|---|
| 656 | /*@ pure;
|
|---|
| 657 | @*/
|
|---|
| 658 | long double fminl(long double x, long double y);
|
|---|
| 659 | /*@ pure;
|
|---|
| 660 | @*/
|
|---|
| 661 | double fma(double x, double y, double z);
|
|---|
| 662 | /*@ pure;
|
|---|
| 663 | @*/
|
|---|
| 664 | float fmaf(float x, float y, float z);
|
|---|
| 665 | /*@ pure;
|
|---|
| 666 | @*/
|
|---|
| 667 | long double fmal(long double x, long double y, long double z);
|
|---|
| 668 |
|
|---|
| 669 | // Comparison macros:
|
|---|
| 670 | #define isgreater(X,Y) ((X)>(Y))
|
|---|
| 671 | #define isgreaterequal(X,Y) ((X)>=(Y))
|
|---|
| 672 | #define isless(X,Y) ((X)<(Y))
|
|---|
| 673 | #define islessequal(X,Y) ((X)<=(Y))
|
|---|
| 674 | #define islessgreater(X,Y) ((X)<(Y))||((X)>(Y))
|
|---|
| 675 | #define isunordered(X,Y) (X>Y)?1:0
|
|---|
| 676 |
|
|---|
| 677 | #endif
|
|---|