CMS 3D CMS Logo

Functions
approx_atan2.h File Reference
#include <cstdint>
#include <cmath>
#include <limits>
#include <algorithm>

Go to the source code of this file.

Functions

template<int DEGREE>
constexpr float approx_atan2f_P (float x)
 
template<>
constexpr float approx_atan2f_P< 11 > (float x)
 
template<>
constexpr float approx_atan2f_P< 13 > (float x)
 
template<>
constexpr float approx_atan2f_P< 15 > (float x)
 
template<>
constexpr float approx_atan2f_P< 3 > (float x)
 
template<>
constexpr float approx_atan2f_P< 5 > (float x)
 
template<>
constexpr float approx_atan2f_P< 7 > (float x)
 
template<>
constexpr float approx_atan2f_P< 9 > (float x)
 
template<int DEGREE>
constexpr float approx_atan2i_P (float x)
 
template<>
constexpr float approx_atan2i_P< 11 > (float x)
 
template<>
constexpr float approx_atan2i_P< 13 > (float x)
 
template<>
constexpr float approx_atan2i_P< 15 > (float x)
 
template<>
constexpr float approx_atan2i_P< 3 > (float x)
 
template<>
constexpr float approx_atan2i_P< 5 > (float x)
 
template<>
constexpr float approx_atan2i_P< 7 > (float x)
 
template<>
constexpr float approx_atan2i_P< 9 > (float x)
 
template<int DEGREE>
constexpr float approx_atan2s_P (float x)
 
template<>
constexpr float approx_atan2s_P< 3 > (float x)
 
template<>
constexpr float approx_atan2s_P< 5 > (float x)
 
template<>
constexpr float approx_atan2s_P< 7 > (float x)
 
template<>
constexpr float approx_atan2s_P< 9 > (float x)
 
constexpr double int2dphi (int x)
 
constexpr float int2phi (int x)
 
constexpr int phi2int (float x)
 
constexpr short phi2short (float x)
 
template<int DEGREE>
constexpr float safe_atan2f (float y, float x)
 
constexpr float short2phi (short x)
 
template<int DEGREE>
constexpr float unsafe_atan2f (float y, float x)
 
template<int DEGREE>
constexpr float unsafe_atan2f_impl (float y, float x)
 
template<int DEGREE>
constexpr int unsafe_atan2i (float y, float x)
 
template<int DEGREE>
constexpr int unsafe_atan2i_impl (float y, float x)
 
template<int DEGREE>
constexpr short unsafe_atan2s (float y, float x)
 
template<int DEGREE>
constexpr short unsafe_atan2s_impl (float y, float x)
 

Function Documentation

◆ approx_atan2f_P()

template<int DEGREE>
constexpr float approx_atan2f_P ( float  x)
constexpr

◆ approx_atan2f_P< 11 >()

template<>
constexpr float approx_atan2f_P< 11 > ( float  x)
constexpr

Definition at line 71 of file approx_atan2.h.

71  {
72  auto z = x * x;
73  return x * (float(-0xf.ffe82p-4) +
74  z * (float(0x5.526c8p-4) +
75  z * (float(-0x3.18bea8p-4) +
76  z * (float(0x1.dce3bcp-4) + z * (float(-0xd.7a64ap-8) + z * float(0x3.000eap-8))))));
77 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, and detailsBasic3DVector::z.

◆ approx_atan2f_P< 13 >()

template<>
constexpr float approx_atan2f_P< 13 > ( float  x)
constexpr

Definition at line 81 of file approx_atan2.h.

81  {
82  auto z = x * x;
83  return x * (float(-0xf.fffbep-4) +
84  z * (float(0x5.54adp-4) +
85  z * (float(-0x3.2b4df8p-4) +
86  z * (float(0x2.1df79p-4) +
87  z * (float(-0x1.46081p-4) + z * (float(0x8.99028p-8) + z * float(-0x1.be0bc4p-8)))))));
88 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and detailsBasic3DVector::z.

◆ approx_atan2f_P< 15 >()

template<>
constexpr float approx_atan2f_P< 15 > ( float  x)
constexpr

Definition at line 92 of file approx_atan2.h.

92  {
93  auto z = x * x;
94  return x * (float(-0xf.ffff4p-4) +
95  z * (float(0x5.552f9p-4 + z * (float(-0x3.30f728p-4) +
96  z * (float(0x2.39826p-4) +
97  z * (float(-0x1.8a880cp-4) +
98  z * (float(0xe.484d6p-8) +
99  z * (float(-0x5.93d5p-8) + z * float(0x1.0875dcp-8)))))))));
100 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and detailsBasic3DVector::z.

◆ approx_atan2f_P< 3 >()

template<>
constexpr float approx_atan2f_P< 3 > ( float  x)
constexpr

Definition at line 42 of file approx_atan2.h.

42  {
43  return x * (float(-0xf.8eed2p-4) + x * x * float(0x3.1238p-4));
44 }

References dqmMemoryStats::float, and genVertex_cff::x.

◆ approx_atan2f_P< 5 >()

template<>
constexpr float approx_atan2f_P< 5 > ( float  x)
constexpr

Definition at line 48 of file approx_atan2.h.

48  {
49  auto z = x * x;
50  return x * (float(-0xf.ecfc8p-4) + z * (float(0x4.9e79dp-4) + z * float(-0x1.44f924p-4)));
51 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, and detailsBasic3DVector::z.

◆ approx_atan2f_P< 7 >()

template<>
constexpr float approx_atan2f_P< 7 > ( float  x)
constexpr

Definition at line 55 of file approx_atan2.h.

55  {
56  auto z = x * x;
57  return x * (float(-0xf.fcc7ap-4) + z * (float(0x5.23886p-4) + z * (float(-0x2.571968p-4) + z * float(0x9.fb05p-8))));
58 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x2, and detailsBasic3DVector::z.

◆ approx_atan2f_P< 9 >()

template<>
constexpr float approx_atan2f_P< 9 > ( float  x)
constexpr

Definition at line 62 of file approx_atan2.h.

62  {
63  auto z = x * x;
64  return x * (float(-0xf.ff73ep-4) +
65  z * (float(0x5.48ee1p-4) +
66  z * (float(-0x2.e1efe8p-4) + z * (float(0x1.5cce54p-4) + z * float(-0x5.56245p-8)))));
67 }

References dqmMemoryStats::float, genVertex_cff::x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and detailsBasic3DVector::z.

◆ approx_atan2i_P()

template<int DEGREE>
constexpr float approx_atan2i_P ( float  x)
constexpr

◆ approx_atan2i_P< 11 >()

template<>
constexpr float approx_atan2i_P< 11 > ( float  x)
constexpr

Definition at line 168 of file approx_atan2.h.

168  {
169  auto z = x * x;
170  return x *
171  (-683549696.f + z * (227369312.f + z * (-132297008.f + z * (79584144.f + z * (-35987016.f + z * 8010488.f)))));
172 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 13 >()

template<>
constexpr float approx_atan2i_P< 13 > ( float  x)
constexpr

Definition at line 176 of file approx_atan2.h.

176  {
177  auto z = x * x;
178  return x * (-683562624.f +
179  z * (227746080.f +
180  z * (-135400128.f + z * (90460848.f + z * (-54431464.f + z * (22973256.f + z * (-4657049.f)))))));
181 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 15 >()

template<>
constexpr float approx_atan2i_P< 15 > ( float  x)
constexpr

Definition at line 184 of file approx_atan2.h.

184  {
185  auto z = x * x;
186  return x * (-683562624.f +
187  z * (227746080.f +
188  z * (-135400128.f + z * (90460848.f + z * (-54431464.f + z * (22973256.f + z * (-4657049.f)))))));
189 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 3 >()

template<>
constexpr float approx_atan2i_P< 3 > ( float  x)
constexpr

Definition at line 140 of file approx_atan2.h.

140  {
141  auto z = x * x;
142  return x * (-664694912.f + z * 131209024.f);
143 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 5 >()

template<>
constexpr float approx_atan2i_P< 5 > ( float  x)
constexpr

Definition at line 147 of file approx_atan2.h.

147  {
148  auto z = x * x;
149  return x * (-680392064.f + z * (197338400.f + z * (-54233256.f)));
150 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 7 >()

template<>
constexpr float approx_atan2i_P< 7 > ( float  x)
constexpr

Definition at line 154 of file approx_atan2.h.

154  {
155  auto z = x * x;
156  return x * (-683027840.f + z * (219543904.f + z * (-99981040.f + z * 26649684.f)));
157 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2i_P< 9 >()

template<>
constexpr float approx_atan2i_P< 9 > ( float  x)
constexpr

Definition at line 161 of file approx_atan2.h.

161  {
162  auto z = x * x;
163  return x * (-683473920.f + z * (225785056.f + z * (-123151184.f + z * (58210592.f + z * (-14249276.f)))));
164 }

References genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2s_P()

template<int DEGREE>
constexpr float approx_atan2s_P ( float  x)
constexpr

◆ approx_atan2s_P< 3 >()

template<>
constexpr float approx_atan2s_P< 3 > ( float  x)
constexpr

Definition at line 220 of file approx_atan2.h.

220  {
221  auto z = x * x;
222  return x * ((-10142.439453125f) + z * 2002.0908203125f);
223 }

References f, genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2s_P< 5 >()

template<>
constexpr float approx_atan2s_P< 5 > ( float  x)
constexpr

Definition at line 226 of file approx_atan2.h.

226  {
227  auto z = x * x;
228  return x * ((-10381.9609375f) + z * ((3011.1513671875f) + z * (-827.538330078125f)));
229 }

References f, genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2s_P< 7 >()

template<>
constexpr float approx_atan2s_P< 7 > ( float  x)
constexpr

Definition at line 232 of file approx_atan2.h.

232  {
233  auto z = x * x;
234  return x * ((-10422.177734375f) + z * (3349.97412109375f + z * ((-1525.589599609375f) + z * 406.64190673828125f)));
235 }

References f, genVertex_cff::x, and detailsBasic3DVector::z.

◆ approx_atan2s_P< 9 >()

template<>
constexpr float approx_atan2s_P< 9 > ( float  x)
constexpr

Definition at line 238 of file approx_atan2.h.

238  {
239  auto z = x * x;
240  return x * ((-10428.984375f) + z * (3445.20654296875f + z * ((-1879.137939453125f) +
241  z * (888.22314453125f + z * (-217.42669677734375f)))));
242 }

References f, genVertex_cff::x, and detailsBasic3DVector::z.

◆ int2dphi()

constexpr double int2dphi ( int  x)
constexpr

Definition at line 275 of file approx_atan2.h.

275  {
276  constexpr double i2p = M_PI / ((long long)(std::numeric_limits<int>::max()) + 1LL);
277  return x * i2p;
278 }

References L1DTConfigBti_cff::LL, M_PI, SiStripPI::max, and genVertex_cff::x.

◆ int2phi()

constexpr float int2phi ( int  x)
constexpr

Definition at line 270 of file approx_atan2.h.

270  {
271  constexpr float i2p = M_PI / ((long long)(std::numeric_limits<int>::max()) + 1LL);
272  return float(x) * i2p;
273 }

References dqmMemoryStats::float, L1DTConfigBti_cff::LL, M_PI, SiStripPI::max, and genVertex_cff::x.

◆ phi2int()

constexpr int phi2int ( float  x)
constexpr

Definition at line 265 of file approx_atan2.h.

265  {
266  constexpr float p2i = ((long long)(std::numeric_limits<int>::max()) + 1LL) / M_PI;
267  return std::round(x * p2i);
268 }

References L1DTConfigBti_cff::LL, M_PI, SiStripPI::max, and genVertex_cff::x.

◆ phi2short()

constexpr short phi2short ( float  x)
constexpr

Definition at line 280 of file approx_atan2.h.

280  {
281  constexpr float p2i = ((int)(std::numeric_limits<short>::max()) + 1) / M_PI;
282  return std::round(x * p2i);
283 }

References createfilelist::int, M_PI, SiStripPI::max, and genVertex_cff::x.

◆ safe_atan2f()

template<int DEGREE>
constexpr float safe_atan2f ( float  y,
float  x 
)
constexpr

Definition at line 123 of file approx_atan2.h.

123  {
124  return unsafe_atan2f_impl<DEGREE>(y, ((y == 0.f) & (x == 0.f)) ? 0.2f : x);
125  // return (y==0.f)&(x==0.f) ? 0.f : unsafe_atan2f_impl<DEGREE>( y, x);
126 }

References f, genVertex_cff::x, and detailsBasic3DVector::y.

◆ short2phi()

constexpr float short2phi ( short  x)
constexpr

Definition at line 285 of file approx_atan2.h.

285  {
286  constexpr float i2p = M_PI / ((int)(std::numeric_limits<short>::max()) + 1);
287  return float(x) * i2p;
288 }

References dqmMemoryStats::float, createfilelist::int, M_PI, SiStripPI::max, and genVertex_cff::x.

◆ unsafe_atan2f()

template<int DEGREE>
constexpr float unsafe_atan2f ( float  y,
float  x 
)
constexpr

Definition at line 118 of file approx_atan2.h.

118  {
119  return unsafe_atan2f_impl<DEGREE>(y, x);
120 }

References genVertex_cff::x, and detailsBasic3DVector::y.

◆ unsafe_atan2f_impl()

template<int DEGREE>
constexpr float unsafe_atan2f_impl ( float  y,
float  x 
)
constexpr

Definition at line 103 of file approx_atan2.h.

103  {
104  constexpr float pi4f = 3.1415926535897932384626434 / 4;
105  constexpr float pi34f = 3.1415926535897932384626434 * 3 / 4;
106 
107  auto r = (std::abs(x) - std::abs(y)) / (std::abs(x) + std::abs(y));
108  if (x < 0)
109  r = -r;
110 
111  auto angle = (x >= 0) ? pi4f : pi34f;
112  angle += approx_atan2f_P<DEGREE>(r);
113 
114  return ((y < 0)) ? -angle : angle;
115 }

References funct::abs(), angle(), alignCSCRings::r, genVertex_cff::x, and detailsBasic3DVector::y.

◆ unsafe_atan2i()

template<int DEGREE>
constexpr int unsafe_atan2i ( float  y,
float  x 
)
constexpr

Definition at line 209 of file approx_atan2.h.

209  {
210  return unsafe_atan2i_impl<DEGREE>(y, x);
211 }

References genVertex_cff::x, and detailsBasic3DVector::y.

◆ unsafe_atan2i_impl()

template<int DEGREE>
constexpr int unsafe_atan2i_impl ( float  y,
float  x 
)
constexpr

Definition at line 192 of file approx_atan2.h.

192  {
193  constexpr long long maxint = (long long)(std::numeric_limits<int>::max()) + 1LL;
194  constexpr int pi4 = int(maxint / 4LL);
195  constexpr int pi34 = int(3LL * maxint / 4LL);
196 
197  auto r = (std::abs(x) - std::abs(y)) / (std::abs(x) + std::abs(y));
198  if (x < 0)
199  r = -r;
200 
201  auto angle = (x >= 0) ? pi4 : pi34;
202  angle += int(approx_atan2i_P<DEGREE>(r));
203  // angle += int(std::round(approx_atan2i_P<DEGREE>(r)));
204 
205  return (y < 0) ? -angle : angle;
206 }

References funct::abs(), angle(), createfilelist::int, L1DTConfigBti_cff::LL, SiStripPI::max, alignCSCRings::r, genVertex_cff::x, and detailsBasic3DVector::y.

◆ unsafe_atan2s()

template<int DEGREE>
constexpr short unsafe_atan2s ( float  y,
float  x 
)
constexpr

Definition at line 261 of file approx_atan2.h.

261  {
262  return unsafe_atan2s_impl<DEGREE>(y, x);
263 }

References genVertex_cff::x, and detailsBasic3DVector::y.

◆ unsafe_atan2s_impl()

template<int DEGREE>
constexpr short unsafe_atan2s_impl ( float  y,
float  x 
)
constexpr

Definition at line 245 of file approx_atan2.h.

245  {
246  constexpr int maxshort = (int)(std::numeric_limits<short>::max()) + 1;
247  constexpr short pi4 = short(maxshort / 4);
248  constexpr short pi34 = short(3 * maxshort / 4);
249 
250  auto r = (std::abs(x) - std::abs(y)) / (std::abs(x) + std::abs(y));
251  if (x < 0)
252  r = -r;
253 
254  auto angle = (x >= 0) ? pi4 : pi34;
255  angle += short(approx_atan2s_P<DEGREE>(r));
256 
257  return (y < 0) ? -angle : angle;
258 }

References funct::abs(), angle(), createfilelist::int, SiStripPI::max, alignCSCRings::r, genVertex_cff::x, and detailsBasic3DVector::y.

dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
detailsBasic3DVector::z
float float float z
Definition: extBasic3DVector.h:14
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
alignCSCRings.r
r
Definition: alignCSCRings.py:93
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
genVertex_cff.x
x
Definition: genVertex_cff.py:12
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22