3 #define MATHUTIL_H "Mathutil.h"
5 #define SQR(x) ((x)*(x))
7 #define SQRT(x) sqrt((x))
13 inline int max(
int x1,
int x2 ){
return x1>x2 ? x1 : x2; }
14 inline int max(
int x1,
unsigned int x2) {
return (
unsigned int)x1>x2 ? x1 : x2; }
15 inline int max(
unsigned int x1,
int x2) {
return x1>(
unsigned int)x2 ? x1 : x2; }
18 inline int max(
unsigned long x1,
int x2) {
return x1>x2 ? x1 : x2; }
19 inline int max(
int x1,
unsigned long x2) {
return x1>x2 ? x1 : x2; }
21 inline double max(
int x1,
double x2 ){
return x1>x2 ? x1 : x2; }
22 inline double max(
double x1,
int x2 ){
return x1>x2 ? x1 : x2; }
23 inline float max(
int x1,
float x2 ){
return x1>x2 ? x1 : x2; }
24 inline float max(
float x1,
int x2 ){
return x1>x2 ? x1 : x2; }
26 inline float max(
float x1,
float x2 ){
return x1>x2 ? x1 : x2; }
28 inline double max(
double x1,
double x2 ){
return x1>x2 ? x1 : x2; }
30 inline double max(
float x1,
double x2 ){
return x1>x2 ? double(x1) : x2; }
32 inline double max(
double x1,
float x2 ){
return x1>x2 ? x1 : double(x2); }
35 inline int min(
int x1,
int x2 ){
return x1<x2 ? x1 : x2; }
38 inline float min(
float x1,
float x2 ){
return x1<x2 ? x1 : x2; }
40 inline double min(
double x1,
double x2 ){
return x1<x2 ? x1 : x2; }
42 inline double min(
float x1,
double x2 ){
return x1<x2 ? double(x1) : x2; }
44 inline double min(
double x1,
float x2 ){
return x1<x2 ? x1 : double(x2); }
49 inline int max(
int x1,
int x2,
int x3 ){
return max(x1,
max(x2,x3)); }
50 inline int max(
int x1,
int x2,
int x3,
int x4 ){
return max(x1,
max(x2,x3,x4));}
51 inline int max(
int x1,
int x2,
int x3,
int x4,
int x5 )
52 {
return max(x1,
max(x2,x3,x4,x5));}
54 inline float max(
float x1,
float x2,
float x3 ){
return max(x1,
max(x2,x3)); }
55 inline float max(
float x1,
float x2,
float x3,
float x4 )
56 {
return max(x1,
max(x2,x3,x4));}
57 inline float max(
float x1,
float x2,
float x3,
float x4,
float x5 )
58 {
return max(x1,
max(x2,x3,x4,x5));}
60 inline double max(
double x1,
double x2,
double x3 ){
return max(x1,
max(x2,x3)); }
61 inline double max(
double x1,
double x2,
double x3,
double x4 )
62 {
return max(x1,
max(x2,x3,x4));}
63 inline double max(
double x1,
double x2,
double x3,
double x4,
double x5 )
64 {
return max(x1,
max(x2,x3,x4,x5));}
66 inline int min(
int x1,
int x2,
int x3 ){
return min(x1,
min(x2,x3)); }
67 inline int min(
int x1,
int x2,
int x3,
int x4 ){
return min(x1,
min(x2,x3,x4));}
68 inline int min(
int x1,
int x2,
int x3,
int x4,
int x5 )
69 {
return min(x1,
min(x2,x3,x4,x5));}
71 inline float min(
float x1,
float x2,
float x3 ){
return min(x1,
min(x2,x3)); }
72 inline float min(
float x1,
float x2,
float x3,
float x4 )
73 {
return min(x1,
min(x2,x3,x4));}
74 inline float min(
float x1,
float x2,
float x3,
float x4,
float x5 )
75 {
return min(x1,
min(x2,x3,x4,x5));}
77 inline double min(
double x1,
double x2,
double x3 ){
return min(x1,
min(x2,x3)); }
78 inline double min(
double x1,
double x2,
double x3,
double x4 )
79 {
return min(x1,
min(x2,x3,x4));}
80 inline double min(
double x1,
double x2,
double x3,
double x4,
double x5 )
81 {
return min(x1,
min(x2,x3,x4,x5));}
85 inline int rounder(
double x ){
return x>0 ? int(x+.5) : int(x-.5); }
92 inline float pow(
float x1,
int x2 ){
return x2==0 ? 1 :
pow(
double(x1),
double(x2)); }
93 inline double pow(
double x1,
int x2 ){
return x2==0 ? 1 :
pow(x1,
double(x2)); }
99 inline float pow(
float &x1,
int x2 ){
return x2==0 ? 1 :
pow(
double(x1),
double(x2)); }
101 inline double pow(
double &x1,
int x2 ){
return x2==0 ? 1 :
pow(x1,
double(x2)); }
104 inline double pow(
real &x1,
int x2) {
return x2==0 ? 1 :
pow(x1,
real(x2)); }
106 inline float pow(
const float &x1,
int x2 ){
return x2==0 ? 1 :
pow(
double(x1),
double(x2)); }
107 inline double pow(
const double &x1,
int x2 ){
return x2==0 ? 1 :
pow(x1,
double(x2)); }
110 inline double pow(
float x1,
double x2 ){
return pow(
double(x1),x2); }
111 inline double pow(
double x1,
float x2 ){
return pow(x1,
double(x2)); }
112 inline float pow(
float x1,
float x2 ){
return pow(
double(x1),
double(x2)); }
113 inline double pow(
double x1,
int x2 ){
return x2==0 ? 1 :
pow(x1,
double(x2)); }
115 inline double pow(
int x1,
int x2 ){
return x2>0 ?
rounder(
pow(
double(x1),
double(x2))) :
pow(double(x1),double(x2)); }
117 inline double pow(
int x1,
int x2 ){
return x2>0 ?
rounder(
pow(
double(x1),
double(x2))) :
pow(double(x1),double(x2)); }
124 inline double pow(
int x1,
int x2 ){
return x2>0 ?
rounder(
pow(
double(x1),
double(x2))) :
pow(
double(x1),
double(x2)); }
127 inline double sqrt(
int x) {
return sqrt(
double(x)); }
131 inline float atan2(
float x1,
float x2 ){
return atan2(
double(x1),
double(x2)); }
133 inline float atan2(
double x1,
float x2 ){
return atan2(
double(x1),
double(x2)); }
134 inline float atan2(
float x1,
double x2 ){
return atan2(
double(x1),
double(x2)); }
135 inline float fmod(
float x1,
float x2 ){
return fmod(
double(x1),
double(x2)); }
136 inline float fmod(
double x1,
float x2 ){
return fmod(
double(x1),
double(x2)); }
137 inline float fmod(
float x1,
double x2 ){
return fmod(
double(x1),
double(x2)); }
139 inline int sign(
int x ) {
return x>0 ? 1 : ( x<0 ? -1 : 0);}
140 inline int sign(
float x ) {
return x>0 ? 1 : ( x<0 ? -1 : 0);}
141 inline int sign(
double x ) {
return x>0 ? 1 : ( x<0 ? -1 : 0);}
146 inline double log(
int x ){
return log((
double)x); }
149 inline double fabs(
int x ){
return fabs((
double)x); }
162 return (numer-denom+1)/denom;
166 #define ARRAY_GET_DATA_POINTER(type,aType) \
167 inline type* getDataPointer(const aType ## Array & u) \
169 return u.Array_Descriptor.Array_View_Pointer3+ \
170 u.getBase(0)+u.getRawDataSize(0)*( \
171 u.getBase(1)+u.getRawDataSize(1)*( \
172 u.getBase(2)+u.getRawDataSize(2)*(u.getBase(3)))); \
187 #undef ARRAY_GET_DATA_POINTER
188 #endif // ifndef NO_APP