Skip to content
Permalink
47f19ae668
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
75 lines (61 sloc) 1.31 KB
#ifndef _MATHUTILS_H
#define _MATHUTILS_H
#define ABS(x) ((x < 0) ? -(x) : (x))
#define LITTLE_ENDIAN
#ifdef LITTLE_ENDIAN
typedef union split_double{
double d;
struct split_bits{
unsigned long j,i;
}bits;
}split_d;
typedef union ieee754_f{
float f;
struct float_bits{
unsigned long mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
}bits;
}ieee_f;
typedef union ieee754_d{
float d;
struct double_bits{
unsigned long long mantissa:52;
unsigned int exponent:11;
unsigned int sign:1;
}bits;
}ieee_d;
#else
typedef union split_double{
double d;
struct split_bits{
unsigned long i,j;
}bits;
}split_d;
typedef union ieee754_f{
float f;
struct float_bits{
unsigned int sign:1;
unsigned int exponent:8;
unsigned long mantissa:23;
}bits;
}ieee_f;
typedef union ieee754_d{
double d;
struct double_bits{
unsigned int sign:1;
unsigned int exponent:11;
unsigned long long mantissa:52;
}bits;
}ieee_d;
#endif
float sqrtf(float x);
float newton_sqrtf(float x);
double fast_dpowe(double y);
double taylor_dpowe(double y);
double taylor_dsinh(double y);
double taylor_dcosh(double y);
double taylor_dtanh(double y);
void seed_MT19937(int seed);
int rand_MT19937();
#endif