cMHN 1.2
C++ library for learning MHNs with pRC
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_VIEWS_RESHAPE_H
4#define pRC_CORE_TENSOR_VIEWS_RESHAPE_H
5
8
9namespace pRC::TensorViews
10{
11 template<class T, class N, class V>
12 requires IsTensorView<V>
13 class Reshape
14 : public Conditional<IsAssignable<V>,
15 Assignable<T, N, Reshape<T, N, V>>, View<T, N, Reshape<T, N, V>>>
16 {
17 private:
20
21 public:
22 template<class X>
24 Reshape(X &&a)
25 : mA(forward<X>(a))
26 {
27 }
28
29 using Base::operator=;
30
31 template<IsConvertible<Index>... Is>
32 requires(sizeof...(Is) == Base::Dimension)
33 constexpr decltype(auto) operator()(Is const... indices)
34 {
35 return (*this)(typename Base::Subscripts(indices...));
36 }
37
38 template<IsConvertible<Index>... Is>
39 requires(sizeof...(Is) == Base::Dimension)
40 constexpr decltype(auto) operator()(Is const... indices) const
41 {
42 return (*this)(typename Base::Subscripts(indices...));
43 }
44
45 constexpr decltype(auto) operator()(
46 typename Base::Subscripts const &subscripts)
47 {
48 return mA(typename V::Subscripts(Index(subscripts)));
49 }
50
51 constexpr decltype(auto) operator()(
52 typename Base::Subscripts const &subscripts) const
53 {
54 return mA(typename V::Subscripts(Index(subscripts)));
55 }
56
57 constexpr decltype(auto) operator[](Index const index)
58 requires IsSubscriptable<V>
59 {
60 return mA[index];
61 }
62
63 constexpr decltype(auto) operator[](Index const index) const
64 requires IsSubscriptable<V>
65 {
66 return mA[index];
67 }
68
69 private:
70 V mA;
71 };
72}
73#endif // pRC_CORE_TENSOR_VIEWS_RESHAPE_H
Definition gtest_unittest.cc:5120
Definition assignable.hpp:21
Definition reshape.hpp:16
Reshape(X &&a)
Definition reshape.hpp:24
Definition declarations.hpp:20
Definition concepts.hpp:28
Definition subscript.hpp:21
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
std::conditional_t< B, T, F > Conditional
Definition basics.hpp:56