Skip to content

Commit 0a7d900

Browse files
committed
Move math functions to clue::math namespace
1 parent 9e55e18 commit 0a7d900

File tree

9 files changed

+23
-25
lines changed

9 files changed

+23
-25
lines changed

include/CLUEstering/core/detail/ClusteringKernels.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace clue::detail {
4646
distance += distance_vector[dim] * distance_vector[dim];
4747
}
4848

49-
auto k = kernel(acc, clue::internal::math::sqrt(distance), point_id, j);
49+
auto k = kernel(acc, math::sqrt(distance), point_id, j);
5050
rho_i += static_cast<int>(distance_vector <= dc) * k * dev_points.weight[j];
5151
}
5252
return;

include/CLUEstering/core/detail/ConvolutionalKernel.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ namespace clue {
4141
if (point_id == j) {
4242
return 1.f;
4343
} else {
44-
return m_gaus_amplitude *
45-
clue::internal::math::exp(-(dist_ij - m_gaus_avg) * (dist_ij - m_gaus_avg) /
46-
(2 * m_gaus_std * m_gaus_std));
44+
return m_gaus_amplitude * math::exp(-(dist_ij - m_gaus_avg) * (dist_ij - m_gaus_avg) /
45+
(2 * m_gaus_std * m_gaus_std));
4746
}
4847
}
4948

@@ -62,7 +61,7 @@ namespace clue {
6261
if (point_id == j) {
6362
return 1.f;
6463
} else {
65-
return (m_exp_amplitude * clue::internal::math::exp(-m_exp_avg * dist_ij));
64+
return (m_exp_amplitude * math::exp(-m_exp_avg * dist_ij));
6665
}
6766
}
6867

include/CLUEstering/data_structures/internal/TilesView.hpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ namespace clue::internal {
4343
}
4444

4545
// Address the cases of underflow and overflow
46-
coord_bin = internal::math::min(coord_bin, nperdim - 1);
47-
coord_bin = internal::math::max(coord_bin, 0);
46+
coord_bin = math::min(coord_bin, nperdim - 1);
47+
coord_bin = math::max(coord_bin, 0);
4848

4949
return coord_bin;
5050
}
5151

5252
ALPAKA_FN_ACC inline constexpr int getGlobalBin(const float* coords) const {
5353
int global_bin = 0;
5454
for (auto dim = 0u; dim != Ndim - 1; ++dim) {
55-
global_bin += internal::math::pow(static_cast<float>(nperdim), Ndim - dim - 1) *
56-
getBin(coords[dim], dim);
55+
global_bin +=
56+
math::pow(static_cast<float>(nperdim), Ndim - dim - 1) * getBin(coords[dim], dim);
5757
}
5858
global_bin += getBin(coords[Ndim - 1], Ndim - 1);
5959
return global_bin;
@@ -63,7 +63,7 @@ namespace clue::internal {
6363
int32_t globalBin = 0;
6464
for (auto dim = 0u; dim != Ndim; ++dim) {
6565
auto bin_i = wrapping[dim] ? (Bins[dim] % nperdim) : Bins[dim];
66-
globalBin += internal::math::pow(static_cast<float>(nperdim), Ndim - dim - 1) * bin_i;
66+
globalBin += math::pow(static_cast<float>(nperdim), Ndim - dim - 1) * bin_i;
6767
}
6868
return globalBin;
6969
}
@@ -102,10 +102,9 @@ namespace clue::internal {
102102
std::array<float, Ndim> distance_vector;
103103
for (auto dim = 0u; dim != Ndim; ++dim) {
104104
if (wrapping[dim])
105-
distance_vector[dim] =
106-
internal::math::fabs(normalizeCoordinate(coord_i[dim] - coord_j[dim], dim));
105+
distance_vector[dim] = math::fabs(normalizeCoordinate(coord_i[dim] - coord_j[dim], dim));
107106
else
108-
distance_vector[dim] = internal::math::fabs(coord_i[dim] - coord_j[dim]);
107+
distance_vector[dim] = math::fabs(coord_i[dim] - coord_j[dim]);
109108
}
110109
return distance_vector;
111110
}

include/CLUEstering/internal/math/exp/exp.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <cmath>
1111
#endif
1212

13-
namespace clue::internal::math {
13+
namespace clue::math {
1414

1515
ALPAKA_FN_ACC inline constexpr float exp(float x) {
1616
#if defined(CUDA_DEVICE_FN)
@@ -51,4 +51,4 @@ namespace clue::internal::math {
5151
return exp(static_cast<double>(x));
5252
}
5353

54-
} // namespace clue::internal::math
54+
} // namespace clue::math

include/CLUEstering/internal/math/fabs/fabs.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include "CLUEstering/internal/math/defines.hpp"
88

9-
namespace clue::internal::math {
9+
namespace clue::math {
1010

1111
ALPAKA_FN_ACC inline constexpr float fabs(float arg) {
1212
#if defined(CUDA_DEVICE_FN)
@@ -34,4 +34,4 @@ namespace clue::internal::math {
3434
#endif
3535
}
3636

37-
} // namespace clue::internal::math
37+
} // namespace clue::math

include/CLUEstering/internal/math/max/max.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <cmath>
1111
#endif
1212

13-
namespace clue::internal::math {
13+
namespace clue::math {
1414

1515
template <clue::concepts::Numeric T>
1616
ALPAKA_FN_ACC inline constexpr T max(const T& a, const T& b) {
@@ -46,4 +46,4 @@ namespace clue::internal::math {
4646
#endif
4747
}
4848

49-
} // namespace clue::internal::math
49+
} // namespace clue::math

include/CLUEstering/internal/math/min/min.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <algorithm>
1111
#endif
1212

13-
namespace clue::internal::math {
13+
namespace clue::math {
1414

1515
template <clue::concepts::Numeric T>
1616
ALPAKA_FN_ACC inline constexpr T min(const T& a, const T& b) {
@@ -46,4 +46,4 @@ namespace clue::internal::math {
4646
#endif
4747
}
4848

49-
} // namespace clue::internal::math
49+
} // namespace clue::math

include/CLUEstering/internal/math/pow/pow.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <cmath>
1010
#endif
1111

12-
namespace clue::internal::math {
12+
namespace clue::math {
1313

1414
ALPAKA_FN_ACC inline constexpr float pow(float base, float exp) {
1515
#if defined(CUDA_DEVICE_FN)
@@ -45,4 +45,4 @@ namespace clue::internal::math {
4545

4646
ALPAKA_FN_ACC inline constexpr float powf(float base, float exp) { return pow(base, exp); }
4747

48-
} // namespace clue::internal::math
48+
} // namespace clue::math

include/CLUEstering/internal/math/sqrt/sqrt.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <cmath>
1111
#endif
1212

13-
namespace clue::internal::math {
13+
namespace clue::math {
1414

1515
ALPAKA_FN_ACC inline constexpr float sqrt(float x) {
1616
#if defined(CUDA_DEVICE_FN)
@@ -51,4 +51,4 @@ namespace clue::internal::math {
5151
return sqrt(static_cast<double>(x));
5252
}
5353

54-
} // namespace clue::internal::math
54+
} // namespace clue::math

0 commit comments

Comments
 (0)