cMHN
1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
pRC
prc
core
tensor
views
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
6
#include <
prc/core/functors/subscript.hpp
>
7
#include <
prc/core/tensor/declarations.hpp
>
8
9
namespace
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
:
18
using
Base
=
Conditional<IsAssignable<V>
,
Assignable<T, N, Reshape>
,
19
View<T, N, Reshape>
>;
20
21
public
:
22
template
<
class
X>
23
requires
IsSame<V, RemoveReference<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
Base
Definition
gtest_unittest.cc:5120
pRC::TensorViews::Assignable
Definition
assignable.hpp:21
pRC::TensorViews::Reshape
Definition
reshape.hpp:16
pRC::TensorViews::Reshape::Reshape
Reshape(X &&a)
Definition
reshape.hpp:24
pRC::TensorViews::View
Definition
declarations.hpp:20
pRC::IsSame
Definition
concepts.hpp:28
pRC::IsSubscriptable
Definition
subscript.hpp:21
declarations.hpp
pRC::TensorViews
Definition
declarations.hpp:18
pRC::Index
Size Index
Definition
basics.hpp:32
pRC::Conditional
std::conditional_t< B, T, F > Conditional
Definition
basics.hpp:56
subscript.hpp
Generated by
1.11.0