pRC
multi-purpose Tensor Train library for C++
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{
27 template<Position P, class X, class R = RemoveReference<X>,
28 If<IsTensorish<R>> = 0,
29 If<IsSatisfied<(typename R::Dimension{} > 1)>> = 0,
31 If<All<IsInvocable<Unfolding<typename R::Dimension() - 2>, X>,
33 static inline constexpr auto folding(X &&a)
34 {
35 if constexpr(P == Position::Left)
36 {
37 return unfolding<typename R::Dimension() - 2>(forward<X>(a));
38 }
39
40 if constexpr(P == Position::Right)
41 {
42 return unfolding<0>(forward<X>(a));
43 }
44 }
45}
46#endif // pRC_CORE_TENSOR_FUNCTIONS_FOLDING_H
Definition cholesky.hpp:18
std::conjunction< Bs... > All
Definition type_traits.hpp:77
static constexpr auto folding(X &&a)
Reshapes a Tensor into a matrix.
Definition folding.hpp:33
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 unfolding(X &&a)
Reshapes a Tensor into a matrix.
Definition unfolding.hpp:30