cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
unit_upper_triangular.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_VIEWS_UNIT_UPPER_TRIANGULAR_H
4#define pRC_CORE_TENSOR_OPERATOR_VIEWS_UNIT_UPPER_TRIANGULAR_H
5
9
10namespace pRC::TensorViews
11{
12 template<class T, class N, class V>
13 requires IsTensorView<V> && (N::Dimension == 2)
14 class UnitUpperTriangular : public View<T, N, UnitUpperTriangular<T, N, V>>
15 {
16 private:
18
19 public:
20 template<class X>
23 : mA(forward<X>(a))
24 {
25 }
26
27 constexpr T operator()(Index const i, Index const j)
28 {
29 if(i < j)
30 {
31 return mA(i, j);
32 }
33
34 if(i == j)
35 {
36 return identity();
37 }
38
39 return zero();
40 }
41
42 constexpr T operator()(Index const i, Index const j) const
43 {
44 if(i < j)
45 {
46 return mA(i, j);
47 }
48
49 if(i == j)
50 {
51 return identity();
52 }
53
54 return zero();
55 }
56
57 constexpr decltype(auto) operator()(
58 typename Base::Subscripts const &subscripts)
59 {
60 return this->call(subscripts);
61 }
62
63 constexpr decltype(auto) operator()(
64 typename Base::Subscripts const &subscripts) const
65 {
66 return this->call(subscripts);
67 }
68
69 constexpr decltype(auto) operator[](Index const index) = delete;
70 constexpr decltype(auto) operator[](Index const index) const = delete;
71
72 private:
73 V mA;
74 };
75}
76#endif // pRC_CORE_TENSOR_OPERATOR_VIEWS_UNIT_UPPER_TRIANGULAR_H
Definition value.hpp:12
Definition unit_upper_triangular.hpp:15
constexpr T operator()(Index const i, Index const j) const
Definition unit_upper_triangular.hpp:42
UnitUpperTriangular(X &&a)
Definition unit_upper_triangular.hpp:22
constexpr T operator()(Index const i, Index const j)
Definition unit_upper_triangular.hpp:27
Definition declarations.hpp:20
Definition concepts.hpp:28
int i
Definition gmock-matchers-comparisons_test.cc:603
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
static constexpr auto identity()
Definition identity.hpp:13
static constexpr auto zero()
Definition zero.hpp:12