www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

math.h (762B)


      1 #ifndef ALGO_MATH_MATH_H
      2 #define ALGO_MATH_MATH_H
      3 
      4 #include <types.h>
      5 
      6 #define max(a, b) (((a) > (b)) ? (a) : (b))
      7 
      8 #define min(a, b) (((a) < (b)) ? (a) : (b))
      9 
     10 #define abs(x) (((x) >= 0) ? (x) : -(x))
     11 
     12 #define sign(x) (((x) >= 0) \
     13                     ? (((x) == 0) ? 0 : 1) \
     14                     : -1)
     15 
     16 #define sinRapide_(a, sgn) ((((a) * 4) \
     17                            - ((a)*(a) >> 13)) \
     18 					       * sgn)
     19 
     20 #define sinRapide(a) sinRapide_(abs((int32)(a)) % 32768, (((a) & 32768) ? 1 : -1))
     21 
     22 #define cosRapide(a) sinRapide((a)+16384)
     23 
     24 #define clip(x, min_, max_) min(max_, max((x),min_))
     25 
     26 typedef struct Div64 {
     27 	uint64 quotient;
     28 	uint64 reste;
     29 } Div64;
     30 
     31 typedef struct EtatMath {
     32 } EtatMath;
     33 
     34 Div64 div64 (uint64 numerateur, uint64 denominateur);
     35 
     36 #endif