cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
single.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_VIEWS_SINGLE_H
4#define pRC_CORE_TENSOR_VIEWS_SINGLE_H
5
8
9namespace pRC::TensorViews
10{
11 template<class T, class N>
12 class Single : public View<T, N, Single<T, N>>
13 {
14 private:
16
17 public:
18 template<class X>
20 Single(X &&value, typename Base::Subscripts const &subscripts)
21 : mValue(forward<X>(value))
22 , mSubscripts(subscripts)
23 {
24 }
25
26 template<IsConvertible<Index>... Is>
27 requires(sizeof...(Is) == Base::Dimension)
28 constexpr decltype(auto) operator()(Is const... indices) const
29 {
30 return (*this)(typename Base::Subscripts(indices...));
31 }
32
33 constexpr T operator()(
34 typename Base::Subscripts const &subscripts) const
35 {
36 if(subscripts == mSubscripts)
37 {
38 return mValue;
39 }
40 else
41 {
42 return zero();
43 }
44 }
45
46 constexpr decltype(auto) operator[](Index const index) = delete;
47 constexpr decltype(auto) operator[](Index const index) const = delete;
48
49 private:
50 T const mValue;
51 typename Base::Subscripts const mSubscripts;
52 };
53}
54#endif // pRC_CORE_TENSOR_VIEWS_SINGLE_H
Definition value.hpp:12
Definition single.hpp:13
Single(X &&value, typename Base::Subscripts const &subscripts)
Definition single.hpp:20
constexpr T operator()(typename Base::Subscripts const &subscripts) const
Definition single.hpp:33
Definition declarations.hpp:20
Definition concepts.hpp:37
int value
Definition gmock-actions_test.cc:1714
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
static constexpr auto zero()
Definition zero.hpp:12