33 #ifndef _VALARRAY_BEFORE_H
34 #define _VALARRAY_BEFORE_H 1
36 #pragma GCC system_header
40 namespace std _GLIBCXX_VISIBILITY(default)
42 _GLIBCXX_BEGIN_NAMESPACE_VERSION
54 template<
typename _Tp1,
typename _Tp2>
class _Constant;
66 template<
typename _Tp>
67 _Tp operator()(
const _Tp& __t)
const
73 template<
typename _Tp>
74 _Tp operator()(
const _Tp& __t)
const
80 template<
typename _Tp>
81 _Tp operator()(
const _Tp& __t)
const
87 template<
typename _Tp>
88 _Tp operator()(
const _Tp& __t)
const
94 template<
typename _Tp>
95 _Tp operator()(
const _Tp& __t)
const
101 template<
typename _Tp>
102 _Tp operator()(
const _Tp& __t)
const
103 {
return asin(__t); }
108 template<
typename _Tp>
109 _Tp operator()(
const _Tp& __t)
const
110 {
return sinh(__t); }
115 template<
typename _Tp>
116 _Tp operator()(
const _Tp& __t)
const
122 template<
typename _Tp>
123 _Tp operator()(
const _Tp& __t)
const
124 {
return atan(__t); }
129 template<
typename _Tp>
130 _Tp operator()(
const _Tp& __t)
const
131 {
return tanh(__t); }
136 template<
typename _Tp>
137 _Tp operator()(
const _Tp& __t)
const
143 template<
typename _Tp>
144 _Tp operator()(
const _Tp& __t)
const
150 template<
typename _Tp>
151 _Tp operator()(
const _Tp& __t)
const
152 {
return log10(__t); }
157 template<
typename _Tp>
158 _Tp operator()(
const _Tp& __t)
const
159 {
return sqrt(__t); }
168 template<
typename _Tp>
169 _Tp operator()(
const _Tp& __t)
const
175 template<
typename _Tp>
176 _Tp operator()(
const _Tp& __t)
const
182 template<
typename _Tp>
183 _Tp operator()(
const _Tp& __t)
const
189 template<
typename _Tp>
190 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
191 {
return __x + __y; }
196 template<
typename _Tp>
197 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
198 {
return __x - __y; }
203 template<
typename _Tp>
204 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
205 {
return __x * __y; }
210 template<
typename _Tp>
211 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
212 {
return __x / __y; }
217 template<
typename _Tp>
218 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
219 {
return __x % __y; }
224 template<
typename _Tp>
225 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
226 {
return __x ^ __y; }
231 template<
typename _Tp>
232 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
233 {
return __x & __y; }
238 template<
typename _Tp>
239 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
240 {
return __x | __y; }
245 template<
typename _Tp>
246 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
247 {
return __x << __y; }
252 template<
typename _Tp>
253 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
254 {
return __x >> __y; }
259 template<
typename _Tp>
260 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
261 {
return __x && __y; }
266 template<
typename _Tp>
267 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
268 {
return __x || __y; }
273 template<
typename _Tp>
274 bool operator()(
const _Tp& __x)
const
280 template<
typename _Tp>
281 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
282 {
return __x == __y; }
285 struct __not_equal_to
287 template<
typename _Tp>
288 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
289 {
return __x != __y; }
294 template<
typename _Tp>
295 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
296 {
return __x < __y; }
301 template<
typename _Tp>
302 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
303 {
return __x > __y; }
308 template<
typename _Tp>
309 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
310 {
return __x <= __y; }
313 struct __greater_equal
315 template<
typename _Tp>
316 bool operator()(
const _Tp& __x,
const _Tp& __y)
const
317 {
return __x >= __y; }
323 template<
typename _Tp>
324 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
325 {
return atan2(__x, __y); }
330 template<
typename _Tp>
331 _Tp operator()(
const _Tp& __x,
const _Tp& __y)
const
332 {
return pow(__x, __y); }
339 template<
typename,
typename _Tp>
342 typedef _Tp result_type;
346 template<
typename _Tp>
347 struct __fun<__logical_not, _Tp>
349 typedef bool result_type;
352 template<
typename _Tp>
353 struct __fun<__logical_and, _Tp>
355 typedef bool result_type;
358 template<
typename _Tp>
359 struct __fun<__logical_or, _Tp>
361 typedef bool result_type;
364 template<
typename _Tp>
365 struct __fun<__less, _Tp>
367 typedef bool result_type;
370 template<
typename _Tp>
371 struct __fun<__greater, _Tp>
373 typedef bool result_type;
376 template<
typename _Tp>
377 struct __fun<__less_equal, _Tp>
379 typedef bool result_type;
382 template<
typename _Tp>
383 struct __fun<__greater_equal, _Tp>
385 typedef bool result_type;
388 template<
typename _Tp>
389 struct __fun<__equal_to, _Tp>
391 typedef bool result_type;
394 template<
typename _Tp>
395 struct __fun<__not_equal_to, _Tp>
397 typedef bool result_type;
404 template<
typename _Dom,
typename _Arg>
408 typedef typename _Dom::value_type value_type;
410 _FunBase(
const _Dom& __e, value_type __f(_Arg))
411 : _M_expr(__e), _M_func(__f) {}
414 {
return _M_func (_M_expr[__i]); }
416 size_t size()
const {
return _M_expr.size ();}
420 value_type (*_M_func)(_Arg);
424 struct _ValFunClos<_Expr,_Dom> : _FunBase<_Dom, typename _Dom::value_type>
426 typedef _FunBase<_Dom, typename _Dom::value_type> _Base;
427 typedef typename _Base::value_type value_type;
428 typedef value_type _Tp;
430 _ValFunClos(
const _Dom& __e, _Tp __f(_Tp)) : _Base(__e, __f) {}
433 template<
typename _Tp>
434 struct _ValFunClos<_ValArray,_Tp> : _FunBase<valarray<_Tp>, _Tp>
436 typedef _FunBase<valarray<_Tp>, _Tp> _Base;
437 typedef _Tp value_type;
439 _ValFunClos(
const valarray<_Tp>& __v, _Tp __f(_Tp)) : _Base(__v, __f) {}
443 struct _RefFunClos<_Expr, _Dom>
444 : _FunBase<_Dom, const typename _Dom::value_type&>
446 typedef _FunBase<_Dom, const typename _Dom::value_type&> _Base;
447 typedef typename _Base::value_type value_type;
448 typedef value_type _Tp;
450 _RefFunClos(
const _Dom& __e, _Tp __f(
const _Tp&))
454 template<
typename _Tp>
455 struct _RefFunClos<_ValArray, _Tp>
456 : _FunBase<valarray<_Tp>, const _Tp&>
458 typedef _FunBase<valarray<_Tp>,
const _Tp&> _Base;
459 typedef _Tp value_type;
461 _RefFunClos(
const valarray<_Tp>& __v, _Tp __f(
const _Tp&))
469 template<
class _Oper,
class _Arg>
473 typedef typename _Arg::value_type _Vt;
474 typedef typename __fun<_Oper, _Vt>::result_type value_type;
476 _UnBase(
const _Arg& __e) : _M_expr(__e) {}
479 {
return _Oper()(_M_expr[__i]); }
481 size_t size()
const {
return _M_expr.size(); }
487 template<
class _Oper,
class _Dom>
488 struct _UnClos<_Oper, _Expr, _Dom>
489 : _UnBase<_Oper, _Dom>
492 typedef _UnBase<_Oper, _Dom> _Base;
493 typedef typename _Base::value_type value_type;
495 _UnClos(
const _Arg& __e) : _Base(__e) {}
498 template<
class _Oper,
typename _Tp>
499 struct _UnClos<_Oper, _ValArray, _Tp>
500 : _UnBase<_Oper, valarray<_Tp> >
502 typedef valarray<_Tp> _Arg;
503 typedef _UnBase<_Oper, valarray<_Tp> > _Base;
504 typedef typename _Base::value_type value_type;
506 _UnClos(
const _Arg& __e) : _Base(__e) {}
514 template<
class _Oper,
class _FirstArg,
class _SecondArg>
518 typedef typename _FirstArg::value_type _Vt;
519 typedef typename __fun<_Oper, _Vt>::result_type value_type;
521 _BinBase(
const _FirstArg& __e1,
const _SecondArg& __e2)
522 : _M_expr1(__e1), _M_expr2(__e2) {}
525 {
return _Oper()(_M_expr1[__i], _M_expr2[__i]); }
527 size_t size()
const {
return _M_expr1.size(); }
530 const _FirstArg& _M_expr1;
531 const _SecondArg& _M_expr2;
535 template<
class _Oper,
class _Clos>
539 typedef typename _Clos::value_type _Vt;
540 typedef typename __fun<_Oper, _Vt>::result_type value_type;
542 _BinBase2(
const _Clos& __e,
const _Vt& __t)
543 : _M_expr1(__e), _M_expr2(__t) {}
546 {
return _Oper()(_M_expr1[__i], _M_expr2); }
548 size_t size()
const {
return _M_expr1.size(); }
551 const _Clos& _M_expr1;
555 template<
class _Oper,
class _Clos>
559 typedef typename _Clos::value_type _Vt;
560 typedef typename __fun<_Oper, _Vt>::result_type value_type;
562 _BinBase1(
const _Vt& __t,
const _Clos& __e)
563 : _M_expr1(__t), _M_expr2(__e) {}
566 {
return _Oper()(_M_expr1, _M_expr2[__i]); }
568 size_t size()
const {
return _M_expr2.size(); }
572 const _Clos& _M_expr2;
575 template<
class _Oper,
class _Dom1,
class _Dom2>
576 struct _BinClos<_Oper, _Expr, _Expr, _Dom1, _Dom2>
577 : _BinBase<_Oper, _Dom1, _Dom2>
579 typedef _BinBase<_Oper, _Dom1, _Dom2> _Base;
580 typedef typename _Base::value_type value_type;
582 _BinClos(
const _Dom1& __e1,
const _Dom2& __e2) : _Base(__e1, __e2) {}
585 template<
class _Oper,
typename _Tp>
586 struct _BinClos<_Oper,_ValArray, _ValArray, _Tp, _Tp>
587 : _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> >
589 typedef _BinBase<_Oper, valarray<_Tp>, valarray<_Tp> > _Base;
590 typedef typename _Base::value_type value_type;
592 _BinClos(
const valarray<_Tp>& __v,
const valarray<_Tp>& __w)
596 template<
class _Oper,
class _Dom>
597 struct _BinClos<_Oper, _Expr, _ValArray, _Dom, typename _Dom::value_type>
598 : _BinBase<_Oper, _Dom, valarray<typename _Dom::value_type> >
600 typedef typename _Dom::value_type _Tp;
601 typedef _BinBase<_Oper,_Dom,valarray<_Tp> > _Base;
602 typedef typename _Base::value_type value_type;
604 _BinClos(
const _Dom& __e1,
const valarray<_Tp>& __e2)
605 : _Base(__e1, __e2) {}
608 template<
class _Oper,
class _Dom>
609 struct _BinClos<_Oper, _ValArray, _Expr, typename _Dom::value_type, _Dom>
610 : _BinBase<_Oper, valarray<typename _Dom::value_type>,_Dom>
612 typedef typename _Dom::value_type _Tp;
613 typedef _BinBase<_Oper, valarray<_Tp>, _Dom> _Base;
614 typedef typename _Base::value_type value_type;
616 _BinClos(
const valarray<_Tp>& __e1,
const _Dom& __e2)
617 : _Base(__e1, __e2) {}
620 template<
class _Oper,
class _Dom>
621 struct _BinClos<_Oper, _Expr, _Constant, _Dom, typename _Dom::value_type>
622 : _BinBase2<_Oper, _Dom>
624 typedef typename _Dom::value_type _Tp;
625 typedef _BinBase2<_Oper,_Dom> _Base;
626 typedef typename _Base::value_type value_type;
628 _BinClos(
const _Dom& __e1,
const _Tp& __e2) : _Base(__e1, __e2) {}
631 template<
class _Oper,
class _Dom>
632 struct _BinClos<_Oper, _Constant, _Expr, typename _Dom::value_type, _Dom>
633 : _BinBase1<_Oper, _Dom>
635 typedef typename _Dom::value_type _Tp;
636 typedef _BinBase1<_Oper, _Dom> _Base;
637 typedef typename _Base::value_type value_type;
639 _BinClos(
const _Tp& __e1,
const _Dom& __e2) : _Base(__e1, __e2) {}
642 template<
class _Oper,
typename _Tp>
643 struct _BinClos<_Oper, _ValArray, _Constant, _Tp, _Tp>
644 : _BinBase2<_Oper, valarray<_Tp> >
646 typedef _BinBase2<_Oper,valarray<_Tp> > _Base;
647 typedef typename _Base::value_type value_type;
649 _BinClos(
const valarray<_Tp>& __v,
const _Tp& __t) : _Base(__v, __t) {}
652 template<
class _Oper,
typename _Tp>
653 struct _BinClos<_Oper, _Constant, _ValArray, _Tp, _Tp>
654 : _BinBase1<_Oper, valarray<_Tp> >
656 typedef _BinBase1<_Oper, valarray<_Tp> > _Base;
657 typedef typename _Base::value_type value_type;
659 _BinClos(
const _Tp& __t,
const valarray<_Tp>& __v) : _Base(__t, __v) {}
665 template<
typename _Dom>
669 typedef typename _Dom::value_type value_type;
671 _SBase (
const _Dom& __e,
const slice& __s)
672 : _M_expr (__e), _M_slice (__s) {}
676 {
return _M_expr[_M_slice.start () + __i * _M_slice.stride ()]; }
680 {
return _M_slice.size (); }
684 const slice& _M_slice;
687 template<
typename _Tp>
688 class _SBase<_Array<_Tp> >
691 typedef _Tp value_type;
693 _SBase (_Array<_Tp> __a,
const slice& __s)
694 : _M_array (__a._M_data+__s.start()), _M_size (__s.
size()),
695 _M_stride (__s.stride()) {}
699 {
return _M_array._M_data[__i * _M_stride]; }
706 const _Array<_Tp> _M_array;
707 const size_t _M_size;
708 const size_t _M_stride;
712 struct _SClos<_Expr, _Dom>
715 typedef _SBase<_Dom> _Base;
716 typedef typename _Base::value_type value_type;
718 _SClos (
const _Dom& __e,
const slice& __s) : _Base (__e, __s) {}
721 template<
typename _Tp>
722 struct _SClos<_ValArray, _Tp>
723 : _SBase<_Array<_Tp> >
725 typedef _SBase<_Array<_Tp> > _Base;
726 typedef _Tp value_type;
728 _SClos (_Array<_Tp> __a,
const slice& __s) : _Base (__a, __s) {}
731 _GLIBCXX_END_NAMESPACE_VERSION
reference operator[](size_t __position)
Array-indexing support.
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
complex< _Tp > pow(const complex< _Tp > &, const _Tp &)
Return x to the y'th power.
std::complex< _Tp > asin(const std::complex< _Tp > &)
asin(__z) [8.1.3].
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
constexpr size_t size() const
Returns the total number of bits.
std::complex< _Tp > acos(const std::complex< _Tp > &)
acos(__z) [8.1.2].
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
std::complex< _Tp > atan(const std::complex< _Tp > &)
atan(__z) [8.1.4].
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.