Permalink
Cannot retrieve contributors at this time
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?
mathLibs/mathutils.h
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
75 lines (61 sloc)
1.31 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |