xtensor
Loading...
Searching...
No Matches
xnoalias.hpp
1/***************************************************************************
2 * Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
3 * Copyright (c) QuantStack *
4 * *
5 * Distributed under the terms of the BSD 3-Clause License. *
6 * *
7 * The full license is in the file LICENSE, distributed with this software. *
8 ****************************************************************************/
9
10#ifndef XTENSOR_NOALIAS_HPP
11#define XTENSOR_NOALIAS_HPP
12
13#include "xsemantic.hpp"
14
15namespace xt
16{
17
18 template <class A>
20 {
21 public:
22
23 noalias_proxy(A a) noexcept;
24
25 template <class E>
26 disable_xexpression<E, A> operator=(const E&);
27
28 template <class E>
29 disable_xexpression<E, A> operator+=(const E&);
30
31 template <class E>
32 disable_xexpression<E, A> operator-=(const E&);
33
34 template <class E>
35 disable_xexpression<E, A> operator*=(const E&);
36
37 template <class E>
38 disable_xexpression<E, A> operator/=(const E&);
39
40 template <class E>
41 disable_xexpression<E, A> operator%=(const E&);
42
43 template <class E>
44 disable_xexpression<E, A> operator&=(const E&);
45
46 template <class E>
47 disable_xexpression<E, A> operator|=(const E&);
48
49 template <class E>
50 disable_xexpression<E, A> operator^=(const E&);
51
52 template <class E>
53 A operator=(const xexpression<E>& e);
54
55 template <class E>
56 A operator+=(const xexpression<E>& e);
57
58 template <class E>
59 A operator-=(const xexpression<E>& e);
60
61 template <class E>
62 A operator*=(const xexpression<E>& e);
63
64 template <class E>
65 A operator/=(const xexpression<E>& e);
66
67 template <class E>
68 A operator%=(const xexpression<E>& e);
69
70 template <class E>
71 A operator&=(const xexpression<E>&);
72
73 template <class E>
74 A operator|=(const xexpression<E>&);
75
76 template <class E>
77 A operator^=(const xexpression<E>&);
78
79 private:
80
81 A m_array;
82 };
83
84 template <class A>
85 noalias_proxy<xtl::closure_type_t<A>> noalias(A&& a) noexcept;
86
87 /********************************
88 * noalias_proxy implementation *
89 ********************************/
90
91 template <class A>
93 : m_array(std::forward<A>(a))
94 {
95 }
96
97 template <class A>
98 template <class E>
99 inline auto noalias_proxy<A>::operator=(const E& e) -> disable_xexpression<E, A>
100 {
101 return m_array.assign(xscalar<E>(e));
102 }
103
104 template <class A>
105 template <class E>
106 inline auto noalias_proxy<A>::operator+=(const E& e) -> disable_xexpression<E, A>
107 {
108 return m_array.scalar_computed_assign(e, std::plus<>());
109 }
110
111 template <class A>
112 template <class E>
113 inline auto noalias_proxy<A>::operator-=(const E& e) -> disable_xexpression<E, A>
114 {
115 return m_array.scalar_computed_assign(e, std::minus<>());
116 }
117
118 template <class A>
119 template <class E>
120 inline auto noalias_proxy<A>::operator*=(const E& e) -> disable_xexpression<E, A>
121 {
122 return m_array.scalar_computed_assign(e, std::multiplies<>());
123 }
124
125 template <class A>
126 template <class E>
127 inline auto noalias_proxy<A>::operator/=(const E& e) -> disable_xexpression<E, A>
128 {
129 return m_array.scalar_computed_assign(e, std::divides<>());
130 }
131
132 template <class A>
133 template <class E>
134 inline auto noalias_proxy<A>::operator%=(const E& e) -> disable_xexpression<E, A>
135 {
136 return m_array.scalar_computed_assign(e, std::modulus<>());
137 }
138
139 template <class A>
140 template <class E>
141 inline auto noalias_proxy<A>::operator&=(const E& e) -> disable_xexpression<E, A>
142 {
143 return m_array.scalar_computed_assign(e, std::bit_and<>());
144 }
145
146 template <class A>
147 template <class E>
148 inline auto noalias_proxy<A>::operator|=(const E& e) -> disable_xexpression<E, A>
149 {
150 return m_array.scalar_computed_assign(e, std::bit_or<>());
151 }
152
153 template <class A>
154 template <class E>
155 inline auto noalias_proxy<A>::operator^=(const E& e) -> disable_xexpression<E, A>
156 {
157 return m_array.scalar_computed_assign(e, std::bit_xor<>());
158 }
159
160 template <class A>
161 template <class E>
162 inline A noalias_proxy<A>::operator=(const xexpression<E>& e)
163 {
164 return m_array.assign(e);
165 }
166
167 template <class A>
168 template <class E>
169 inline A noalias_proxy<A>::operator+=(const xexpression<E>& e)
170 {
171 return m_array.plus_assign(e);
172 }
173
174 template <class A>
175 template <class E>
176 inline A noalias_proxy<A>::operator-=(const xexpression<E>& e)
177 {
178 return m_array.minus_assign(e);
179 }
180
181 template <class A>
182 template <class E>
183 inline A noalias_proxy<A>::operator*=(const xexpression<E>& e)
184 {
185 return m_array.multiplies_assign(e);
186 }
187
188 template <class A>
189 template <class E>
190 inline A noalias_proxy<A>::operator/=(const xexpression<E>& e)
191 {
192 return m_array.divides_assign(e);
193 }
194
195 template <class A>
196 template <class E>
197 inline A noalias_proxy<A>::operator%=(const xexpression<E>& e)
198 {
199 return m_array.modulus_assign(e);
200 }
201
202 template <class A>
203 template <class E>
204 inline A noalias_proxy<A>::operator&=(const xexpression<E>& e)
205 {
206 return m_array.bit_and_assign(e);
207 }
208
209 template <class A>
210 template <class E>
211 inline A noalias_proxy<A>::operator|=(const xexpression<E>& e)
212 {
213 return m_array.bit_or_assign(e);
214 }
215
216 template <class A>
217 template <class E>
218 inline A noalias_proxy<A>::operator^=(const xexpression<E>& e)
219 {
220 return m_array.bit_xor_assign(e);
221 }
222
223 template <class A>
224 inline noalias_proxy<xtl::closure_type_t<A>> noalias(A&& a) noexcept
225 {
226 return noalias_proxy<xtl::closure_type_t<A>>(a);
227 }
228}
229
230#endif
standard mathematical functions for xexpressions