pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
unfolding.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_UNFOLDING_H
4#define pRC_CORE_TENSOR_FUNCTIONS_UNFOLDING_H
5
8
9namespace pRC
10{
24 template<Index K, class X, class R = RemoveReference<X>,
25 If<IsTensorish<R>> = 0,
26 If<IsSatisfied<(typename R::Dimension{} > 1)>> = 0,
27 If<IsSatisfied<(K + 1 < typename R::Dimension{})>> = 0,
28 If<IsInvocable<Reshape<R::size(K), R::Sizes::size() / R::size(K)>, X>> =
29 0>
30 static inline constexpr auto unfolding(X &&a)
31 {
32 return reshape<decltype(trim<0, K + 1>(typename R::Sizes()))::size(),
33 decltype(trim<K + 1, typename R::Dimension{}>(
34 typename R::Sizes{}))::size()>(forward<X>(a));
35 }
36}
37#endif // pRC_CORE_TENSOR_FUNCTIONS_UNFOLDING_H
Definition cholesky.hpp:18
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 trim(Sequence< T, Is... > const)
Definition sequence.hpp:623
static constexpr auto unfolding(X &&a)
Reshapes a Tensor into a matrix.
Definition unfolding.hpp:30