cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
assignable.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ASSIGNABLE_H
4#define pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ASSIGNABLE_H
5
8
10{
11 template<class T, class SM, class SN, class SR, class F>
12 class Assignable : public View<T, SM, SN, SR, F>
13 {
14 private:
16
17 public:
18 constexpr auto &operator=(Zero<> const)
19 {
20 return *this = zero<F>();
21 }
22
23 constexpr auto &operator=(Unit<> const)
24 {
25 return *this = unit<F>();
26 }
27
28 constexpr auto &operator=(Identity<> const)
29 {
30 return *this = identity<F>();
31 }
32
33 template<class X, IsOperatorish R = RemoveReference<X>>
37 constexpr auto &operator=(X &&rhs)
38 {
40 [this, &rhs](auto const i)
41 {
42 this->self().template core<i>() =
43 forward<X>(rhs).template core<i>();
44 });
45 return this->self();
46 }
47
48 template<class X, IsOperatorish R = RemoveReference<X>>
51 IsSame<typename Base::Ranks,
52 typename decltype(round<typename Base::Ranks>(
53 declval<X>()))::Ranks> &&
55 constexpr auto &operator=(X &&rhs)
56 {
57 this->self() = round<typename Base::Ranks>(forward<X>(rhs));
58 return this->self();
59 }
60
61 template<class X>
63 constexpr auto operator+=(X &&rhs)
64 {
65 this->self() = this->self() + forward<X>(rhs);
66 return this->self();
67 }
68
69 template<class X>
71 constexpr auto operator-=(X &&rhs)
72 {
73 this->self() = this->self() - forward<X>(rhs);
74 return this->self();
75 }
76
77 template<class X>
79 constexpr auto applyOnTheLeft(X &&lhs)
80 {
81 this->self() = eval(forward<X>(lhs) * this->self());
82 return this->self();
83 }
84
85 template<class X>
87 constexpr auto applyOnTheRight(X &&rhs)
88 {
89 this->self() = eval(this->self() * forward<X>(rhs));
90 return this->self();
91 }
92
93 template<class X>
95 constexpr auto operator*=(X &&rhs)
96 {
97 return applyOnTheRight(forward<X>(rhs));
98 }
99
100 template<class X>
102 constexpr auto operator/=(X &&rhs)
103 {
104 this->self() = this->self() / forward<X>(rhs);
105 return this->self();
106 }
107
108 protected:
109 ~Assignable() = default;
110 constexpr Assignable(Assignable const &) = default;
111 constexpr Assignable(Assignable &&) = default;
112 constexpr Assignable &operator=(Assignable const &) = delete;
113 constexpr Assignable &operator=(Assignable &&) = delete;
114 constexpr Assignable() = default;
115 };
116}
117#endif // pRC_TENSOR_TRAIN_OPERATOR_VIEWS_ASSIGNABLE_H
constexpr auto operator/=(X &&rhs)
Definition assignable.hpp:102
constexpr auto operator-=(X &&rhs)
Definition assignable.hpp:71
constexpr auto applyOnTheLeft(X &&lhs)
Definition assignable.hpp:79
constexpr auto operator*=(X &&rhs)
Definition assignable.hpp:95
constexpr auto & operator=(Unit<> const)
Definition assignable.hpp:23
constexpr auto operator+=(X &&rhs)
Definition assignable.hpp:63
constexpr Assignable(Assignable const &)=default
constexpr auto & operator=(Identity<> const)
Definition assignable.hpp:28
constexpr Assignable & operator=(Assignable const &)=delete
constexpr Assignable & operator=(Assignable &&)=delete
constexpr auto applyOnTheRight(X &&rhs)
Definition assignable.hpp:87
constexpr auto & operator=(Zero<> const)
Definition assignable.hpp:18
constexpr auto & operator=(X &&rhs)
Definition assignable.hpp:37
constexpr Assignable(Assignable &&)=default
Definition declarations.hpp:25
Definition concepts.hpp:40
Definition concepts.hpp:31
Definition concepts.hpp:28
int i
Definition gmock-matchers-comparisons_test.cc:603
Definition declarations.hpp:23
static constexpr auto unit()
Definition unit.hpp:13
static constexpr auto range(F &&f, Xs &&...args)
Definition range.hpp:18
static constexpr auto identity()
Definition identity.hpp:13
static constexpr auto zero()
Definition zero.hpp:12
static constexpr auto round(T const &a)
Definition round.hpp:11
static constexpr decltype(auto) eval(X &&a)
Definition eval.hpp:12
Definition identity.hpp:11
Definition unit.hpp:11
Definition zero.hpp:11