IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
IpplExpressions.h
Go to the documentation of this file.
1//
2// File IpplExpressions.h
3// Expression Templates classes.
4//
5#ifndef IPPL_EXPRESSIONS_H
6#define IPPL_EXPRESSIONS_H
7
8#include <type_traits>
9
10namespace ippl {
11 namespace detail {
18
25 template <typename E, size_t N = sizeof(E)>
26 struct Expression {
27 constexpr static unsigned dim = E::dim;
28
32 KOKKOS_INLINE_FUNCTION auto operator[](size_t i) const {
33 return static_cast<const E&>(*this)[i];
34 }
35 };
36
43 template <typename E, size_t N = sizeof(E)>
45 constexpr static unsigned dim = E::dim;
46
47 template <typename... Args>
48 KOKKOS_INLINE_FUNCTION auto operator()(Args... args) const {
49 static_assert(sizeof...(Args) == dim || dim == 0);
50 return reinterpret_cast<const E&>(*this)(args...);
51 }
52
53 char buffer[N];
54 };
55
60 template <typename T>
61 struct Scalar : public Expression<Scalar<T>, sizeof(T)> {
62 typedef T value_type;
63 constexpr static unsigned dim = 0;
64
65 KOKKOS_FUNCTION
67 : val_m(val) {}
68
74 KOKKOS_INLINE_FUNCTION value_type operator[](size_t /*i*/) const { return val_m; }
75
82 template <typename... Args>
83 KOKKOS_INLINE_FUNCTION auto operator()(Args... /*args*/) const {
84 return val_m;
85 }
86
87 private:
89 };
90
91 template <typename T>
92 struct isExpression : std::false_type {};
93
94 template <typename T>
95 struct isExpression<Scalar<T>> : std::true_type {};
96
97 } // namespace detail
98} // namespace ippl
99
101
102#endif
Definition Archive.h:20
KOKKOS_INLINE_FUNCTION auto operator[](size_t i) const
static constexpr unsigned dim
KOKKOS_INLINE_FUNCTION auto operator()(Args... args) const
static constexpr unsigned dim
KOKKOS_INLINE_FUNCTION value_type operator[](size_t) const
KOKKOS_FUNCTION Scalar(value_type val)
KOKKOS_INLINE_FUNCTION auto operator()(Args...) const
static constexpr unsigned dim