1 #ifndef DataFormats_Math_FastMath_h
2 #define DataFormats_Math_FastMath_h
16 _mm_store_ss(&
out, _mm_rsqrt_ss(_mm_load_ss(&
in)));
27 const double _2pi = (2.0 * 3.1415926535897932384626434);
38 inline std::pair<float, float>
atan2r(
float y_,
float x_,
bool overR =
false) {
40 float mag2 = x_ * x_ + y_ * y_;
42 return std::pair<float, float>(0.
f, 0.
f);
47 unsigned int flags = 0;
72 int ind = (yp.i & 0x01FF) * 2;
74 float* asbuf = (
float*)(
atanbuf_ + ind);
75 float sv = yp.f - 32768.f;
80 float asvd = 6.f +
sv *
sv;
82 float th = asv + asvd *
sv;
84 th = (
_2pif / 4.f) - th;
87 th = (
_2pif / 2.f) - th;
92 return std::pair<float, float>(th, overR ?
rinv :
rinv *
mag2);
98 inline std::pair<double, double>
atan2r(
double y_,
double x_,
bool overR =
false) {
101 double mag2 = x_ * x_ + y_ * y_;
103 return std::pair<double, double>(0., 0.);
107 double rinv = 1. / r_;
108 unsigned int flags = 0;
110 const double _2p43 = 65536.0 * 65536.0 * 2048.0;
136 int ind = (yp.i[0] & 0x03FF) * 2;
138 double* dasbuf = (
double*)(
datanbuf_ + ind);
139 double sv = yp.d - _2p43;
140 double cv = dasbuf[0];
141 double asv = dasbuf[1];
145 double asvd = 6 +
sv *
sv;
146 sv *= double(1.0 / 6.0);
147 double th = asv + asvd *
sv;
149 th = (
_2pi / 4) - th;
152 th = (
_2pi / 2) - th;
157 return std::pair<double, double>(th, overR ?
rinv : r_);
161 template <
typename T>
163 std::pair<T, T> por =
atan2r(y, x,
true);