pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
matricize.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_MATRICIZE_H
4#define pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_MATRICIZE_H
5
8
9namespace pRC
10{
21 template<class X, class R = RemoveReference<X>, If<IsTensorish<R>> = 0,
22 If<IsSatisfied<(typename R::Dimension{} > 0)>> = 0,
23 If<IsSatisfied<(isEven(typename R::Dimension()))>> = 0>
24 static inline constexpr auto matricize(X &&a)
25 {
26 return reshape<decltype(cut<2, 0>(typename R::Sizes()))::size(),
27 decltype(cut<2, 1>(typename R::Sizes()))::size()>(forward<X>(a));
28 }
29}
30#endif // pRC_CORE_TENSOR_OPERATOR_FUNCTIONS_MATRICIZE_H
Definition cholesky.hpp:18
static constexpr auto matricize(X &&a)
Reshapes a Tensor into a matrix (a 2-dimensional Tensor)
Definition matricize.hpp:24
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
static constexpr auto isEven(T const a)
Definition is_even.hpp:11
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13