equal
deleted
inserted
replaced
25 */ |
25 */ |
26 |
26 |
27 #ifndef COMMON_H |
27 #ifndef COMMON_H |
28 #define COMMON_H |
28 #define COMMON_H |
29 |
29 |
|
30 #include "config.h" |
|
31 |
30 #include <stdio.h> |
32 #include <stdio.h> |
31 #include <stdarg.h> |
33 #include <stdarg.h> |
|
34 #include <math.h> |
32 #include <float.h> |
35 #include <float.h> |
33 #include <pthread.h> |
36 #include <pthread.h> |
34 #include <string> |
37 #include <string> |
35 |
38 |
36 using namespace std; |
39 using namespace std; |
39 # define Float double |
42 # define Float double |
40 # define Eps DBL_EPSILON |
43 # define Eps DBL_EPSILON |
41 # define Inf DBL_MAX |
44 # define Inf DBL_MAX |
42 #else |
45 #else |
43 # define Float float |
46 # define Float float |
44 # define Eps 1e-6 |
47 # define Eps 1e-6f |
45 # define Inf FLT_MAX |
48 # define Inf FLT_MAX |
46 #endif |
49 #endif |
47 |
50 |
48 #ifndef NO_SSE |
51 // enable M_* constants in MSVC |
49 // SSE intrinsics |
52 #define _USE_MATH_DEFINES |
50 #include <xmmintrin.h> |
|
51 |
|
52 const __m128 mZero = _mm_set_ps1(0.); |
|
53 const __m128 mOne = _mm_set_ps1(1.); |
|
54 const __m128 mTwo = _mm_set_ps1(2.); |
|
55 const __m128 mEps = _mm_set_ps1(Eps); |
|
56 const __m128 mMEps = _mm_set_ps1(-Eps); |
|
57 const __m128 mInf = _mm_set_ps1(Inf); |
|
58 const __m128 mAllSet = _mm_cmplt_ps(mZero, mOne); |
|
59 |
|
60 inline const __m128 _mm_fastpow(const __m128& base, const __m128& exponent) |
|
61 { |
|
62 __m128 denom = _mm_mul_ps( exponent, base); |
|
63 denom = _mm_sub_ps( exponent, denom); |
|
64 denom = _mm_add_ps( base, denom); |
|
65 return _mm_mul_ps( base, _mm_rcp_ps(denom)); |
|
66 } |
|
67 #endif |
|
68 |
53 |
69 /* verbosity level: |
54 /* verbosity level: |
70 0: only errors (E) |
55 0: only errors (E) |
71 1: major status messages (*) |
56 1: major status messages (*) |
72 2: minor status, progress (-) |
57 2: minor status, progress (-) |