cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
stride.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_STRIDE_H
4#define pRC_CORE_TENSOR_FUNCTIONS_STRIDE_H
5
8
9namespace pRC
10{
11 template<Size... Ss>
12 struct Stride;
13
14 template<Size... Ss, class X, class... Os, class R = RemoveReference<X>,
17 If<IsSatisfied<(sizeof...(Ss) == typename R::Dimension())>> = 0,
18 If<IsSatisfied<(sizeof...(Os) == typename R::Dimension())>> = 0,
20 typename R::Sizes() % Sizes<Ss...>() == Constant<Size, 0>())>> = 0>
21 static inline constexpr auto stride(X &&a, Os const... offsets)
22 {
24 return TensorViews::Stride<typename R::Type,
25 decltype(typename R::Sizes() / Sizes<Ss...>()), Sizes<Ss...>, V>(
26 view(forward<X>(a)), Subscripts<Ss...>(offsets...));
27 }
28
29 template<Size... Ss, class X, class... Os, class R = RemoveReference<X>,
31 If<IsInvocable<Stride<Ss...>, X &, Os...>> = 0>
32 static inline constexpr auto stride(X &&a, Os const... offsets)
33 {
34 return eval(stride<Ss...>(a, offsets...));
35 }
36}
37#endif // pRC_CORE_TENSOR_FUNCTIONS_STRIDE_H
Definition sequence.hpp:56
Definition subscripts.hpp:20
Definition stride.hpp:13
Definition cholesky.hpp:18
static constexpr X eval(X &&a)
Definition eval.hpp:11
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::size_t Size
Definition type_traits.hpp:20
static constexpr X view(X &&a)
Definition view.hpp:12
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
Sequence< Size, Ns... > Sizes
Definition type_traits.hpp:238
static constexpr auto stride(X &&a, Os const ... offsets)
Definition stride.hpp:21
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134