cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
folding.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_FOLDING_H
4#define pRC_CORE_TENSOR_FUNCTIONS_FOLDING_H
5
9
10namespace pRC
11{
12 template<Position P, class X, class R = RemoveReference<X>,
13 If<IsTensorish<R>> = 0,
14 If<IsSatisfied<(typename R::Dimension{} > 1)>> = 0,
16 If<All<IsInvocable<Unfolding<typename R::Dimension() - 2>, X>,
18 static inline constexpr auto folding(X &&a)
19 {
20 if constexpr(P == Position::Left)
21 {
22 return unfolding<typename R::Dimension() - 2>(forward<X>(a));
23 }
24
25 if constexpr(P == Position::Right)
26 {
27 return unfolding<0>(forward<X>(a));
28 }
29 }
30}
31#endif // pRC_CORE_TENSOR_FUNCTIONS_FOLDING_H
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr auto folding(X &&a)
Definition folding.hpp:18
static constexpr auto unfolding(X &&a)
Definition unfolding.hpp:17
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134