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)

◆ approx_atan2f_P< 11 >()

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

Definition at line 71 of file approx_atan2.h.

References ALCARECOEcalPhiSym_cff::float, x, testProducerWithPsetDescEmpty_cfi::x1, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
float x

◆ approx_atan2f_P< 13 >()

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

◆ approx_atan2f_P< 15 >()

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

Definition at line 92 of file approx_atan2.h.

References ALCARECOEcalPhiSym_cff::float, x, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
float x

◆ approx_atan2f_P< 3 >()

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

Definition at line 42 of file approx_atan2.h.

References ALCARECOEcalPhiSym_cff::float, and x.

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

◆ approx_atan2f_P< 5 >()

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

◆ approx_atan2f_P< 7 >()

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

◆ approx_atan2f_P< 9 >()

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

◆ approx_atan2i_P()

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

◆ approx_atan2i_P< 11 >()

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

Definition at line 168 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
float x

◆ approx_atan2i_P< 13 >()

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

Definition at line 176 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
float x

◆ approx_atan2i_P< 15 >()

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

Definition at line 184 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
float x

◆ approx_atan2i_P< 3 >()

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

Definition at line 140 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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

◆ approx_atan2i_P< 5 >()

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

Definition at line 147 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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

◆ approx_atan2i_P< 7 >()

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

Definition at line 154 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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

◆ approx_atan2i_P< 9 >()

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

Definition at line 161 of file approx_atan2.h.

References x, and ctppsOpticalFunctions_non_DB_cff::z.

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

◆ approx_atan2s_P()

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

◆ approx_atan2s_P< 3 >()

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

Definition at line 220 of file approx_atan2.h.

References f, x, and ctppsOpticalFunctions_non_DB_cff::z.

220  {
221  auto z = x * x;
222  return x * ((-10142.439453125f) + z * 2002.0908203125f);
223 }
double f[11][100]
float x

◆ approx_atan2s_P< 5 >()

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

Definition at line 226 of file approx_atan2.h.

References f, x, and ctppsOpticalFunctions_non_DB_cff::z.

226  {
227  auto z = x * x;
228  return x * ((-10381.9609375f) + z * ((3011.1513671875f) + z * (-827.538330078125f)));
229 }
double f[11][100]
float x

◆ approx_atan2s_P< 7 >()

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

Definition at line 232 of file approx_atan2.h.

References f, x, and ctppsOpticalFunctions_non_DB_cff::z.

232  {
233  auto z = x * x;
234  return x * ((-10422.177734375f) + z * (3349.97412109375f + z * ((-1525.589599609375f) + z * 406.64190673828125f)));
235 }
double f[11][100]
float x

◆ approx_atan2s_P< 9 >()

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

Definition at line 238 of file approx_atan2.h.

References f, x, and ctppsOpticalFunctions_non_DB_cff::z.

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 }
double f[11][100]
float x

◆ int2dphi()

constexpr double int2dphi ( int  x)

◆ int2phi()

constexpr float int2phi ( int  x)

◆ phi2int()

constexpr int phi2int ( float  x)

◆ phi2short()

constexpr short phi2short ( float  x)

◆ safe_atan2f()

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

Definition at line 123 of file approx_atan2.h.

References f, x, and detailsBasic3DVector::y.

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 }
double f[11][100]
float x

◆ short2phi()

constexpr float short2phi ( short  x)

◆ unsafe_atan2f()

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

Definition at line 118 of file approx_atan2.h.

References x, and detailsBasic3DVector::y.

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

◆ unsafe_atan2f_impl()

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

Definition at line 103 of file approx_atan2.h.

References funct::abs(), angle(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), alignCSCRings::r, x, and detailsBasic3DVector::y.

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ unsafe_atan2i()

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

Definition at line 209 of file approx_atan2.h.

References x, and detailsBasic3DVector::y.

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

◆ unsafe_atan2i_impl()

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

Definition at line 192 of file approx_atan2.h.

References funct::abs(), angle(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), createfilelist::int, L1DTConfigBti_cff::LL, WZElectronSkims53X_cff::max, alignCSCRings::r, x, and detailsBasic3DVector::y.

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ unsafe_atan2s()

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

Definition at line 261 of file approx_atan2.h.

References x, and detailsBasic3DVector::y.

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

◆ unsafe_atan2s_impl()

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

Definition at line 245 of file approx_atan2.h.

References funct::abs(), angle(), ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), createfilelist::int, WZElectronSkims53X_cff::max, alignCSCRings::r, x, and detailsBasic3DVector::y.

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float x
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11