11#include <Kokkos_Core.hpp>
13namespace ddc::detail {
16KOKKOS_INLINE_FUNCTION T sum(T* array,
int size)
19 for (
int i(0); i < size; ++i) {
25template <
class ElementType,
class LayoutPolicy,
class AccessorPolicy, std::size_t Ext>
26KOKKOS_INLINE_FUNCTION ElementType sum(Kokkos::mdspan<
28 Kokkos::extents<std::size_t, Ext>,
30 AccessorPolicy>
const& array)
33 for (std::size_t i(0); i < array.extent(0); ++i) {
39template <
class ElementType,
class LayoutPolicy,
class AccessorPolicy, std::size_t Ext>
40KOKKOS_INLINE_FUNCTION ElementType
43 Kokkos::extents<std::size_t, Ext>,
45 AccessorPolicy>
const& array,
50 for (
int i(start); i < end; ++i) {
57KOKKOS_INLINE_FUNCTION T modulo(T x, T y)
59 return x - y * Kokkos::floor(
double(x) / y);
62KOKKOS_INLINE_FUNCTION
double ipow(
double a, std::size_t i)
65 for (std::size_t j(0); j < i; ++j) {
71KOKKOS_INLINE_FUNCTION
double ipow(
double a,
int i)
75 for (
int j(0); j < i; ++j) {
79 for (
int j(0); j < -i; ++j) {
87KOKKOS_INLINE_FUNCTION std::size_t factorial(std::size_t f)
90 for (std::size_t i(2); i < f + 1; ++i) {
96template <
class T, std::size_t D>
97KOKKOS_INLINE_FUNCTION T dot_product(std::array<T, D>
const& a, std::array<T, D>
const& b)
100 for (std::size_t i(0); i < D; ++i) {
101 result += a[i] * b[i];
107KOKKOS_INLINE_FUNCTION T min(T x, T y)
109 return x < y ? x : y;
113KOKKOS_INLINE_FUNCTION T max(T x, T y)
115 return x > y ? x : y;
The top-level namespace of DDC.