32 #ifndef _VALARRAY_BEFORE_H
33 #define _VALARRAY_BEFORE_H 1
35 #pragma GCC system_header
39 namespace std _GLIBCXX_VISIBILITY(default)
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
53 template<
typename _Tp1,
typename _Tp2>
class _Constant;
65 template<
typename _Tp>
66 _Tp operator()(
const _Tp& __t)
const
72 template<
typename _Tp>
73 _Tp operator()(
const _Tp& __t)
const
79 template<
typename _Tp>
80 _Tp operator()(
const _Tp& __t)
const
86 template<
typename _Tp>
87 _Tp operator()(
const _Tp& __t)
const
93 template<
typename _Tp>
94 _Tp operator()(
const _Tp& __t)
const
100 template<
typename _Tp>
101 _Tp operator()(
const _Tp& __t)
const
102 {
return asin(__t); }
107 template<
typename _Tp>
108 _Tp operator()(
const _Tp& __t)
const
109 {
return sinh(__t); }
114 template<
typename _Tp>
115 _Tp operator()(
const _Tp& __t)
const
121 template<
typename _Tp>
122 _Tp operator()(
const _Tp& __t)
const
123 {
return atan(__t); }
128 template<
typename _Tp>
129 _Tp operator()(
const _Tp& __t)
const
130 {
return tanh(__t); }
135 template<
typename _Tp>
136 _Tp operator()(
const _Tp& __t)
const
142 template<
typename _Tp>
143 _Tp operator()(
const _Tp& __t)
const
149 template<
typename _Tp>
150 _Tp operator()(
const _Tp& __t)
const
151 {
return log10(__t); }
156 template<
typename _Tp>
157 _Tp operator()(
const _Tp& __t)
const
158 {
return sqrt(__t); }
167 template<
typename _Tp>
168 _Tp operator()(
const _Tp& __t)
const
174 template<
typename _Tp>
175 _Tp operator()(
const _Tp& __t)
const
181 template<
typename _Tp>
182 _Tp operator()(
const _Tp& __t)
const
188 template<
typename _Tp>
189 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
190 {
return __x + __y; }
195 template<
typename _Tp>
196 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
197 {
return __x - __y; }
202 template<
typename _Tp>
203 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
204 {
return __x * __y; }
209 template<
typename _Tp>
210 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
211 {
return __x / __y; }
216 template<
typename _Tp>
217 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
218 {
return __x % __y; }
223 template<
typename _Tp>
224 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
225 {
return __x ^ __y; }
230 template<
typename _Tp>
231 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
232 {
return __x & __y; }
237 template<
typename _Tp>
238 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
239 {
return __x | __y; }
244 template<
typename _Tp>
245 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
246 {
return __x << __y; }
251 template<
typename _Tp>
252 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
253 {
return __x >> __y; }
258 template<
typename _Tp>
259 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
260 {
return __x && __y; }
265 template<
typename _Tp>
266 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
267 {
return __x || __y; }
272 template<
typename _Tp>
273 bool operator()(
const _Tp& __x)
const
279 template<
typename _Tp>
280 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
281 {
return __x == __y; }
284 struct __not_equal_to
286 template<
typename _Tp>
287 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
288 {
return __x != __y; }
293 template<
typename _Tp>
294 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
295 {
return __x < __y; }
300 template<
typename _Tp>
301 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
302 {
return __x > __y; }
307 template<
typename _Tp>
308 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
309 {
return __x <= __y; }
312 struct __greater_equal
314 template<
typename _Tp>
315 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
316 {
return __x >= __y; }
322 template<
typename _Tp>
323 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
324 {
return atan2(__x, __y); }
329 template<
typename _Tp>
330 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
331 {
return pow(__x, __y); }
338 template<
typename,
typename _Tp>
341 typedef _Tp result_type;
345 template<
typename _Tp>
346 struct __fun<__logical_not, _Tp>
348 typedef bool result_type;
351 template<
typename _Tp>
352 struct __fun<__logical_and, _Tp>
354 typedef bool result_type;
357 template<
typename _Tp>
358 struct __fun<__logical_or, _Tp>
360 typedef bool result_type;
363 template<
typename _Tp>
364 struct __fun<__less, _Tp>
366 typedef bool result_type;
369 template<
typename _Tp>
370 struct __fun<__greater, _Tp>
372 typedef bool result_type;
375 template<
typename _Tp>
376 struct __fun<__less_equal, _Tp>
378 typedef bool result_type;
381 template<
typename _Tp>
382 struct __fun<__greater_equal, _Tp>
384 typedef bool result_type;
387 template<
typename _Tp>
388 struct __fun<__equal_to, _Tp>
390 typedef bool result_type;
393 template<
typename _Tp>
394 struct __fun<__not_equal_to, _Tp>
396 typedef bool result_type;
403 template<
typename _Dom,
typename _Arg>
407 typedef typename _Dom::value_type value_type;
409 _FunBase(
const _Dom& __e, value_type __f(_Arg))
410 : _M_expr(__e), _M_func(__f) {}
412 value_type operator[](
size_t __i)
const
413 {
return _M_func (_M_expr[__i]); }
415 size_t size()
const {
return _M_expr.size ();}
419 value_type (*_M_func)(_Arg);
423 struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
425 typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
426 typedef typename _Base::value_type value_type;
427 typedef value_type _Tp;
429 _ValFunClos(
const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
432 template<
typename _Tp>
433 struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
435 typedef _FunBase<valarray<_Tp>, _Tp> _Base;
436 typedef _Tp value_type;
438 _ValFunClos(
const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
442 struct _RefFunClos<_Expr, _Dom>
443 : _FunBase<_Dom, const typename _Dom::value_type&>
445 typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
446 typedef typename _Base::value_type value_type;
447 typedef value_type _Tp;
449 _RefFunClos(
const _Dom& __e, _Tp __f(
const _Tp&))
453 template<
typename _Tp>
454 struct _RefFunClos<_ValArray, _Tp>
455 : _FunBase<valarray<_Tp>, const _Tp&>
457 typedef _FunBase<valarray<_Tp>,
const _Tp&> _Base;
458 typedef _Tp value_type;
460 _RefFunClos(
const valarray<_Tp>& __v, _Tp __f(
const _Tp&))
468 template<
class _Oper,
class _Arg>
472 typedef typename _Arg::value_type _Vt;
473 typedef typename __fun<_Oper, _Vt>::result_type value_type;
475 _UnBase(
const _Arg& __e) : _M_expr(__e) {}
477 value_type operator[](
size_t __i)
const
478 {
return _Oper()(_M_expr[__i]); }
480 size_t size()
const {
return _M_expr.size(); }
486 template<
class _Oper,
class _Dom>
487 struct _UnClos<_Oper, _Expr, _Dom>
488 : _UnBase<_Oper, _Dom>
491 typedef _UnBase<_Oper, _Dom> _Base;
492 typedef typename _Base::value_type value_type;
494 _UnClos(
const _Arg& __e) : _Base(__e) {}
497 template<
class _Oper,
typename _Tp>
498 struct _UnClos<_Oper, _ValArray, _Tp>
499 : _UnBase<_Oper, valarray<_Tp> >
501 typedef valarray<_Tp> _Arg;
502 typedef _UnBase<_Oper, valarray<_Tp> > _Base;
503 typedef typename _Base::value_type value_type;
505 _UnClos(
const _Arg& __e) : _Base(__e) {}
513 template<
class _Oper,
class _FirstArg,
class _SecondArg>
517 typedef typename _FirstArg::value_type _Vt;
518 typedef typename __fun<_Oper, _Vt>::result_type value_type;
520 _BinBase(
const _FirstArg& __e1,
const _SecondArg& __e2)
521 : _M_expr1(__e1), _M_expr2(__e2) {}
523 value_type operator[](
size_t __i)
const
524 {
return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
526 size_t size()
const {
return _M_expr1.size(); }
529 const _FirstArg& _M_expr1;
530 const _SecondArg& _M_expr2;
534 template<
class _Oper,
class _Clos>
538 typedef typename _Clos::value_type _Vt;
539 typedef typename __fun<_Oper, _Vt>::result_type value_type;
541 _BinBase2(
const _Clos& __e,
const _Vt& __t)
542 : _M_expr1(__e), _M_expr2(__t) {}
544 value_type operator[](
size_t __i)
const
545 {
return _Oper()(_M_expr1[__i], _M_expr2); }
547 size_t size()
const {
return _M_expr1.size(); }
550 const _Clos& _M_expr1;
554 template<
class _Oper,
class _Clos>
558 typedef typename _Clos::value_type _Vt;
559 typedef typename __fun<_Oper, _Vt>::result_type value_type;
561 _BinBase1(
const _Vt& __t,
const _Clos& __e)
562 : _M_expr1(__t), _M_expr2(__e) {}
564 value_type operator[](
size_t __i)
const
565 {
return _Oper()(_M_expr1, _M_expr2[__i]); }
567 size_t size()
const {
return _M_expr2.size(); }
571 const _Clos& _M_expr2;
574 template<
class _Oper,
class _Dom1,
class _Dom2>
575 struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
576 : _BinBase<_Oper, _Dom1, _Dom2>
578 typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
579 typedef typename _Base::value_type value_type;
581 _BinClos(
const _Dom1& __e1,
const _Dom2& __e2) : _Base(__e1, __e2) {}
584 template<
class _Oper,
typename _Tp>
585 struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
586 : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
588 typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
589 typedef typename _Base::value_type value_type;
591 _BinClos(
const valarray<_Tp>& __v,
const valarray<_Tp>& __w)
595 template<
class _Oper,
class _Dom>
596 struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
597 : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
599 typedef typename _Dom::value_type _Tp;
600 typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
601 typedef typename _Base::value_type value_type;
603 _BinClos(
const _Dom& __e1,
const valarray<_Tp>& __e2)
604 : _Base(__e1, __e2) {}
607 template<
class _Oper,
class _Dom>
608 struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
609 : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
611 typedef typename _Dom::value_type _Tp;
612 typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
613 typedef typename _Base::value_type value_type;
615 _BinClos(
const valarray<_Tp>& __e1,
const _Dom& __e2)
616 : _Base(__e1, __e2) {}
619 template<
class _Oper,
class _Dom>
620 struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
621 : _BinBase2<_Oper, _Dom>
623 typedef typename _Dom::value_type _Tp;
624 typedef _BinBase2<_Oper,_Dom> _Base;
625 typedef typename _Base::value_type value_type;
627 _BinClos(
const _Dom& __e1,
const _Tp& __e2) : _Base(__e1, __e2) {}
630 template<
class _Oper,
class _Dom>
631 struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
632 : _BinBase1<_Oper, _Dom>
634 typedef typename _Dom::value_type _Tp;
635 typedef _BinBase1<_Oper, _Dom> _Base;
636 typedef typename _Base::value_type value_type;
638 _BinClos(
const _Tp& __e1,
const _Dom& __e2) : _Base(__e1, __e2) {}
641 template<
class _Oper,
typename _Tp>
642 struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
643 : _BinBase2<_Oper, valarray<_Tp> >
645 typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
646 typedef typename _Base::value_type value_type;
648 _BinClos(
const valarray<_Tp>& __v,
const _Tp& __t) : _Base(__v, __t) {}
651 template<
class _Oper,
typename _Tp>
652 struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
653 : _BinBase1<_Oper, valarray<_Tp> >
655 typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
656 typedef typename _Base::value_type value_type;
658 _BinClos(
const _Tp& __t,
const valarray<_Tp>& __v) : _Base(__t, __v) {}
664 template<
typename _Dom>
668 typedef typename _Dom::value_type value_type;
670 _SBase (
const _Dom& __e,
const slice& __s)
671 : _M_expr (__e), _M_slice (__s) {}
674 operator[] (
size_t __i)
const
675 {
return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
679 {
return _M_slice.size (); }
683 const slice& _M_slice;
686 template<
typename _Tp>
687 class _SBase<_Array<_Tp> >
690 typedef _Tp value_type;
692 _SBase (_Array<_Tp> __a,
const slice& __s)
693 : _M_array (__a._M_data+__s.start()), _M_size (__s.size()),
694 _M_stride (__s.stride()) {}
697 operator[] (
size_t __i)
const
698 {
return _M_array._M_data[__i * _M_stride]; }
705 const _Array<_Tp> _M_array;
706 const size_t _M_size;
707 const size_t _M_stride;
711 struct _SClos<_Expr, _Dom>
714 typedef _SBase<_Dom> _Base;
715 typedef typename _Base::value_type value_type;
717 _SClos (
const _Dom& __e,
const slice& __s) : _Base (__e, __s) {}
720 template<
typename _Tp>
721 struct _SClos<_ValArray, _Tp>
722 : _SBase<_Array<_Tp> >
724 typedef _SBase<_Array<_Tp> > _Base;
725 typedef _Tp value_type;
727 _SClos (_Array<_Tp> __a,
const slice& __s) : _Base (__a, __s) {}
730 _GLIBCXX_END_NAMESPACE_VERSION
ISO C++ entities toplevel namespace is std.