cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
extract_diagonal.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_OPERATOR_VIEWS_EXTRACT_DIAGONAL_H
4#define pRC_CORE_TENSOR_OPERATOR_VIEWS_EXTRACT_DIAGONAL_H
5
8
9namespace pRC::TensorViews
10{
11 template<class T, class N, class V>
12 requires IsTensorView<V>
14 : public Conditional<IsAssignable<V>,
15 Assignable<T, N, ExtractDiagonal<T, N, V>>,
16 View<T, N, ExtractDiagonal<T, N, V>>>
17 {
18 private:
22
23 public:
24 template<class X>
27 : mA(forward<X>(a))
28 {
29 }
30
31 using Base::operator=;
32
33 template<IsConvertible<Index>... Is>
34 requires(sizeof...(Is) == Base::Dimension)
35 constexpr decltype(auto) operator()(Is const... indices)
36 {
37 return mA(indices..., indices...);
38 }
39
40 template<IsConvertible<Index>... Is>
41 requires(sizeof...(Is) == Base::Dimension)
42 constexpr decltype(auto) operator()(Is const... indices) const
43 {
44 return mA(indices..., indices...);
45 }
46
47 constexpr decltype(auto) operator()(
48 typename Base::Subscripts const &subscripts)
49 {
50 return this->call(subscripts);
51 }
52
53 constexpr decltype(auto) operator()(
54 typename Base::Subscripts const &subscripts) const
55 {
56 return this->call(subscripts);
57 }
58
59 constexpr decltype(auto) operator[](Index const index) = delete;
60 constexpr decltype(auto) operator[](Index const index) const = delete;
61
62 private:
63 V mA;
64 };
65}
66#endif // pRC_CORE_TENSOR_OPERATOR_VIEWS_EXTRACT_DIAGONAL_H
Definition gtest_unittest.cc:5120
Definition assignable.hpp:21
Definition extract_diagonal.hpp:17
ExtractDiagonal(X &&a)
Definition extract_diagonal.hpp:26
Definition declarations.hpp:20
Definition concepts.hpp:28
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
std::conditional_t< B, T, F > Conditional
Definition basics.hpp:56