cMHN 1.1
C++ library for learning MHNs with pRC
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
15 template<Index... Ps, class X, class R = RemoveReference<X>,
17 If<IsSatisfied<(sizeof...(Ps) == typename R::Dimension())>> = 0,
18 If<IsSatisfied<(max(Ps...) < typename R::Dimension())>> = 0,
19 If<IsUnique<Constant<Index, Ps>...>> = 0>
20 static inline constexpr auto permute(X &&a)
21 {
23 return TensorViews::Permute<typename R::Type,
24 decltype(permute<Ps...>(typename R::Sizes())),
25 Sequence<Index, Ps...>, V>(view(forward<X>(a)));
26 }
27
28 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
29 If<IsInvocable<View, X>> = 0,
30 If<IsSatisfied<(0 == typename R::Dimension())>> = 0>
31 static inline constexpr auto permute(X &&a)
32 {
33 return view(forward<X>(a));
34 }
35
36 template<Index... Ps, class X, class R = RemoveReference<X>,
38 If<IsInvocable<Permute<Ps...>, X &>> = 0>
39 static inline constexpr auto permute(X &&a)
40 {
41 return eval(permute<Ps...>(a));
42 }
43}
44#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 auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
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
static constexpr auto permute(Sequence< T, Is... > const)
Definition sequence.hpp:440
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134
static constexpr X max(X &&a)
Definition max.hpp:13