source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Blitz/blitz/array/ops.cc

Last change on this file was 658, checked in by ansari, 26 years ago

no message

File size: 8.7 KB
Line 
1#ifndef BZ_ARRAYOPS_CC
2#define BZ_ARRAYOPS_CC
3
4#ifndef BZ_ARRAY_H
5 #error <blitz/array/ops.cc> must be included via <blitz/array.h>
6#endif
7
8#ifndef BZ_UPDATE_H
9 #include <blitz/update.h>
10#endif
11
12BZ_NAMESPACE(blitz)
13
14/*
15 * Constant operands
16 */
17
18template<class T_numtype, int N_rank>
19inline Array<T_numtype, N_rank>& Array<T_numtype,N_rank>::initialize(
20 T_numtype x)
21{
22 (*this) = _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
23 return *this;
24}
25
26template<class T_numtype, int N_rank>
27inline Array<T_numtype, N_rank>&
28Array<T_numtype,N_rank>::operator+=(T_numtype x)
29{
30 (*this) += _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
31 return *this;
32}
33
34template<class T_numtype, int N_rank>
35inline Array<T_numtype, N_rank>&
36Array<T_numtype,N_rank>::operator-=(T_numtype x)
37{
38 (*this) -= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
39 return *this;
40}
41
42template<class T_numtype, int N_rank>
43inline Array<T_numtype, N_rank>&
44Array<T_numtype,N_rank>::operator*=(T_numtype x)
45{
46 (*this) *= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
47 return *this;
48}
49
50template<class T_numtype, int N_rank>
51inline Array<T_numtype, N_rank>&
52Array<T_numtype,N_rank>::operator/=(T_numtype x)
53{
54 (*this) /= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
55 return *this;
56}
57
58template<class T_numtype, int N_rank>
59inline Array<T_numtype, N_rank>&
60Array<T_numtype,N_rank>::operator%=(T_numtype x)
61{
62 (*this) %= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
63 return *this;
64}
65
66template<class T_numtype, int N_rank>
67inline Array<T_numtype, N_rank>&
68Array<T_numtype,N_rank>::operator^=(T_numtype x)
69{
70 (*this) ^= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
71 return *this;
72}
73
74template<class T_numtype, int N_rank>
75inline Array<T_numtype, N_rank>&
76Array<T_numtype,N_rank>::operator&=(T_numtype x)
77{
78 (*this) &= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
79 return *this;
80}
81
82template<class T_numtype, int N_rank>
83inline Array<T_numtype, N_rank>&
84Array<T_numtype,N_rank>::operator|=(T_numtype x)
85{
86 (*this) |= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
87 return *this;
88}
89
90template<class T_numtype, int N_rank>
91inline Array<T_numtype, N_rank>&
92Array<T_numtype,N_rank>::operator>>=(T_numtype x)
93{
94 (*this) <<= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
95 return *this;
96}
97
98template<class T_numtype, int N_rank>
99inline Array<T_numtype, N_rank>&
100Array<T_numtype,N_rank>::operator<<=(T_numtype x)
101{
102 (*this) <<= _bz_ArrayExpr<_bz_ArrayExprConstant<T_numtype> >(x);
103 return *this;
104}
105
106/*
107 * Array operands
108 */
109
110template<class T_numtype, int N_rank>
111inline Array<T_numtype, N_rank>&
112Array<T_numtype, N_rank>::operator=(const Array<T_numtype,N_rank>& x)
113{
114 (*this) = _bz_ArrayExpr<ArrayIterator<T_numtype, N_rank> >(x.begin());
115 return *this;
116}
117
118template<class T_numtype, int N_rank> template<class T_numtype2>
119inline Array<T_numtype, N_rank>&
120Array<T_numtype, N_rank>::operator=(const Array<T_numtype2,N_rank>& x)
121{
122 (*this) = _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
123 return *this;
124}
125
126template<class T_numtype, int N_rank> template<class T_numtype2>
127inline Array<T_numtype, N_rank>&
128Array<T_numtype, N_rank>::operator+=(const Array<T_numtype2,N_rank>& x)
129{
130 (*this) += _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
131 return *this;
132}
133
134template<class T_numtype, int N_rank> template<class T_numtype2>
135inline Array<T_numtype, N_rank>&
136Array<T_numtype, N_rank>::operator-=(const Array<T_numtype2,N_rank>& x)
137{
138 (*this) -= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
139 return *this;
140}
141
142template<class T_numtype, int N_rank> template<class T_numtype2>
143inline Array<T_numtype, N_rank>&
144Array<T_numtype, N_rank>::operator*=(const Array<T_numtype2,N_rank>& x)
145{
146 (*this) *= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
147 return *this;
148}
149
150template<class T_numtype, int N_rank> template<class T_numtype2>
151inline Array<T_numtype, N_rank>&
152Array<T_numtype, N_rank>::operator/=(const Array<T_numtype2,N_rank>& x)
153{
154 (*this) /= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
155 return *this;
156}
157
158template<class T_numtype, int N_rank> template<class T_numtype2>
159inline Array<T_numtype, N_rank>&
160Array<T_numtype, N_rank>::operator%=(const Array<T_numtype2,N_rank>& x)
161{
162 (*this) %= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
163 return *this;
164}
165
166template<class T_numtype, int N_rank> template<class T_numtype2>
167inline Array<T_numtype, N_rank>&
168Array<T_numtype, N_rank>::operator^=(const Array<T_numtype2,N_rank>& x)
169{
170 (*this) ^= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
171 return *this;
172}
173
174template<class T_numtype, int N_rank> template<class T_numtype2>
175inline Array<T_numtype, N_rank>&
176Array<T_numtype, N_rank>::operator&=(const Array<T_numtype2,N_rank>& x)
177{
178 (*this) &= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
179 return *this;
180}
181
182template<class T_numtype, int N_rank> template<class T_numtype2>
183inline Array<T_numtype, N_rank>&
184Array<T_numtype, N_rank>::operator|=(const Array<T_numtype2,N_rank>& x)
185{
186 (*this) |= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
187 return *this;
188}
189
190template<class T_numtype, int N_rank> template<class T_numtype2>
191inline Array<T_numtype, N_rank>&
192Array<T_numtype, N_rank>::operator>>=(const Array<T_numtype2,N_rank>& x)
193{
194 (*this) >>= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
195 return *this;
196}
197
198template<class T_numtype, int N_rank> template<class T_numtype2>
199inline Array<T_numtype, N_rank>&
200Array<T_numtype, N_rank>::operator<<=(const Array<T_numtype2,N_rank>& x)
201{
202 (*this) <<= _bz_ArrayExpr<ArrayIterator<T_numtype2, N_rank> >(x.begin());
203 return *this;
204}
205
206/*
207 * Array expression operands
208 */
209
210template<class T_numtype, int N_rank> template<class T_expr>
211inline Array<T_numtype, N_rank>&
212Array<T_numtype, N_rank>::operator=(_bz_ArrayExpr<T_expr> expr)
213{
214 evaluate(expr, _bz_update<T_numtype, _bz_typename T_expr::T_numtype>());
215 return *this;
216}
217
218template<class T_numtype, int N_rank> template<class T_expr>
219inline Array<T_numtype, N_rank>&
220Array<T_numtype, N_rank>::operator+=(_bz_ArrayExpr<T_expr> expr)
221{
222 evaluate(expr, _bz_plus_update<T_numtype, _bz_typename T_expr::T_numtype>());
223 return *this;
224}
225
226template<class T_numtype, int N_rank> template<class T_expr>
227inline Array<T_numtype, N_rank>&
228Array<T_numtype, N_rank>::operator-=(_bz_ArrayExpr<T_expr> expr)
229{
230 evaluate(expr, _bz_minus_update<T_numtype,
231 _bz_typename T_expr::T_numtype>());
232 return *this;
233}
234
235template<class T_numtype, int N_rank> template<class T_expr>
236inline Array<T_numtype, N_rank>&
237Array<T_numtype, N_rank>::operator*=(_bz_ArrayExpr<T_expr> expr)
238{
239 evaluate(expr, _bz_multiply_update<T_numtype,
240 _bz_typename T_expr::T_numtype>());
241 return *this;
242}
243
244template<class T_numtype, int N_rank> template<class T_expr>
245inline Array<T_numtype, N_rank>&
246Array<T_numtype, N_rank>::operator/=(_bz_ArrayExpr<T_expr> expr)
247{
248 evaluate(expr, _bz_divide_update<T_numtype,
249 _bz_typename T_expr::T_numtype>());
250 return *this;
251}
252
253template<class T_numtype, int N_rank> template<class T_expr>
254inline Array<T_numtype, N_rank>&
255Array<T_numtype, N_rank>::operator%=(_bz_ArrayExpr<T_expr> expr)
256{
257 evaluate(expr, _bz_mod_update<T_numtype,
258 _bz_typename T_expr::T_numtype>());
259 return *this;
260}
261
262template<class T_numtype, int N_rank> template<class T_expr>
263inline Array<T_numtype, N_rank>&
264Array<T_numtype, N_rank>::operator^=(_bz_ArrayExpr<T_expr> expr)
265{
266 evaluate(expr, _bz_xor_update<T_numtype,
267 _bz_typename T_expr::T_numtype>());
268 return *this;
269}
270
271template<class T_numtype, int N_rank> template<class T_expr>
272inline Array<T_numtype, N_rank>&
273Array<T_numtype, N_rank>::operator&=(_bz_ArrayExpr<T_expr> expr)
274{
275 evaluate(expr, _bz_bitand_update<T_numtype,
276 _bz_typename T_expr::T_numtype>());
277 return *this;
278}
279
280template<class T_numtype, int N_rank> template<class T_expr>
281inline Array<T_numtype, N_rank>&
282Array<T_numtype, N_rank>::operator|=(_bz_ArrayExpr<T_expr> expr)
283{
284 evaluate(expr, _bz_bitor_update<T_numtype,
285 _bz_typename T_expr::T_numtype>());
286 return *this;
287}
288
289template<class T_numtype, int N_rank> template<class T_expr>
290inline Array<T_numtype, N_rank>&
291Array<T_numtype, N_rank>::operator>>=(_bz_ArrayExpr<T_expr> expr)
292{
293 evaluate(expr, _bz_shiftr_update<T_numtype,
294 _bz_typename T_expr::T_numtype>());
295 return *this;
296}
297
298template<class T_numtype, int N_rank> template<class T_expr>
299inline Array<T_numtype, N_rank>&
300Array<T_numtype, N_rank>::operator<<=(_bz_ArrayExpr<T_expr> expr)
301{
302 evaluate(expr, _bz_shiftl_update<T_numtype,
303 _bz_typename T_expr::T_numtype>());
304 return *this;
305}
306
307BZ_NAMESPACE_END
308
309#endif // BZ_ARRAYOPS_CC
Note: See TracBrowser for help on using the repository browser.