pRC
multi-purpose Tensor Train library for C++
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
34 template<Size... Ss, class X, class... Os, class R = RemoveReference<X>,
37 If<IsSatisfied<(sizeof...(Ss) == typename R::Dimension())>> = 0,
38 If<IsSatisfied<(sizeof...(Os) == typename R::Dimension())>> = 0,
40 typename R::Sizes() % Sizes<Ss...>() == Constant<Size, 0>())>> = 0>
41 static inline constexpr auto stride(X &&a, Os const... offsets)
42 {
44 return TensorViews::Stride<typename R::Type,
45 decltype(typename R::Sizes() / Sizes<Ss...>()), Sizes<Ss...>, V>(
46 view(forward<X>(a)), Subscripts<Ss...>(offsets...));
47 }
48
70 template<Size... Ss, class X, class... Os, class R = RemoveReference<X>,
72 If<IsInvocable<Stride<Ss...>, X &, Os...>> = 0>
73 static inline constexpr auto stride(X &&a, Os const... offsets)
74 {
75 return eval(stride<Ss...>(a, offsets...));
76 }
77}
78#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
Sequence< Size, Ns... > Sizes
Definition type_traits.hpp:238
static constexpr X view(X &&a)
Returns a TensorView obtained from a TensorView.
Definition view.hpp:22
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
std::size_t Size
Definition type_traits.hpp:20
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134
static constexpr auto stride(X &&a, Os const ... offsets)
Constructs a Tensor by taking equally-sized steps through the input Tensor.
Definition stride.hpp:41
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13