cMHN 1.2
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
9
10namespace pRC
11{
12 template<Size... Ss, class X, IsConvertible<Index>... Os,
13 IsTensorish R = RemoveReference<X>>
14 requires(sizeof...(Ss) == R::Dimension &&
15 sizeof...(Os) == R::Dimension &&
16 typename R::Sizes() % Sizes<Ss...>() == Constant<Size, 0>())
17 static inline constexpr auto stride(X &&a, Os const... offsets)
18 {
19 if constexpr(IsInvocable<View, X>)
20 {
22 return TensorViews::Stride<typename R::Type,
23 decltype(typename R::Sizes() / Sizes<Ss...>()), Sizes<Ss...>,
24 V>(view(forward<X>(a)), Subscripts<Ss...>(offsets...));
25 }
26 else
27 {
28 return eval(stride<Ss...>(a, offsets...));
29 }
30 }
31}
32#endif // pRC_CORE_TENSOR_FUNCTIONS_STRIDE_H
Definition sequence.hpp:29
Definition subscripts.hpp:21
Definition stride.hpp:14
Definition concepts.hpp:31
Definition cholesky.hpp:10
std::size_t Size
Definition basics.hpp:31
std::remove_reference_t< T > RemoveReference
Definition basics.hpp:41
static constexpr decltype(auto) view(X &&a)
Definition view.hpp:13
static constexpr auto stride(X &&a, Os const ... offsets)
Definition stride.hpp:17
Sequence< Size, Ns... > Sizes
Definition sequence.hpp:100
std::integral_constant< T, V > Constant
Definition basics.hpp:38
static constexpr decltype(auto) eval(X &&a)
Definition eval.hpp:12