cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
off_diagonal.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_VIEWS_OFF_DIAGONAL_H
4#define pRC_CORE_TENSOR_OPERATOR_VIEWS_OFF_DIAGONAL_H
5
9
10namespace pRC::TensorViews
11{
12 template<class T, class N, class V>
13 requires IsTensorView<V>
14 class OffDiagonal : public View<T, N, OffDiagonal<T, N, V>>
15 {
16 private:
18
19 public:
20 template<class X>
23 : mA(forward<X>(a))
24 {
25 }
26
27 template<IsConvertible<Index>... Is>
28 requires(sizeof...(Is) == Base::Dimension)
29 constexpr decltype(auto) operator()(Is const... indices)
30 {
31 return this->call(indices...);
32 }
33
34 template<IsConvertible<Index>... Is>
35 requires(sizeof...(Is) == Base::Dimension)
36 constexpr decltype(auto) operator()(Is const... indices) const
37 {
38 return this->call(indices...);
39 }
40
41 constexpr decltype(auto) operator()(
42 typename Base::Subscripts const &subscripts)
43 {
45 [this, &subscripts](auto const... seq) -> T
46 {
47 if(((subscripts[seq] ==
48 subscripts[Base::Dimension / 2 + seq]) &&
49 ...))
50 {
51 return zero();
52 }
53
54 return mA(subscripts[seq]...,
55 subscripts[Base::Dimension / 2 + seq]...);
56 });
57 }
58
59 constexpr decltype(auto) operator()(
60 typename Base::Subscripts const &subscripts) const
61 {
63 [this, &subscripts](auto const... seq) -> T
64 {
65 if(((subscripts[seq] ==
66 subscripts[Base::Dimension / 2 + seq]) &&
67 ...))
68 {
69 return zero();
70 }
71
72 return mA(subscripts[seq]...,
73 subscripts[Base::Dimension / 2 + seq]...);
74 });
75 }
76
77 constexpr decltype(auto) operator[](Index const index) = delete;
78 constexpr decltype(auto) operator[](Index const index) const = delete;
79
80 private:
81 V mA;
82 };
83}
84#endif // pRC_CORE_TENSOR_OPERATOR_VIEWS_OFF_DIAGONAL_H
Definition value.hpp:12
Definition off_diagonal.hpp:15
OffDiagonal(X &&a)
Definition off_diagonal.hpp:22
Definition declarations.hpp:20
Definition concepts.hpp:28
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
static constexpr auto makeSeries()
Definition sequence.hpp:390
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383
static constexpr auto zero()
Definition zero.hpp:12