]>
Commit | Line | Data |
---|---|---|
1 | // The template and inlines for the -*- C++ -*- internal _Meta class. | |
2 | ||
3 | // Copyright (C) 1997-2025 Free Software Foundation, Inc. | |
4 | // | |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // Under Section 7 of GPL version 3, you are granted additional | |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
24 | ||
25 | /** @file bits/valarray_after.h | |
26 | * This is an internal header file, included by other library headers. | |
27 | * Do not attempt to use it directly. @headername{valarray} | |
28 | */ | |
29 | ||
30 | // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@cmla.ens-cachan.fr> | |
31 | ||
32 | #ifndef _VALARRAY_AFTER_H | |
33 | #define _VALARRAY_AFTER_H 1 | |
34 | ||
35 | #ifdef _GLIBCXX_SYSHDR | |
36 | #pragma GCC system_header | |
37 | #endif | |
38 | ||
39 | namespace std _GLIBCXX_VISIBILITY(default) | |
40 | { | |
41 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
42 | ||
43 | namespace __detail | |
44 | { | |
45 | // | |
46 | // gslice_array closure. | |
47 | // | |
48 | template<class _Dom> | |
49 | class _GBase | |
50 | { | |
51 | public: | |
52 | typedef typename _Dom::value_type value_type; | |
53 | ||
54 | _GBase (const _Dom& __e, const valarray<size_t>& __i) | |
55 | : _M_expr (__e), _M_index(__i) {} | |
56 | ||
57 | value_type | |
58 | operator[] (size_t __i) const | |
59 | { return _M_expr[_M_index[__i]]; } | |
60 | ||
61 | size_t | |
62 | size () const | |
63 | { return _M_index.size(); } | |
64 | ||
65 | private: | |
66 | typename _ValArrayRef<_Dom>::__type _M_expr; | |
67 | const valarray<size_t>& _M_index; | |
68 | }; | |
69 | ||
70 | template<typename _Tp> | |
71 | class _GBase<_Array<_Tp> > | |
72 | { | |
73 | public: | |
74 | typedef _Tp value_type; | |
75 | ||
76 | _GBase (_Array<_Tp> __a, const valarray<size_t>& __i) | |
77 | : _M_array (__a), _M_index(__i) {} | |
78 | ||
79 | value_type | |
80 | operator[] (size_t __i) const | |
81 | { return _M_array._M_data[_M_index[__i]]; } | |
82 | ||
83 | size_t | |
84 | size () const | |
85 | { return _M_index.size(); } | |
86 | ||
87 | private: | |
88 | const _Array<_Tp> _M_array; | |
89 | const valarray<size_t>& _M_index; | |
90 | }; | |
91 | ||
92 | template<class _Dom> | |
93 | struct _GClos<_Expr, _Dom> | |
94 | : _GBase<_Dom> | |
95 | { | |
96 | typedef _GBase<_Dom> _Base; | |
97 | typedef typename _Base::value_type value_type; | |
98 | ||
99 | _GClos (const _Dom& __e, const valarray<size_t>& __i) | |
100 | : _Base (__e, __i) {} | |
101 | }; | |
102 | ||
103 | template<typename _Tp> | |
104 | struct _GClos<_ValArray, _Tp> | |
105 | : _GBase<_Array<_Tp> > | |
106 | { | |
107 | typedef _GBase<_Array<_Tp> > _Base; | |
108 | typedef typename _Base::value_type value_type; | |
109 | ||
110 | _GClos (_Array<_Tp> __a, const valarray<size_t>& __i) | |
111 | : _Base (__a, __i) {} | |
112 | }; | |
113 | ||
114 | // | |
115 | // indirect_array closure | |
116 | // | |
117 | template<class _Dom> | |
118 | class _IBase | |
119 | { | |
120 | public: | |
121 | typedef typename _Dom::value_type value_type; | |
122 | ||
123 | _IBase (const _Dom& __e, const valarray<size_t>& __i) | |
124 | : _M_expr (__e), _M_index (__i) {} | |
125 | ||
126 | value_type | |
127 | operator[] (size_t __i) const | |
128 | { return _M_expr[_M_index[__i]]; } | |
129 | ||
130 | size_t | |
131 | size() const | |
132 | { return _M_index.size(); } | |
133 | ||
134 | private: | |
135 | typename _ValArrayRef<_Dom>::__type _M_expr; | |
136 | const valarray<size_t>& _M_index; | |
137 | }; | |
138 | ||
139 | template<class _Dom> | |
140 | struct _IClos<_Expr, _Dom> | |
141 | : _IBase<_Dom> | |
142 | { | |
143 | typedef _IBase<_Dom> _Base; | |
144 | typedef typename _Base::value_type value_type; | |
145 | ||
146 | _IClos (const _Dom& __e, const valarray<size_t>& __i) | |
147 | : _Base (__e, __i) {} | |
148 | }; | |
149 | ||
150 | template<typename _Tp> | |
151 | struct _IClos<_ValArray, _Tp> | |
152 | : _IBase<valarray<_Tp> > | |
153 | { | |
154 | typedef _IBase<valarray<_Tp> > _Base; | |
155 | typedef _Tp value_type; | |
156 | ||
157 | _IClos (const valarray<_Tp>& __a, const valarray<size_t>& __i) | |
158 | : _Base (__a, __i) {} | |
159 | }; | |
160 | } // namespace __detail | |
161 | ||
162 | // | |
163 | // class _Expr | |
164 | // | |
165 | template<class _Clos, typename _Tp> | |
166 | class _Expr | |
167 | { | |
168 | public: | |
169 | typedef _Tp value_type; | |
170 | ||
171 | _Expr(const _Clos&); | |
172 | ||
173 | const _Clos& operator()() const; | |
174 | ||
175 | value_type operator[](size_t) const; | |
176 | valarray<value_type> operator[](slice) const; | |
177 | valarray<value_type> operator[](const gslice&) const; | |
178 | valarray<value_type> operator[](const valarray<bool>&) const; | |
179 | valarray<value_type> operator[](const valarray<size_t>&) const; | |
180 | ||
181 | _Expr<_UnClos<__unary_plus, std::_Expr, _Clos>, value_type> | |
182 | operator+() const; | |
183 | ||
184 | _Expr<_UnClos<__negate, std::_Expr, _Clos>, value_type> | |
185 | operator-() const; | |
186 | ||
187 | _Expr<_UnClos<__bitwise_not, std::_Expr, _Clos>, value_type> | |
188 | operator~() const; | |
189 | ||
190 | _Expr<_UnClos<__logical_not, std::_Expr, _Clos>, bool> | |
191 | operator!() const; | |
192 | ||
193 | size_t size() const; | |
194 | value_type sum() const; | |
195 | ||
196 | valarray<value_type> shift(int) const; | |
197 | valarray<value_type> cshift(int) const; | |
198 | ||
199 | value_type min() const; | |
200 | value_type max() const; | |
201 | ||
202 | valarray<value_type> apply(value_type (*)(const value_type&)) const; | |
203 | valarray<value_type> apply(value_type (*)(value_type)) const; | |
204 | ||
205 | private: | |
206 | const _Clos _M_closure; | |
207 | }; | |
208 | ||
209 | template<class _Clos, typename _Tp> | |
210 | inline | |
211 | _Expr<_Clos, _Tp>::_Expr(const _Clos& __c) : _M_closure(__c) {} | |
212 | ||
213 | template<class _Clos, typename _Tp> | |
214 | inline const _Clos& | |
215 | _Expr<_Clos, _Tp>::operator()() const | |
216 | { return _M_closure; } | |
217 | ||
218 | template<class _Clos, typename _Tp> | |
219 | inline _Tp | |
220 | _Expr<_Clos, _Tp>::operator[](size_t __i) const | |
221 | { return _M_closure[__i]; } | |
222 | ||
223 | template<class _Clos, typename _Tp> | |
224 | inline valarray<_Tp> | |
225 | _Expr<_Clos, _Tp>::operator[](slice __s) const | |
226 | { | |
227 | valarray<_Tp> __v = valarray<_Tp>(*this)[__s]; | |
228 | return __v; | |
229 | } | |
230 | ||
231 | template<class _Clos, typename _Tp> | |
232 | inline valarray<_Tp> | |
233 | _Expr<_Clos, _Tp>::operator[](const gslice& __gs) const | |
234 | { | |
235 | valarray<_Tp> __v = valarray<_Tp>(*this)[__gs]; | |
236 | return __v; | |
237 | } | |
238 | ||
239 | template<class _Clos, typename _Tp> | |
240 | inline valarray<_Tp> | |
241 | _Expr<_Clos, _Tp>::operator[](const valarray<bool>& __m) const | |
242 | { | |
243 | valarray<_Tp> __v = valarray<_Tp>(*this)[__m]; | |
244 | return __v; | |
245 | } | |
246 | ||
247 | template<class _Clos, typename _Tp> | |
248 | inline valarray<_Tp> | |
249 | _Expr<_Clos, _Tp>::operator[](const valarray<size_t>& __i) const | |
250 | { | |
251 | valarray<_Tp> __v = valarray<_Tp>(*this)[__i]; | |
252 | return __v; | |
253 | } | |
254 | ||
255 | template<class _Clos, typename _Tp> | |
256 | inline size_t | |
257 | _Expr<_Clos, _Tp>::size() const | |
258 | { return _M_closure.size(); } | |
259 | ||
260 | template<class _Clos, typename _Tp> | |
261 | inline valarray<_Tp> | |
262 | _Expr<_Clos, _Tp>::shift(int __n) const | |
263 | { | |
264 | valarray<_Tp> __v = valarray<_Tp>(*this).shift(__n); | |
265 | return __v; | |
266 | } | |
267 | ||
268 | template<class _Clos, typename _Tp> | |
269 | inline valarray<_Tp> | |
270 | _Expr<_Clos, _Tp>::cshift(int __n) const | |
271 | { | |
272 | valarray<_Tp> __v = valarray<_Tp>(*this).cshift(__n); | |
273 | return __v; | |
274 | } | |
275 | ||
276 | template<class _Clos, typename _Tp> | |
277 | inline valarray<_Tp> | |
278 | _Expr<_Clos, _Tp>::apply(_Tp __f(const _Tp&)) const | |
279 | { | |
280 | valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); | |
281 | return __v; | |
282 | } | |
283 | ||
284 | template<class _Clos, typename _Tp> | |
285 | inline valarray<_Tp> | |
286 | _Expr<_Clos, _Tp>::apply(_Tp __f(_Tp)) const | |
287 | { | |
288 | valarray<_Tp> __v = valarray<_Tp>(*this).apply(__f); | |
289 | return __v; | |
290 | } | |
291 | ||
292 | // XXX: replace this with a more robust summation algorithm. | |
293 | template<class _Clos, typename _Tp> | |
294 | inline _Tp | |
295 | _Expr<_Clos, _Tp>::sum() const | |
296 | { | |
297 | size_t __n = _M_closure.size(); | |
298 | if (__n == 0) | |
299 | return _Tp(); | |
300 | else | |
301 | { | |
302 | _Tp __s = _M_closure[--__n]; | |
303 | while (__n != 0) | |
304 | __s += _M_closure[--__n]; | |
305 | return __s; | |
306 | } | |
307 | } | |
308 | ||
309 | template<class _Clos, typename _Tp> | |
310 | inline _Tp | |
311 | _Expr<_Clos, _Tp>::min() const | |
312 | { return __valarray_min(_M_closure); } | |
313 | ||
314 | template<class _Clos, typename _Tp> | |
315 | inline _Tp | |
316 | _Expr<_Clos, _Tp>::max() const | |
317 | { return __valarray_max(_M_closure); } | |
318 | ||
319 | template<class _Dom, typename _Tp> | |
320 | inline _Expr<_UnClos<__logical_not, _Expr, _Dom>, bool> | |
321 | _Expr<_Dom, _Tp>::operator!() const | |
322 | { | |
323 | typedef _UnClos<__logical_not, std::_Expr, _Dom> _Closure; | |
324 | return _Expr<_Closure, bool>(_Closure(this->_M_closure)); | |
325 | } | |
326 | ||
327 | #define _DEFINE_EXPR_UNARY_OPERATOR(_Op, _Name) \ | |
328 | template<class _Dom, typename _Tp> \ | |
329 | inline _Expr<_UnClos<_Name, std::_Expr, _Dom>, _Tp> \ | |
330 | _Expr<_Dom, _Tp>::operator _Op() const \ | |
331 | { \ | |
332 | typedef _UnClos<_Name, std::_Expr, _Dom> _Closure; \ | |
333 | return _Expr<_Closure, _Tp>(_Closure(this->_M_closure)); \ | |
334 | } | |
335 | ||
336 | _DEFINE_EXPR_UNARY_OPERATOR(+, struct std::__unary_plus) | |
337 | _DEFINE_EXPR_UNARY_OPERATOR(-, struct std::__negate) | |
338 | _DEFINE_EXPR_UNARY_OPERATOR(~, struct std::__bitwise_not) | |
339 | ||
340 | #undef _DEFINE_EXPR_UNARY_OPERATOR | |
341 | ||
342 | #define _DEFINE_EXPR_BINARY_OPERATOR(_Op, _Name) \ | |
343 | template<class _Dom1, class _Dom2> \ | |
344 | inline _Expr<_BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2>, \ | |
345 | typename __fun<_Name, typename _Dom1::value_type>::result_type> \ | |
346 | operator _Op(const _Expr<_Dom1, typename _Dom1::value_type>& __v, \ | |
347 | const _Expr<_Dom2, typename _Dom2::value_type>& __w) \ | |
348 | { \ | |
349 | typedef typename _Dom1::value_type _Arg; \ | |
350 | typedef typename __fun<_Name, _Arg>::result_type _Value; \ | |
351 | typedef _BinClos<_Name, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ | |
352 | return _Expr<_Closure, _Value>(_Closure(__v(), __w())); \ | |
353 | } \ | |
354 | \ | |
355 | template<class _Dom> \ | |
356 | inline _Expr<_BinClos<_Name, _Expr, _Constant, _Dom, \ | |
357 | typename _Dom::value_type>, \ | |
358 | typename __fun<_Name, typename _Dom::value_type>::result_type> \ | |
359 | operator _Op(const _Expr<_Dom, typename _Dom::value_type>& __v, \ | |
360 | const typename _Dom::value_type& __t) \ | |
361 | { \ | |
362 | typedef typename _Dom::value_type _Arg; \ | |
363 | typedef typename __fun<_Name, _Arg>::result_type _Value; \ | |
364 | typedef _BinClos<_Name, _Expr, _Constant, _Dom, _Arg> _Closure; \ | |
365 | return _Expr<_Closure, _Value>(_Closure(__v(), __t)); \ | |
366 | } \ | |
367 | \ | |
368 | template<class _Dom> \ | |
369 | inline _Expr<_BinClos<_Name, _Constant, _Expr, \ | |
370 | typename _Dom::value_type, _Dom>, \ | |
371 | typename __fun<_Name, typename _Dom::value_type>::result_type> \ | |
372 | operator _Op(const typename _Dom::value_type& __t, \ | |
373 | const _Expr<_Dom, typename _Dom::value_type>& __v) \ | |
374 | { \ | |
375 | typedef typename _Dom::value_type _Arg; \ | |
376 | typedef typename __fun<_Name, _Arg>::result_type _Value; \ | |
377 | typedef _BinClos<_Name, _Constant, _Expr, _Arg, _Dom> _Closure; \ | |
378 | return _Expr<_Closure, _Value>(_Closure(__t, __v())); \ | |
379 | } \ | |
380 | \ | |
381 | template<class _Dom> \ | |
382 | inline _Expr<_BinClos<_Name, _Expr, _ValArray, \ | |
383 | _Dom, typename _Dom::value_type>, \ | |
384 | typename __fun<_Name, typename _Dom::value_type>::result_type> \ | |
385 | operator _Op(const _Expr<_Dom,typename _Dom::value_type>& __e, \ | |
386 | const valarray<typename _Dom::value_type>& __v) \ | |
387 | { \ | |
388 | typedef typename _Dom::value_type _Arg; \ | |
389 | typedef typename __fun<_Name, _Arg>::result_type _Value; \ | |
390 | typedef _BinClos<_Name, _Expr, _ValArray, _Dom, _Arg> _Closure; \ | |
391 | return _Expr<_Closure, _Value>(_Closure(__e(), __v)); \ | |
392 | } \ | |
393 | \ | |
394 | template<class _Dom> \ | |
395 | inline _Expr<_BinClos<_Name, _ValArray, _Expr, \ | |
396 | typename _Dom::value_type, _Dom>, \ | |
397 | typename __fun<_Name, typename _Dom::value_type>::result_type> \ | |
398 | operator _Op(const valarray<typename _Dom::value_type>& __v, \ | |
399 | const _Expr<_Dom, typename _Dom::value_type>& __e) \ | |
400 | { \ | |
401 | typedef typename _Dom::value_type _Tp; \ | |
402 | typedef typename __fun<_Name, _Tp>::result_type _Value; \ | |
403 | typedef _BinClos<_Name, _ValArray, _Expr, _Tp, _Dom> _Closure; \ | |
404 | return _Expr<_Closure, _Value>(_Closure(__v, __e ())); \ | |
405 | } | |
406 | ||
407 | _DEFINE_EXPR_BINARY_OPERATOR(+, struct std::__plus) | |
408 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | |
409 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) | |
410 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | |
411 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | |
412 | _DEFINE_EXPR_BINARY_OPERATOR(^, struct std::__bitwise_xor) | |
413 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | |
414 | _DEFINE_EXPR_BINARY_OPERATOR(|, struct std::__bitwise_or) | |
415 | _DEFINE_EXPR_BINARY_OPERATOR(<<, struct std::__shift_left) | |
416 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right) | |
417 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | |
418 | _DEFINE_EXPR_BINARY_OPERATOR(||, struct std::__logical_or) | |
419 | _DEFINE_EXPR_BINARY_OPERATOR(==, struct std::__equal_to) | |
420 | _DEFINE_EXPR_BINARY_OPERATOR(!=, struct std::__not_equal_to) | |
421 | _DEFINE_EXPR_BINARY_OPERATOR(<, struct std::__less) | |
422 | _DEFINE_EXPR_BINARY_OPERATOR(>, struct std::__greater) | |
423 | _DEFINE_EXPR_BINARY_OPERATOR(<=, struct std::__less_equal) | |
424 | _DEFINE_EXPR_BINARY_OPERATOR(>=, struct std::__greater_equal) | |
425 | ||
426 | #undef _DEFINE_EXPR_BINARY_OPERATOR | |
427 | ||
428 | #define _DEFINE_EXPR_UNARY_FUNCTION(_Name, _UName) \ | |
429 | template<class _Dom> \ | |
430 | inline _Expr<_UnClos<_UName, _Expr, _Dom>, \ | |
431 | typename _Dom::value_type> \ | |
432 | _Name(const _Expr<_Dom, typename _Dom::value_type>& __e) \ | |
433 | { \ | |
434 | typedef typename _Dom::value_type _Tp; \ | |
435 | typedef _UnClos<_UName, _Expr, _Dom> _Closure; \ | |
436 | return _Expr<_Closure, _Tp>(_Closure(__e())); \ | |
437 | } \ | |
438 | \ | |
439 | template<typename _Tp> \ | |
440 | inline _Expr<_UnClos<_UName, _ValArray, _Tp>, _Tp> \ | |
441 | _Name(const valarray<_Tp>& __v) \ | |
442 | { \ | |
443 | typedef _UnClos<_UName, _ValArray, _Tp> _Closure; \ | |
444 | return _Expr<_Closure, _Tp>(_Closure(__v)); \ | |
445 | } | |
446 | ||
447 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | |
448 | _DEFINE_EXPR_UNARY_FUNCTION(cos, struct std::_Cos) | |
449 | _DEFINE_EXPR_UNARY_FUNCTION(acos, struct std::_Acos) | |
450 | _DEFINE_EXPR_UNARY_FUNCTION(cosh, struct std::_Cosh) | |
451 | _DEFINE_EXPR_UNARY_FUNCTION(sin, struct std::_Sin) | |
452 | _DEFINE_EXPR_UNARY_FUNCTION(asin, struct std::_Asin) | |
453 | _DEFINE_EXPR_UNARY_FUNCTION(sinh, struct std::_Sinh) | |
454 | _DEFINE_EXPR_UNARY_FUNCTION(tan, struct std::_Tan) | |
455 | _DEFINE_EXPR_UNARY_FUNCTION(tanh, struct std::_Tanh) | |
456 | _DEFINE_EXPR_UNARY_FUNCTION(atan, struct std::_Atan) | |
457 | _DEFINE_EXPR_UNARY_FUNCTION(exp, struct std::_Exp) | |
458 | _DEFINE_EXPR_UNARY_FUNCTION(log, struct std::_Log) | |
459 | _DEFINE_EXPR_UNARY_FUNCTION(log10, struct std::_Log10) | |
460 | _DEFINE_EXPR_UNARY_FUNCTION(sqrt, struct std::_Sqrt) | |
461 | ||
462 | #undef _DEFINE_EXPR_UNARY_FUNCTION | |
463 | ||
464 | #define _DEFINE_EXPR_BINARY_FUNCTION(_Fun, _UFun) \ | |
465 | template<class _Dom1, class _Dom2> \ | |
466 | inline _Expr<_BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2>, \ | |
467 | typename _Dom1::value_type> \ | |
468 | _Fun(const _Expr<_Dom1, typename _Dom1::value_type>& __e1, \ | |
469 | const _Expr<_Dom2, typename _Dom2::value_type>& __e2) \ | |
470 | { \ | |
471 | typedef typename _Dom1::value_type _Tp; \ | |
472 | typedef _BinClos<_UFun, _Expr, _Expr, _Dom1, _Dom2> _Closure; \ | |
473 | return _Expr<_Closure, _Tp>(_Closure(__e1(), __e2())); \ | |
474 | } \ | |
475 | \ | |
476 | template<class _Dom> \ | |
477 | inline _Expr<_BinClos<_UFun, _Expr, _ValArray, _Dom, \ | |
478 | typename _Dom::value_type>, \ | |
479 | typename _Dom::value_type> \ | |
480 | _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ | |
481 | const valarray<typename _Dom::value_type>& __v) \ | |
482 | { \ | |
483 | typedef typename _Dom::value_type _Tp; \ | |
484 | typedef _BinClos<_UFun, _Expr, _ValArray, _Dom, _Tp> _Closure; \ | |
485 | return _Expr<_Closure, _Tp>(_Closure(__e(), __v)); \ | |
486 | } \ | |
487 | \ | |
488 | template<class _Dom> \ | |
489 | inline _Expr<_BinClos<_UFun, _ValArray, _Expr, \ | |
490 | typename _Dom::value_type, _Dom>, \ | |
491 | typename _Dom::value_type> \ | |
492 | _Fun(const valarray<typename _Dom::valarray>& __v, \ | |
493 | const _Expr<_Dom, typename _Dom::value_type>& __e) \ | |
494 | { \ | |
495 | typedef typename _Dom::value_type _Tp; \ | |
496 | typedef _BinClos<_UFun, _ValArray, _Expr, _Tp, _Dom> _Closure; \ | |
497 | return _Expr<_Closure, _Tp>(_Closure(__v, __e())); \ | |
498 | } \ | |
499 | \ | |
500 | template<class _Dom> \ | |
501 | inline _Expr<_BinClos<_UFun, _Expr, _Constant, _Dom, \ | |
502 | typename _Dom::value_type>, \ | |
503 | typename _Dom::value_type> \ | |
504 | _Fun(const _Expr<_Dom, typename _Dom::value_type>& __e, \ | |
505 | const typename _Dom::value_type& __t) \ | |
506 | { \ | |
507 | typedef typename _Dom::value_type _Tp; \ | |
508 | typedef _BinClos<_UFun, _Expr, _Constant, _Dom, _Tp> _Closure; \ | |
509 | return _Expr<_Closure, _Tp>(_Closure(__e(), __t)); \ | |
510 | } \ | |
511 | \ | |
512 | template<class _Dom> \ | |
513 | inline _Expr<_BinClos<_UFun, _Constant, _Expr, \ | |
514 | typename _Dom::value_type, _Dom>, \ | |
515 | typename _Dom::value_type> \ | |
516 | _Fun(const typename _Dom::value_type& __t, \ | |
517 | const _Expr<_Dom, typename _Dom::value_type>& __e) \ | |
518 | { \ | |
519 | typedef typename _Dom::value_type _Tp; \ | |
520 | typedef _BinClos<_UFun, _Constant, _Expr, _Tp, _Dom> _Closure; \ | |
521 | return _Expr<_Closure, _Tp>(_Closure(__t, __e())); \ | |
522 | } \ | |
523 | \ | |
524 | template<typename _Tp> \ | |
525 | inline _Expr<_BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp>, _Tp> \ | |
526 | _Fun(const valarray<_Tp>& __v, const valarray<_Tp>& __w) \ | |
527 | { \ | |
528 | typedef _BinClos<_UFun, _ValArray, _ValArray, _Tp, _Tp> _Closure;\ | |
529 | return _Expr<_Closure, _Tp>(_Closure(__v, __w)); \ | |
530 | } \ | |
531 | \ | |
532 | template<typename _Tp> \ | |
533 | inline _Expr<_BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp>, _Tp> \ | |
534 | _Fun(const valarray<_Tp>& __v, \ | |
535 | const typename valarray<_Tp>::value_type& __t) \ | |
536 | { \ | |
537 | typedef _BinClos<_UFun, _ValArray, _Constant, _Tp, _Tp> _Closure;\ | |
538 | return _Expr<_Closure, _Tp>(_Closure(__v, __t)); \ | |
539 | } \ | |
540 | \ | |
541 | template<typename _Tp> \ | |
542 | inline _Expr<_BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp>, _Tp> \ | |
543 | _Fun(const typename valarray<_Tp>::value_type& __t, \ | |
544 | const valarray<_Tp>& __v) \ | |
545 | { \ | |
546 | typedef _BinClos<_UFun, _Constant, _ValArray, _Tp, _Tp> _Closure;\ | |
547 | return _Expr<_Closure, _Tp>(_Closure(__t, __v)); \ | |
548 | } | |
549 | ||
550 | _DEFINE_EXPR_BINARY_FUNCTION(atan2, struct std::_Atan2) | |
551 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow) | |
552 | ||
553 | #undef _DEFINE_EXPR_BINARY_FUNCTION | |
554 | ||
555 | _GLIBCXX_END_NAMESPACE_VERSION | |
556 | } // namespace | |
557 | ||
558 | #endif /* _CPP_VALARRAY_AFTER_H */ |