Skip to content
Merged
26 changes: 14 additions & 12 deletions Common/MathUtils/include/MathUtils/CartesianGPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,34 @@
#ifndef ALICEO2_CARTESIANGPU_H
#define ALICEO2_CARTESIANGPU_H

#include "GPUCommonDef.h"

namespace o2::math_utils
{

namespace detail
{
template <typename T, int I>
struct GPUPoint2D {
GPUPoint2D() = default;
GPUPoint2D(T a, T b) : xx(a), yy(b) {}
GPUdDefault() GPUPoint2D() = default;
GPUd() GPUPoint2D(T a, T b) : xx(a), yy(b) {}
GPUd() float X() const { return xx; }
GPUd() float Y() const { return yy; }
GPUd() float R() const { return o2::gpu::CAMath::Sqrt(xx * xx + yy * yy); }
GPUd() void SetX(float v) { xx = v; }
GPUd() void SetY(float v) { yy = v; }
T xx;
T yy;
float X() const { return xx; }
float Y() const { return yy; }
float R() const { return o2::gpu::CAMath::Sqrt(xx * xx + yy * yy); }
void SetX(float v) { xx = v; }
void SetY(float v) { yy = v; }
};

template <typename T, int I>
struct GPUPoint3D : public GPUPoint2D<T, I> {
GPUPoint3D() = default;
GPUPoint3D(T a, T b, T c) : GPUPoint2D<T, I>(a, b), zz(c) {}
GPUdDefault() GPUPoint3D() = default;
GPUd() GPUPoint3D(T a, T b, T c) : GPUPoint2D<T, I>(a, b), zz(c) {}
GPUd() float Z() const { return zz; }
GPUd() float R() const { return o2::gpu::CAMath::Sqrt(GPUPoint2D<T, I>::xx * GPUPoint2D<T, I>::xx + GPUPoint2D<T, I>::yy * GPUPoint2D<T, I>::yy + zz * zz); }
GPUd() void SetZ(float v) { zz = v; }
T zz;
float Z() const { return zz; }
float R() const { return o2::gpu::CAMath::Sqrt(GPUPoint2D<T, I>::xx * GPUPoint2D<T, I>::xx + GPUPoint2D<T, I>::yy * GPUPoint2D<T, I>::yy + zz * zz); }
void SetZ(float v) { zz = v; }
};
} // namespace detail

Expand Down
9 changes: 5 additions & 4 deletions Common/MathUtils/include/MathUtils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,23 +108,24 @@ GPUdi() void sincos(float ang, float& s, float& c)
{
detail::sincos<float>(ang, s, c);
}

#ifndef __OPENCL__
GPUdi() void sincosd(double ang, double& s, double& c)
{
detail::sincos<double>(ang, s, c);
}
#endif

#ifndef GPUCA_GPUCODE_DEVICE
inline void rotateZ(float xL, float yL, float& xG, float& yG, float snAlp, float csAlp)
GPUdi() void rotateZ(float xL, float yL, float& xG, float& yG, float snAlp, float csAlp)
{
return detail::rotateZ<float>(xL, yL, xG, yG, snAlp, csAlp);
}

inline void rotateZd(double xL, double yL, double& xG, double& yG, double snAlp, double csAlp)
GPUdi() void rotateZd(double xL, double yL, double& xG, double& yG, double snAlp, double csAlp)
{
return detail::rotateZ<double>(xL, yL, xG, yG, snAlp, csAlp);
}

#ifndef GPUCA_GPUCODE_DEVICE
inline void rotateZInv(float xG, float yG, float& xL, float& yL, float snAlp, float csAlp)
{
detail::rotateZInv<float>(xG, yG, xL, yL, snAlp, csAlp);
Expand Down
9 changes: 5 additions & 4 deletions Common/MathUtils/include/MathUtils/detail/CircleXY.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef MATHUTILS_INCLUDE_MATHUTILS_DETAIL_CIRCLEXY_H_
#define MATHUTILS_INCLUDE_MATHUTILS_DETAIL_CIRCLEXY_H_

#include "GPUCommonDef.h"
#include "GPUCommonRtypes.h"

namespace o2
Expand All @@ -32,18 +33,18 @@ struct CircleXY {
T rC; // circle radius
T xC; // x-center
T yC; // y-center
CircleXY(T r = T(), T x = T(), T y = T());
T getCenterD2() const;
GPUd() CircleXY(T r = T(), T x = T(), T y = T());
GPUd() T getCenterD2() const;
ClassDefNV(CircleXY, 2);
};

template <typename T>
CircleXY<T>::CircleXY(T r, T x, T y) : rC(std::move(r)), xC(std::move(x)), yC(std::move(y))
GPUdi() CircleXY<T>::CircleXY(T r, T x, T y) : rC(r), xC(x), yC(y)
{
}

template <typename T>
inline T CircleXY<T>::getCenterD2() const
GPUdi() T CircleXY<T>::getCenterD2() const
{
return xC * xC + yC * yC;
}
Expand Down
Loading