Skip to content

Commit bca0a30

Browse files
committed
ITS: constexpr computePhi
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent babe031 commit bca0a30

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

Common/MathUtils/include/MathUtils/Utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,12 @@ inline double angle2Alphad(double phi)
210210
return detail::angle2Alpha<double>(phi);
211211
}
212212

213-
GPUhdi() float fastATan2(float y, float x)
213+
GPUhdi() constexpr float fastATan2(float y, float x)
214214
{
215215
return detail::fastATan2<float>(y, x);
216216
}
217217

218-
GPUhdi() double fastATan2d(double y, double x)
218+
GPUhdi() constexpr double fastATan2d(double y, double x)
219219
{
220220
return detail::fastATan2<double>(y, x);
221221
}

Common/MathUtils/include/MathUtils/detail/basicMath.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace detail
3434
{
3535

3636
template <typename T>
37-
GPUhdi() T copysign(T x, T y)
37+
GPUhdi() constexpr T copysign(T x, T y)
3838
{
3939
return o2::gpu::GPUCommonMath::Copysign(x, y);
4040
}

Common/MathUtils/include/MathUtils/detail/trigonometric.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ GPUhdi() constexpr T deltaPhiSmall(T phi0, T phi1)
269269
}
270270

271271
template <typename T>
272-
GPUhdi() T fastATan2(T y, T x)
272+
GPUhdi() constexpr T fastATan2(T y, T x)
273273
{
274274
// Fast atan2(y,x) for any angle [-Pi,Pi]
275275
// Average inaccuracy: 0.00048
@@ -283,7 +283,7 @@ GPUhdi() T fastATan2(T y, T x)
283283
// https://stackoverflow.com/questions/42537957/fast-accurate-atan-arctan-approximation-algorithm
284284
constexpr T A = 0.0776509570923569;
285285
constexpr T B = -0.287434475393028;
286-
constexpr T C = (Pi / 4 - A - B);
286+
constexpr T C = ((Pi / 4) - A - B);
287287
const T a2 = a * a;
288288
return ((A * a2 + B) * a2 + C) * a;
289289
};

Detectors/ITSMFT/ITS/tracking/include/ITStracking/MathUtils.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#ifndef O2_ITS_TRACKING_MATHUTILS_H_
1717
#define O2_ITS_TRACKING_MATHUTILS_H_
1818

19-
#include <cstdint>
20-
2119
#include "CommonConstants/MathConstants.h"
2220
#include "ITStracking/Constants.h"
2321
#include "MathUtils/Utils.h"
@@ -27,7 +25,7 @@
2725
namespace o2::its::math_utils
2826
{
2927

30-
GPUhdi() float computePhi(float x, float y)
28+
GPUhdi() constexpr float computePhi(float x, float y)
3129
{
3230
return o2::math_utils::fastATan2(-y, -x) + o2::constants::math::PI;
3331
}

0 commit comments

Comments
 (0)