cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
unit_lower_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_LOWER_TRIANGULAR_H
4#define pRC_CORE_TENSOR_OPERATOR_VIEWS_UNIT_LOWER_TRIANGULAR_H
5
9
10namespace pRC::TensorViews
11{
12 template<class T, class N, class V>
13 class UnitLowerTriangular : public View<T, N, UnitLowerTriangular<T, N, V>>
14 {
15 static_assert(IsTensorView<V>());
16 static_assert(typename N::Dimension() == 2);
17
18 private:
20
21 public:
22 template<class X, If<IsConstructible<V, X>> = 0>
24 : mA(forward<X>(a))
25 {
26 }
27
28 constexpr T operator()(Index const i, Index const j)
29 {
30 if(i > j)
31 {
32 return mA(i, j);
33 }
34
35 if(i == j)
36 {
37 return identity();
38 }
39
40 return zero();
41 }
42
43 constexpr T operator()(Index const i, Index const j) const
44 {
45 if(i > j)
46 {
47 return mA(i, j);
48 }
49
50 if(i == j)
51 {
52 return identity();
53 }
54
55 return zero();
56 }
57
58 constexpr decltype(auto) operator()(
59 typename Base::Subscripts const &subscripts)
60 {
61 return this->call(subscripts);
62 }
63
64 constexpr decltype(auto) operator()(
65 typename Base::Subscripts const &subscripts) const
66 {
67 return this->call(subscripts);
68 }
69
70 private:
71 V mA;
72 };
73}
74#endif // pRC_CORE_TENSOR_OPERATOR_VIEWS_UNIT_LOWER_TRIANGULAR_H
Definition unit_lower_triangular.hpp:14
constexpr T operator()(Index const i, Index const j)
Definition unit_lower_triangular.hpp:28
constexpr T operator()(Index const i, Index const j) const
Definition unit_lower_triangular.hpp:43
UnitLowerTriangular(X &&a)
Definition unit_lower_triangular.hpp:23
Definition type_traits.hpp:32
Definition diagonal.hpp:11
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
static constexpr auto zero()
Definition zero.hpp:12
static constexpr auto identity()
Definition identity.hpp:12