Project
Loading...
Searching...
No Matches
basicMath.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef MATHUTILS_INCLUDE_MATHUTILS_DETAIL_BASICMATH_H_
17#define MATHUTILS_INCLUDE_MATHUTILS_DETAIL_BASICMATH_H_
18
19#ifndef GPUCA_GPUCODE_DEVICE
20#include <cmath>
21#include <tuple>
22#endif
23#include "GPUCommonArray.h"
24#include "GPUCommonDef.h"
25#include "GPUCommonMath.h"
27
28namespace o2
29{
30namespace math_utils
31{
32namespace detail
33{
34
35template <typename T>
36GPUhdi() T copysign(T x, T y)
37{
38 return o2::gpu::GPUCommonMath::Copysign(x, y);
39}
40
41template <class T>
42GPUhdi() T min(const T x, const T y)
43{
44 return o2::gpu::GPUCommonMath::Min(x, y);
45};
46
47template <class T>
48GPUhdi() T max(const T x, const T y)
49{
50 return o2::gpu::GPUCommonMath::Max(x, y);
51};
52
53template <class T>
54GPUhdi() T sqrt(T x)
55{
56 return o2::gpu::GPUCommonMath::Sqrt(x);
57};
58
59template <class T>
60GPUhdi() T abs(T x)
61{
62 return o2::gpu::GPUCommonMath::Abs(x);
63};
64
65template <class T>
66GPUdi() int nint(T x)
67{
68 return o2::gpu::GPUCommonMath::Float2IntRn(x);
69};
70
71template <class T>
72GPUdi() bool finite(T x)
73{
74 return o2::gpu::GPUCommonMath::Finite(x);
75}
76
77GPUdi() unsigned int clz(unsigned int val)
78{
79 return o2::gpu::GPUCommonMath::Clz(val);
80};
81
82GPUdi() unsigned int popcount(unsigned int val)
83{
84 return o2::gpu::GPUCommonMath::Popcount(val);
85};
86
87template <class T>
88GPUdi() T log(T x)
89{
90 return o2::gpu::GPUCommonMath::Log(x);
91};
92
93#ifndef GPUCA_GPUCODE_DEVICE // Double overloads using std namespace not visible on GPU
94template <>
95GPUhdi() double copysign(double x, double y)
96{
97 return std::copysign(x, y);
98}
99template <>
100GPUhdi() double sqrt(double x)
101{
102 return std::sqrt(x);
103};
104GPUhdi() double abs(double x)
105{
106 return std::abs(x);
107};
108template <>
109GPUdi() int nint(double x)
110{
111 return std::nearbyint(x);
112};
113template <>
114GPUdi() bool finite(double x)
115{
116 return std::isfinite(x);
117}
118template <>
119GPUdi() double log(double x)
120{
121 return std::log(x);
122};
123#endif
124
125} // namespace detail
126} // namespace math_utils
127} // namespace o2
128
129#endif /* MATHUTILS_INCLUDE_MATHUTILS_DETAIL_BASICMATH_H_ */
useful math constants
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLfloat * val
Definition glcorearb.h:1582
return((dphi > 0 &&dphi< constants::math::PI)||dphi< -constants::math::PI) ? true GPUhdi() const expr bool okForPhiMax(T phiMax
GPUdi() int nint(T x)
Definition basicMath.h:66
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
constexpr size_t min
constexpr size_t max