pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
permute.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_PERMUTE_H
4#define pRC_CORE_TENSOR_FUNCTIONS_PERMUTE_H
5
9
10namespace pRC
11{
12 template<Index... Ps>
13 struct Permute;
14
26 template<Index... Ps, class X, class R = RemoveReference<X>,
28 If<IsSatisfied<(sizeof...(Ps) == typename R::Dimension())>> = 0,
29 If<IsSatisfied<(max(Ps...) < typename R::Dimension())>> = 0,
30 If<IsUnique<Constant<Index, Ps>...>> = 0>
31 static inline constexpr auto permute(X &&a)
32 {
34 return TensorViews::Permute<typename R::Type,
35 decltype(permute<Ps...>(typename R::Sizes())),
36 Sequence<Index, Ps...>, V>(view(forward<X>(a)));
37 }
38
52 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
53 If<IsInvocable<View, X>> = 0,
54 If<IsSatisfied<(0 == typename R::Dimension())>> = 0>
55 static inline constexpr auto permute(X &&a)
56 {
57 return view(forward<X>(a));
58 }
59
74 template<Index... Ps, class X, class R = RemoveReference<X>,
76 If<IsInvocable<Permute<Ps...>, X &>> = 0>
77 static inline constexpr auto permute(X &&a)
78 {
79 return eval(permute<Ps...>(a));
80 }
81}
82#endif // pRC_CORE_TENSOR_FUNCTIONS_PERMUTE_H
Definition sequence.hpp:34
Definition permute.hpp:13
Definition cholesky.hpp:18
static constexpr X eval(X &&a)
Definition eval.hpp:11
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::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
static constexpr auto permute(Sequence< T, Is... > const)
Definition sequence.hpp:450
Size Index
Definition type_traits.hpp:21
static constexpr X max(X &&a)
Definition max.hpp:13