pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
reshape.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_RESHAPE_H
4#define pRC_CORE_TENSOR_FUNCTIONS_RESHAPE_H
5
8
9namespace pRC
10{
11 template<Size... Ns>
12 struct Reshape;
13
26 template<Size... Ns, class X, class R = RemoveReference<X>,
28 If<IsSatisfied<(Sizes<Ns...>::size() == R::size())>> = 0>
29 static inline constexpr auto reshape(X &&a)
30 {
32 return TensorViews::Reshape<typename R::Type, Sizes<Ns...>, V>(
33 view(forward<X>(a)));
34 }
35
51 template<Size... Ns, class X, class R = RemoveReference<X>,
53 If<IsInvocable<Reshape<Ns...>, X &>> = 0>
54 static inline constexpr auto reshape(X &&a)
55 {
56 return eval(reshape<Ns...>(a));
57 }
58}
59#endif // pRC_CORE_TENSOR_FUNCTIONS_RESHAPE_H
Definition sequence.hpp:56
static constexpr auto size()
Definition sequence.hpp:88
Definition reshape.hpp:15
Definition cholesky.hpp:18
static constexpr X eval(X &&a)
Definition eval.hpp:11
static constexpr X view(X &&a)
Returns a TensorView obtained from a TensorView.
Definition view.hpp:22
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
std::size_t Size
Definition type_traits.hpp:20
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 reshape(X &&a)
Reshapes a Tensor.
Definition reshape.hpp:29