2 //===-------------------------- valarray ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_VALARRAY
12 #define _LIBCPP_VALARRAY
28 explicit valarray(size_t n);
29 valarray(const value_type& x, size_t n);
30 valarray(const value_type* px, size_t n);
31 valarray(const valarray& v);
32 valarray(valarray&& v) noexcept;
33 valarray(const slice_array<value_type>& sa);
34 valarray(const gslice_array<value_type>& ga);
35 valarray(const mask_array<value_type>& ma);
36 valarray(const indirect_array<value_type>& ia);
37 valarray(initializer_list<value_type> il);
41 valarray& operator=(const valarray& v);
42 valarray& operator=(valarray&& v) noexcept;
43 valarray& operator=(initializer_list<value_type> il);
44 valarray& operator=(const value_type& x);
45 valarray& operator=(const slice_array<value_type>& sa);
46 valarray& operator=(const gslice_array<value_type>& ga);
47 valarray& operator=(const mask_array<value_type>& ma);
48 valarray& operator=(const indirect_array<value_type>& ia);
51 const value_type& operator[](size_t i) const;
52 value_type& operator[](size_t i);
55 valarray operator[](slice s) const;
56 slice_array<value_type> operator[](slice s);
57 valarray operator[](const gslice& gs) const;
58 gslice_array<value_type> operator[](const gslice& gs);
59 valarray operator[](const valarray<bool>& vb) const;
60 mask_array<value_type> operator[](const valarray<bool>& vb);
61 valarray operator[](const valarray<size_t>& vs) const;
62 indirect_array<value_type> operator[](const valarray<size_t>& vs);
65 valarray operator+() const;
66 valarray operator-() const;
67 valarray operator~() const;
68 valarray<bool> operator!() const;
70 // computed assignment:
71 valarray& operator*= (const value_type& x);
72 valarray& operator/= (const value_type& x);
73 valarray& operator%= (const value_type& x);
74 valarray& operator+= (const value_type& x);
75 valarray& operator-= (const value_type& x);
76 valarray& operator^= (const value_type& x);
77 valarray& operator&= (const value_type& x);
78 valarray& operator|= (const value_type& x);
79 valarray& operator<<=(const value_type& x);
80 valarray& operator>>=(const value_type& x);
82 valarray& operator*= (const valarray& v);
83 valarray& operator/= (const valarray& v);
84 valarray& operator%= (const valarray& v);
85 valarray& operator+= (const valarray& v);
86 valarray& operator-= (const valarray& v);
87 valarray& operator^= (const valarray& v);
88 valarray& operator|= (const valarray& v);
89 valarray& operator&= (const valarray& v);
90 valarray& operator<<=(const valarray& v);
91 valarray& operator>>=(const valarray& v);
94 void swap(valarray& v) noexcept;
98 value_type sum() const;
99 value_type min() const;
100 value_type max() const;
102 valarray shift (int i) const;
103 valarray cshift(int i) const;
104 valarray apply(value_type f(value_type)) const;
105 valarray apply(value_type f(const value_type&)) const;
106 void resize(size_t n, value_type x = value_type());
113 slice(size_t start, size_t size, size_t stride);
115 size_t start() const;
117 size_t stride() const;
124 typedef T value_type;
126 const slice_array& operator=(const slice_array& sa) const;
127 void operator= (const valarray<value_type>& v) const;
128 void operator*= (const valarray<value_type>& v) const;
129 void operator/= (const valarray<value_type>& v) const;
130 void operator%= (const valarray<value_type>& v) const;
131 void operator+= (const valarray<value_type>& v) const;
132 void operator-= (const valarray<value_type>& v) const;
133 void operator^= (const valarray<value_type>& v) const;
134 void operator&= (const valarray<value_type>& v) const;
135 void operator|= (const valarray<value_type>& v) const;
136 void operator<<=(const valarray<value_type>& v) const;
137 void operator>>=(const valarray<value_type>& v) const;
139 void operator=(const value_type& x) const;
141 slice_array() = delete;
148 gslice(size_t start, const valarray<size_t>& size,
149 const valarray<size_t>& stride);
151 size_t start() const;
152 valarray<size_t> size() const;
153 valarray<size_t> stride() const;
160 typedef T value_type;
162 void operator= (const valarray<value_type>& v) const;
163 void operator*= (const valarray<value_type>& v) const;
164 void operator/= (const valarray<value_type>& v) const;
165 void operator%= (const valarray<value_type>& v) const;
166 void operator+= (const valarray<value_type>& v) const;
167 void operator-= (const valarray<value_type>& v) const;
168 void operator^= (const valarray<value_type>& v) const;
169 void operator&= (const valarray<value_type>& v) const;
170 void operator|= (const valarray<value_type>& v) const;
171 void operator<<=(const valarray<value_type>& v) const;
172 void operator>>=(const valarray<value_type>& v) const;
174 gslice_array(const gslice_array& ga);
176 const gslice_array& operator=(const gslice_array& ga) const;
177 void operator=(const value_type& x) const;
179 gslice_array() = delete;
186 typedef T value_type;
188 void operator= (const valarray<value_type>& v) const;
189 void operator*= (const valarray<value_type>& v) const;
190 void operator/= (const valarray<value_type>& v) const;
191 void operator%= (const valarray<value_type>& v) const;
192 void operator+= (const valarray<value_type>& v) const;
193 void operator-= (const valarray<value_type>& v) const;
194 void operator^= (const valarray<value_type>& v) const;
195 void operator&= (const valarray<value_type>& v) const;
196 void operator|= (const valarray<value_type>& v) const;
197 void operator<<=(const valarray<value_type>& v) const;
198 void operator>>=(const valarray<value_type>& v) const;
200 mask_array(const mask_array& ma);
202 const mask_array& operator=(const mask_array& ma) const;
203 void operator=(const value_type& x) const;
205 mask_array() = delete;
212 typedef T value_type;
214 void operator= (const valarray<value_type>& v) const;
215 void operator*= (const valarray<value_type>& v) const;
216 void operator/= (const valarray<value_type>& v) const;
217 void operator%= (const valarray<value_type>& v) const;
218 void operator+= (const valarray<value_type>& v) const;
219 void operator-= (const valarray<value_type>& v) const;
220 void operator^= (const valarray<value_type>& v) const;
221 void operator&= (const valarray<value_type>& v) const;
222 void operator|= (const valarray<value_type>& v) const;
223 void operator<<=(const valarray<value_type>& v) const;
224 void operator>>=(const valarray<value_type>& v) const;
226 indirect_array(const indirect_array& ia);
228 const indirect_array& operator=(const indirect_array& ia) const;
229 void operator=(const value_type& x) const;
231 indirect_array() = delete;
234 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
236 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
237 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
238 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
240 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
241 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
242 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
244 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
245 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
246 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
248 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
249 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
250 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
252 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
253 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
254 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
256 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
257 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
258 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
260 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
261 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
262 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
264 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
265 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
266 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
268 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
269 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
270 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
272 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
273 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
274 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
276 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
277 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
278 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
280 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
281 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
282 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
284 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
285 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
286 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
288 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
289 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
290 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
292 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
293 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
294 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
296 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
297 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
298 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
300 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
301 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
302 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
304 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
305 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
306 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
308 template<class T> valarray<T> abs (const valarray<T>& x);
309 template<class T> valarray<T> acos (const valarray<T>& x);
310 template<class T> valarray<T> asin (const valarray<T>& x);
311 template<class T> valarray<T> atan (const valarray<T>& x);
313 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
314 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
315 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
317 template<class T> valarray<T> cos (const valarray<T>& x);
318 template<class T> valarray<T> cosh (const valarray<T>& x);
319 template<class T> valarray<T> exp (const valarray<T>& x);
320 template<class T> valarray<T> log (const valarray<T>& x);
321 template<class T> valarray<T> log10(const valarray<T>& x);
323 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
324 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
325 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
327 template<class T> valarray<T> sin (const valarray<T>& x);
328 template<class T> valarray<T> sinh (const valarray<T>& x);
329 template<class T> valarray<T> sqrt (const valarray<T>& x);
330 template<class T> valarray<T> tan (const valarray<T>& x);
331 template<class T> valarray<T> tanh (const valarray<T>& x);
333 template <class T> unspecified1 begin(valarray<T>& v);
334 template <class T> unspecified2 begin(const valarray<T>& v);
335 template <class T> unspecified1 end(valarray<T>& v);
336 template <class T> unspecified2 end(const valarray<T>& v);
345 #include <initializer_list>
347 #include <functional>
350 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
351 #pragma GCC system_header
355 #include <__undef_macros>
358 _LIBCPP_BEGIN_NAMESPACE_STD
360 template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
362 class _LIBCPP_TEMPLATE_VIS slice
368 _LIBCPP_INLINE_VISIBILITY
375 _LIBCPP_INLINE_VISIBILITY
376 slice(size_t __start, size_t __size, size_t __stride)
382 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
383 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
384 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
387 template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
388 class _LIBCPP_TYPE_VIS gslice;
389 template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
390 template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
391 template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
394 _LIBCPP_INLINE_VISIBILITY
396 begin(valarray<_Tp>& __v);
399 _LIBCPP_INLINE_VISIBILITY
401 begin(const valarray<_Tp>& __v);
404 _LIBCPP_INLINE_VISIBILITY
406 end(valarray<_Tp>& __v);
409 _LIBCPP_INLINE_VISIBILITY
411 end(const valarray<_Tp>& __v);
413 template <class _Op, class _A0>
416 typedef typename _Op::result_type result_type;
417 typedef typename _A0::value_type value_type;
422 _LIBCPP_INLINE_VISIBILITY
423 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
425 _LIBCPP_INLINE_VISIBILITY
426 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
428 _LIBCPP_INLINE_VISIBILITY
429 size_t size() const {return __a0_.size();}
432 template <class _Op, class _A0, class _A1>
435 typedef typename _Op::result_type result_type;
436 typedef typename _A0::value_type value_type;
442 _LIBCPP_INLINE_VISIBILITY
443 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
444 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
446 _LIBCPP_INLINE_VISIBILITY
447 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
449 _LIBCPP_INLINE_VISIBILITY
450 size_t size() const {return __a0_.size();}
457 typedef _Tp value_type;
458 typedef const _Tp& result_type;
460 const value_type& __t_;
463 _LIBCPP_INLINE_VISIBILITY
464 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
466 _LIBCPP_INLINE_VISIBILITY
467 result_type operator[](size_t) const {return __t_;}
469 _LIBCPP_INLINE_VISIBILITY
470 size_t size() const {return __s_;}
474 struct __unary_plus : unary_function<_Tp, _Tp>
476 _LIBCPP_INLINE_VISIBILITY
477 _Tp operator()(const _Tp& __x) const
482 struct __bit_not : unary_function<_Tp, _Tp>
484 _LIBCPP_INLINE_VISIBILITY
485 _Tp operator()(const _Tp& __x) const
490 struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
492 _LIBCPP_INLINE_VISIBILITY
493 _Tp operator()(const _Tp& __x, const _Tp& __y) const
498 struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
500 _LIBCPP_INLINE_VISIBILITY
501 _Tp operator()(const _Tp& __x, const _Tp& __y) const
505 template <class _Tp, class _Fp>
506 struct __apply_expr : unary_function<_Tp, _Tp>
511 _LIBCPP_INLINE_VISIBILITY
512 explicit __apply_expr(_Fp __f) : __f_(__f) {}
514 _LIBCPP_INLINE_VISIBILITY
515 _Tp operator()(const _Tp& __x) const
520 struct __abs_expr : unary_function<_Tp, _Tp>
522 _LIBCPP_INLINE_VISIBILITY
523 _Tp operator()(const _Tp& __x) const
528 struct __acos_expr : unary_function<_Tp, _Tp>
530 _LIBCPP_INLINE_VISIBILITY
531 _Tp operator()(const _Tp& __x) const
536 struct __asin_expr : unary_function<_Tp, _Tp>
538 _LIBCPP_INLINE_VISIBILITY
539 _Tp operator()(const _Tp& __x) const
544 struct __atan_expr : unary_function<_Tp, _Tp>
546 _LIBCPP_INLINE_VISIBILITY
547 _Tp operator()(const _Tp& __x) const
552 struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
554 _LIBCPP_INLINE_VISIBILITY
555 _Tp operator()(const _Tp& __x, const _Tp& __y) const
556 {return atan2(__x, __y);}
560 struct __cos_expr : unary_function<_Tp, _Tp>
562 _LIBCPP_INLINE_VISIBILITY
563 _Tp operator()(const _Tp& __x) const
568 struct __cosh_expr : unary_function<_Tp, _Tp>
570 _LIBCPP_INLINE_VISIBILITY
571 _Tp operator()(const _Tp& __x) const
576 struct __exp_expr : unary_function<_Tp, _Tp>
578 _LIBCPP_INLINE_VISIBILITY
579 _Tp operator()(const _Tp& __x) const
584 struct __log_expr : unary_function<_Tp, _Tp>
586 _LIBCPP_INLINE_VISIBILITY
587 _Tp operator()(const _Tp& __x) const
592 struct __log10_expr : unary_function<_Tp, _Tp>
594 _LIBCPP_INLINE_VISIBILITY
595 _Tp operator()(const _Tp& __x) const
600 struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
602 _LIBCPP_INLINE_VISIBILITY
603 _Tp operator()(const _Tp& __x, const _Tp& __y) const
604 {return pow(__x, __y);}
608 struct __sin_expr : unary_function<_Tp, _Tp>
610 _LIBCPP_INLINE_VISIBILITY
611 _Tp operator()(const _Tp& __x) const
616 struct __sinh_expr : unary_function<_Tp, _Tp>
618 _LIBCPP_INLINE_VISIBILITY
619 _Tp operator()(const _Tp& __x) const
624 struct __sqrt_expr : unary_function<_Tp, _Tp>
626 _LIBCPP_INLINE_VISIBILITY
627 _Tp operator()(const _Tp& __x) const
632 struct __tan_expr : unary_function<_Tp, _Tp>
634 _LIBCPP_INLINE_VISIBILITY
635 _Tp operator()(const _Tp& __x) const
640 struct __tanh_expr : unary_function<_Tp, _Tp>
642 _LIBCPP_INLINE_VISIBILITY
643 _Tp operator()(const _Tp& __x) const
647 template <class _ValExpr>
650 typedef typename remove_reference<_ValExpr>::type _RmExpr;
652 typedef typename _RmExpr::value_type value_type;
653 typedef value_type result_type;
661 _LIBCPP_INLINE_VISIBILITY
662 __slice_expr(const slice& __sl, const _RmExpr& __e)
664 __start_(__sl.start()),
665 __size_(__sl.size()),
666 __stride_(__sl.stride())
670 _LIBCPP_INLINE_VISIBILITY
671 result_type operator[](size_t __i) const
672 {return __expr_[__start_ + __i * __stride_];}
674 _LIBCPP_INLINE_VISIBILITY
675 size_t size() const {return __size_;}
677 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
680 template <class _ValExpr>
683 template <class _ValExpr>
684 class __indirect_expr;
686 template <class _ValExpr>
689 typedef typename remove_reference<_ValExpr>::type _RmExpr;
691 typedef typename _RmExpr::value_type value_type;
692 typedef value_type result_type;
700 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
701 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
703 _LIBCPP_INLINE_VISIBILITY
704 __shift_expr(int __n, const _RmExpr& __e)
709 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
710 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
711 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
715 _LIBCPP_INLINE_VISIBILITY
716 result_type operator[](size_t __j) const
718 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
719 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
720 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
723 _LIBCPP_INLINE_VISIBILITY
724 size_t size() const {return __size_;}
726 template <class> friend class __val_expr;
729 template <class _ValExpr>
732 typedef typename remove_reference<_ValExpr>::type _RmExpr;
734 typedef typename _RmExpr::value_type value_type;
735 typedef value_type result_type;
744 _LIBCPP_INLINE_VISIBILITY
745 __cshift_expr(int __n, const _RmExpr& __e)
749 __n %= static_cast<int>(__size_);
752 __m_ = __size_ - __n;
754 __o2_ = __n - __size_;
759 __o1_ = __n + __size_;
765 _LIBCPP_INLINE_VISIBILITY
766 result_type operator[](size_t __i) const
769 return __expr_[__i + __o1_];
770 return __expr_[__i + __o2_];
773 _LIBCPP_INLINE_VISIBILITY
774 size_t size() const {return __size_;}
776 template <class> friend class __val_expr;
779 template<class _ValExpr>
782 template<class _ValExpr>
783 struct __is_val_expr : false_type {};
785 template<class _ValExpr>
786 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
789 struct __is_val_expr<valarray<_Tp> > : true_type {};
792 class _LIBCPP_TEMPLATE_VIS valarray
795 typedef _Tp value_type;
796 typedef _Tp result_type;
799 value_type* __begin_;
803 // construct/destroy:
804 _LIBCPP_INLINE_VISIBILITY
805 valarray() : __begin_(0), __end_(0) {}
806 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
807 explicit valarray(size_t __n);
808 _LIBCPP_INLINE_VISIBILITY
809 valarray(const value_type& __x, size_t __n);
810 valarray(const value_type* __p, size_t __n);
811 valarray(const valarray& __v);
812 #ifndef _LIBCPP_CXX03_LANG
813 _LIBCPP_INLINE_VISIBILITY
814 valarray(valarray&& __v) _NOEXCEPT;
815 valarray(initializer_list<value_type> __il);
816 #endif // _LIBCPP_CXX03_LANG
817 valarray(const slice_array<value_type>& __sa);
818 valarray(const gslice_array<value_type>& __ga);
819 valarray(const mask_array<value_type>& __ma);
820 valarray(const indirect_array<value_type>& __ia);
821 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
825 valarray& operator=(const valarray& __v);
826 #ifndef _LIBCPP_CXX03_LANG
827 _LIBCPP_INLINE_VISIBILITY
828 valarray& operator=(valarray&& __v) _NOEXCEPT;
829 _LIBCPP_INLINE_VISIBILITY
830 valarray& operator=(initializer_list<value_type>);
831 #endif // _LIBCPP_CXX03_LANG
832 _LIBCPP_INLINE_VISIBILITY
833 valarray& operator=(const value_type& __x);
834 _LIBCPP_INLINE_VISIBILITY
835 valarray& operator=(const slice_array<value_type>& __sa);
836 _LIBCPP_INLINE_VISIBILITY
837 valarray& operator=(const gslice_array<value_type>& __ga);
838 _LIBCPP_INLINE_VISIBILITY
839 valarray& operator=(const mask_array<value_type>& __ma);
840 _LIBCPP_INLINE_VISIBILITY
841 valarray& operator=(const indirect_array<value_type>& __ia);
842 template <class _ValExpr>
843 _LIBCPP_INLINE_VISIBILITY
844 valarray& operator=(const __val_expr<_ValExpr>& __v);
847 _LIBCPP_INLINE_VISIBILITY
848 const value_type& operator[](size_t __i) const {return __begin_[__i];}
850 _LIBCPP_INLINE_VISIBILITY
851 value_type& operator[](size_t __i) {return __begin_[__i];}
853 // subset operations:
854 _LIBCPP_INLINE_VISIBILITY
855 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
856 _LIBCPP_INLINE_VISIBILITY
857 slice_array<value_type> operator[](slice __s);
858 _LIBCPP_INLINE_VISIBILITY
859 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
860 _LIBCPP_INLINE_VISIBILITY
861 gslice_array<value_type> operator[](const gslice& __gs);
862 #ifndef _LIBCPP_CXX03_LANG
863 _LIBCPP_INLINE_VISIBILITY
864 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
865 _LIBCPP_INLINE_VISIBILITY
866 gslice_array<value_type> operator[](gslice&& __gs);
867 #endif // _LIBCPP_CXX03_LANG
868 _LIBCPP_INLINE_VISIBILITY
869 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
870 _LIBCPP_INLINE_VISIBILITY
871 mask_array<value_type> operator[](const valarray<bool>& __vb);
872 #ifndef _LIBCPP_CXX03_LANG
873 _LIBCPP_INLINE_VISIBILITY
874 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
875 _LIBCPP_INLINE_VISIBILITY
876 mask_array<value_type> operator[](valarray<bool>&& __vb);
877 #endif // _LIBCPP_CXX03_LANG
878 _LIBCPP_INLINE_VISIBILITY
879 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
880 _LIBCPP_INLINE_VISIBILITY
881 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
882 #ifndef _LIBCPP_CXX03_LANG
883 _LIBCPP_INLINE_VISIBILITY
884 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
885 _LIBCPP_INLINE_VISIBILITY
886 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
887 #endif // _LIBCPP_CXX03_LANG
890 valarray operator+() const;
891 valarray operator-() const;
892 valarray operator~() const;
893 valarray<bool> operator!() const;
895 // computed assignment:
896 _LIBCPP_INLINE_VISIBILITY
897 valarray& operator*= (const value_type& __x);
898 _LIBCPP_INLINE_VISIBILITY
899 valarray& operator/= (const value_type& __x);
900 _LIBCPP_INLINE_VISIBILITY
901 valarray& operator%= (const value_type& __x);
902 _LIBCPP_INLINE_VISIBILITY
903 valarray& operator+= (const value_type& __x);
904 _LIBCPP_INLINE_VISIBILITY
905 valarray& operator-= (const value_type& __x);
906 _LIBCPP_INLINE_VISIBILITY
907 valarray& operator^= (const value_type& __x);
908 _LIBCPP_INLINE_VISIBILITY
909 valarray& operator&= (const value_type& __x);
910 _LIBCPP_INLINE_VISIBILITY
911 valarray& operator|= (const value_type& __x);
912 _LIBCPP_INLINE_VISIBILITY
913 valarray& operator<<=(const value_type& __x);
914 _LIBCPP_INLINE_VISIBILITY
915 valarray& operator>>=(const value_type& __x);
917 template <class _Expr>
920 __is_val_expr<_Expr>::value,
923 _LIBCPP_INLINE_VISIBILITY
924 operator*= (const _Expr& __v);
926 template <class _Expr>
929 __is_val_expr<_Expr>::value,
932 _LIBCPP_INLINE_VISIBILITY
933 operator/= (const _Expr& __v);
935 template <class _Expr>
938 __is_val_expr<_Expr>::value,
941 _LIBCPP_INLINE_VISIBILITY
942 operator%= (const _Expr& __v);
944 template <class _Expr>
947 __is_val_expr<_Expr>::value,
950 _LIBCPP_INLINE_VISIBILITY
951 operator+= (const _Expr& __v);
953 template <class _Expr>
956 __is_val_expr<_Expr>::value,
959 _LIBCPP_INLINE_VISIBILITY
960 operator-= (const _Expr& __v);
962 template <class _Expr>
965 __is_val_expr<_Expr>::value,
968 _LIBCPP_INLINE_VISIBILITY
969 operator^= (const _Expr& __v);
971 template <class _Expr>
974 __is_val_expr<_Expr>::value,
977 _LIBCPP_INLINE_VISIBILITY
978 operator|= (const _Expr& __v);
980 template <class _Expr>
983 __is_val_expr<_Expr>::value,
986 _LIBCPP_INLINE_VISIBILITY
987 operator&= (const _Expr& __v);
989 template <class _Expr>
992 __is_val_expr<_Expr>::value,
995 _LIBCPP_INLINE_VISIBILITY
996 operator<<= (const _Expr& __v);
998 template <class _Expr>
1001 __is_val_expr<_Expr>::value,
1004 _LIBCPP_INLINE_VISIBILITY
1005 operator>>= (const _Expr& __v);
1007 // member functions:
1008 _LIBCPP_INLINE_VISIBILITY
1009 void swap(valarray& __v) _NOEXCEPT;
1011 _LIBCPP_INLINE_VISIBILITY
1012 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
1014 _LIBCPP_INLINE_VISIBILITY
1015 value_type sum() const;
1016 _LIBCPP_INLINE_VISIBILITY
1017 value_type min() const;
1018 _LIBCPP_INLINE_VISIBILITY
1019 value_type max() const;
1021 valarray shift (int __i) const;
1022 valarray cshift(int __i) const;
1023 valarray apply(value_type __f(value_type)) const;
1024 valarray apply(value_type __f(const value_type&)) const;
1025 void resize(size_t __n, value_type __x = value_type());
1028 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1029 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1030 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1031 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
1032 template <class> friend class __mask_expr;
1033 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
1034 template <class> friend class __indirect_expr;
1035 template <class> friend class __val_expr;
1037 template <class _Up>
1040 begin(valarray<_Up>& __v);
1042 template <class _Up>
1045 begin(const valarray<_Up>& __v);
1047 template <class _Up>
1050 end(valarray<_Up>& __v);
1052 template <class _Up>
1055 end(const valarray<_Up>& __v);
1058 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1059 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1060 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1062 template <class _Op, class _Tp>
1063 struct _UnaryOp<_Op, valarray<_Tp> >
1065 typedef typename _Op::result_type result_type;
1066 typedef _Tp value_type;
1069 const valarray<_Tp>& __a0_;
1071 _LIBCPP_INLINE_VISIBILITY
1072 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1074 _LIBCPP_INLINE_VISIBILITY
1075 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1077 _LIBCPP_INLINE_VISIBILITY
1078 size_t size() const {return __a0_.size();}
1081 template <class _Op, class _Tp, class _A1>
1082 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1084 typedef typename _Op::result_type result_type;
1085 typedef _Tp value_type;
1088 const valarray<_Tp>& __a0_;
1091 _LIBCPP_INLINE_VISIBILITY
1092 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1093 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1095 _LIBCPP_INLINE_VISIBILITY
1096 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1098 _LIBCPP_INLINE_VISIBILITY
1099 size_t size() const {return __a0_.size();}
1102 template <class _Op, class _A0, class _Tp>
1103 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1105 typedef typename _Op::result_type result_type;
1106 typedef _Tp value_type;
1110 const valarray<_Tp>& __a1_;
1112 _LIBCPP_INLINE_VISIBILITY
1113 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1114 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1116 _LIBCPP_INLINE_VISIBILITY
1117 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1119 _LIBCPP_INLINE_VISIBILITY
1120 size_t size() const {return __a0_.size();}
1123 template <class _Op, class _Tp>
1124 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1126 typedef typename _Op::result_type result_type;
1127 typedef _Tp value_type;
1130 const valarray<_Tp>& __a0_;
1131 const valarray<_Tp>& __a1_;
1133 _LIBCPP_INLINE_VISIBILITY
1134 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1135 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1137 _LIBCPP_INLINE_VISIBILITY
1138 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1140 _LIBCPP_INLINE_VISIBILITY
1141 size_t size() const {return __a0_.size();}
1146 template <class _Tp>
1147 class _LIBCPP_TEMPLATE_VIS slice_array
1150 typedef _Tp value_type;
1158 template <class _Expr>
1161 __is_val_expr<_Expr>::value,
1164 _LIBCPP_INLINE_VISIBILITY
1165 operator=(const _Expr& __v) const;
1167 template <class _Expr>
1170 __is_val_expr<_Expr>::value,
1173 _LIBCPP_INLINE_VISIBILITY
1174 operator*=(const _Expr& __v) const;
1176 template <class _Expr>
1179 __is_val_expr<_Expr>::value,
1182 _LIBCPP_INLINE_VISIBILITY
1183 operator/=(const _Expr& __v) const;
1185 template <class _Expr>
1188 __is_val_expr<_Expr>::value,
1191 _LIBCPP_INLINE_VISIBILITY
1192 operator%=(const _Expr& __v) const;
1194 template <class _Expr>
1197 __is_val_expr<_Expr>::value,
1200 _LIBCPP_INLINE_VISIBILITY
1201 operator+=(const _Expr& __v) const;
1203 template <class _Expr>
1206 __is_val_expr<_Expr>::value,
1209 _LIBCPP_INLINE_VISIBILITY
1210 operator-=(const _Expr& __v) const;
1212 template <class _Expr>
1215 __is_val_expr<_Expr>::value,
1218 _LIBCPP_INLINE_VISIBILITY
1219 operator^=(const _Expr& __v) const;
1221 template <class _Expr>
1224 __is_val_expr<_Expr>::value,
1227 _LIBCPP_INLINE_VISIBILITY
1228 operator&=(const _Expr& __v) const;
1230 template <class _Expr>
1233 __is_val_expr<_Expr>::value,
1236 _LIBCPP_INLINE_VISIBILITY
1237 operator|=(const _Expr& __v) const;
1239 template <class _Expr>
1242 __is_val_expr<_Expr>::value,
1245 _LIBCPP_INLINE_VISIBILITY
1246 operator<<=(const _Expr& __v) const;
1248 template <class _Expr>
1251 __is_val_expr<_Expr>::value,
1254 _LIBCPP_INLINE_VISIBILITY
1255 operator>>=(const _Expr& __v) const;
1257 _LIBCPP_INLINE_VISIBILITY
1258 const slice_array& operator=(const slice_array& __sa) const;
1260 _LIBCPP_INLINE_VISIBILITY
1261 void operator=(const value_type& __x) const;
1264 _LIBCPP_INLINE_VISIBILITY
1265 slice_array(const slice& __sl, const valarray<value_type>& __v)
1266 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1267 __size_(__sl.size()),
1268 __stride_(__sl.stride())
1271 template <class> friend class valarray;
1272 template <class> friend class sliceExpr;
1275 template <class _Tp>
1277 const slice_array<_Tp>&
1278 slice_array<_Tp>::operator=(const slice_array& __sa) const
1280 value_type* __t = __vp_;
1281 const value_type* __s = __sa.__vp_;
1282 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1287 template <class _Tp>
1288 template <class _Expr>
1292 __is_val_expr<_Expr>::value,
1295 slice_array<_Tp>::operator=(const _Expr& __v) const
1297 value_type* __t = __vp_;
1298 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1302 template <class _Tp>
1303 template <class _Expr>
1307 __is_val_expr<_Expr>::value,
1310 slice_array<_Tp>::operator*=(const _Expr& __v) const
1312 value_type* __t = __vp_;
1313 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1317 template <class _Tp>
1318 template <class _Expr>
1322 __is_val_expr<_Expr>::value,
1325 slice_array<_Tp>::operator/=(const _Expr& __v) const
1327 value_type* __t = __vp_;
1328 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1332 template <class _Tp>
1333 template <class _Expr>
1337 __is_val_expr<_Expr>::value,
1340 slice_array<_Tp>::operator%=(const _Expr& __v) const
1342 value_type* __t = __vp_;
1343 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1347 template <class _Tp>
1348 template <class _Expr>
1352 __is_val_expr<_Expr>::value,
1355 slice_array<_Tp>::operator+=(const _Expr& __v) const
1357 value_type* __t = __vp_;
1358 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1362 template <class _Tp>
1363 template <class _Expr>
1367 __is_val_expr<_Expr>::value,
1370 slice_array<_Tp>::operator-=(const _Expr& __v) const
1372 value_type* __t = __vp_;
1373 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1377 template <class _Tp>
1378 template <class _Expr>
1382 __is_val_expr<_Expr>::value,
1385 slice_array<_Tp>::operator^=(const _Expr& __v) const
1387 value_type* __t = __vp_;
1388 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1392 template <class _Tp>
1393 template <class _Expr>
1397 __is_val_expr<_Expr>::value,
1400 slice_array<_Tp>::operator&=(const _Expr& __v) const
1402 value_type* __t = __vp_;
1403 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1407 template <class _Tp>
1408 template <class _Expr>
1412 __is_val_expr<_Expr>::value,
1415 slice_array<_Tp>::operator|=(const _Expr& __v) const
1417 value_type* __t = __vp_;
1418 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1422 template <class _Tp>
1423 template <class _Expr>
1427 __is_val_expr<_Expr>::value,
1430 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1432 value_type* __t = __vp_;
1433 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1437 template <class _Tp>
1438 template <class _Expr>
1442 __is_val_expr<_Expr>::value,
1445 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1447 value_type* __t = __vp_;
1448 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1452 template <class _Tp>
1455 slice_array<_Tp>::operator=(const value_type& __x) const
1457 value_type* __t = __vp_;
1458 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1464 class _LIBCPP_TYPE_VIS gslice
1466 valarray<size_t> __size_;
1467 valarray<size_t> __stride_;
1468 valarray<size_t> __1d_;
1471 _LIBCPP_INLINE_VISIBILITY
1474 _LIBCPP_INLINE_VISIBILITY
1475 gslice(size_t __start, const valarray<size_t>& __size,
1476 const valarray<size_t>& __stride)
1481 #ifndef _LIBCPP_CXX03_LANG
1483 _LIBCPP_INLINE_VISIBILITY
1484 gslice(size_t __start, const valarray<size_t>& __size,
1485 valarray<size_t>&& __stride)
1487 __stride_(move(__stride))
1490 _LIBCPP_INLINE_VISIBILITY
1491 gslice(size_t __start, valarray<size_t>&& __size,
1492 const valarray<size_t>& __stride)
1493 : __size_(move(__size)),
1497 _LIBCPP_INLINE_VISIBILITY
1498 gslice(size_t __start, valarray<size_t>&& __size,
1499 valarray<size_t>&& __stride)
1500 : __size_(move(__size)),
1501 __stride_(move(__stride))
1504 #endif // _LIBCPP_CXX03_LANG
1506 // gslice(const gslice&) = default;
1507 // gslice(gslice&&) = default;
1508 // gslice& operator=(const gslice&) = default;
1509 // gslice& operator=(gslice&&) = default;
1511 _LIBCPP_INLINE_VISIBILITY
1512 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1514 _LIBCPP_INLINE_VISIBILITY
1515 valarray<size_t> size() const {return __size_;}
1517 _LIBCPP_INLINE_VISIBILITY
1518 valarray<size_t> stride() const {return __stride_;}
1521 void __init(size_t __start);
1523 template <class> friend class gslice_array;
1524 template <class> friend class valarray;
1525 template <class> friend class __val_expr;
1530 template <class _Tp>
1531 class _LIBCPP_TEMPLATE_VIS gslice_array
1534 typedef _Tp value_type;
1538 valarray<size_t> __1d_;
1541 template <class _Expr>
1544 __is_val_expr<_Expr>::value,
1547 _LIBCPP_INLINE_VISIBILITY
1548 operator=(const _Expr& __v) const;
1550 template <class _Expr>
1553 __is_val_expr<_Expr>::value,
1556 _LIBCPP_INLINE_VISIBILITY
1557 operator*=(const _Expr& __v) const;
1559 template <class _Expr>
1562 __is_val_expr<_Expr>::value,
1565 _LIBCPP_INLINE_VISIBILITY
1566 operator/=(const _Expr& __v) const;
1568 template <class _Expr>
1571 __is_val_expr<_Expr>::value,
1574 _LIBCPP_INLINE_VISIBILITY
1575 operator%=(const _Expr& __v) const;
1577 template <class _Expr>
1580 __is_val_expr<_Expr>::value,
1583 _LIBCPP_INLINE_VISIBILITY
1584 operator+=(const _Expr& __v) const;
1586 template <class _Expr>
1589 __is_val_expr<_Expr>::value,
1592 _LIBCPP_INLINE_VISIBILITY
1593 operator-=(const _Expr& __v) const;
1595 template <class _Expr>
1598 __is_val_expr<_Expr>::value,
1601 _LIBCPP_INLINE_VISIBILITY
1602 operator^=(const _Expr& __v) const;
1604 template <class _Expr>
1607 __is_val_expr<_Expr>::value,
1610 _LIBCPP_INLINE_VISIBILITY
1611 operator&=(const _Expr& __v) const;
1613 template <class _Expr>
1616 __is_val_expr<_Expr>::value,
1619 _LIBCPP_INLINE_VISIBILITY
1620 operator|=(const _Expr& __v) const;
1622 template <class _Expr>
1625 __is_val_expr<_Expr>::value,
1628 _LIBCPP_INLINE_VISIBILITY
1629 operator<<=(const _Expr& __v) const;
1631 template <class _Expr>
1634 __is_val_expr<_Expr>::value,
1637 _LIBCPP_INLINE_VISIBILITY
1638 operator>>=(const _Expr& __v) const;
1640 _LIBCPP_INLINE_VISIBILITY
1641 const gslice_array& operator=(const gslice_array& __ga) const;
1643 _LIBCPP_INLINE_VISIBILITY
1644 void operator=(const value_type& __x) const;
1646 // gslice_array(const gslice_array&) = default;
1647 // gslice_array(gslice_array&&) = default;
1648 // gslice_array& operator=(const gslice_array&) = default;
1649 // gslice_array& operator=(gslice_array&&) = default;
1652 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1653 : __vp_(const_cast<value_type*>(__v.__begin_)),
1657 #ifndef _LIBCPP_CXX03_LANG
1658 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1659 : __vp_(const_cast<value_type*>(__v.__begin_)),
1660 __1d_(move(__gs.__1d_))
1662 #endif // _LIBCPP_CXX03_LANG
1664 template <class> friend class valarray;
1667 template <class _Tp>
1668 template <class _Expr>
1672 __is_val_expr<_Expr>::value,
1675 gslice_array<_Tp>::operator=(const _Expr& __v) const
1677 typedef const size_t* _Ip;
1679 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1680 __vp_[*__i] = __v[__j];
1683 template <class _Tp>
1684 template <class _Expr>
1688 __is_val_expr<_Expr>::value,
1691 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1693 typedef const size_t* _Ip;
1695 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1696 __vp_[*__i] *= __v[__j];
1699 template <class _Tp>
1700 template <class _Expr>
1704 __is_val_expr<_Expr>::value,
1707 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1709 typedef const size_t* _Ip;
1711 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1712 __vp_[*__i] /= __v[__j];
1715 template <class _Tp>
1716 template <class _Expr>
1720 __is_val_expr<_Expr>::value,
1723 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1725 typedef const size_t* _Ip;
1727 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1728 __vp_[*__i] %= __v[__j];
1731 template <class _Tp>
1732 template <class _Expr>
1736 __is_val_expr<_Expr>::value,
1739 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1741 typedef const size_t* _Ip;
1743 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1744 __vp_[*__i] += __v[__j];
1747 template <class _Tp>
1748 template <class _Expr>
1752 __is_val_expr<_Expr>::value,
1755 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1757 typedef const size_t* _Ip;
1759 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1760 __vp_[*__i] -= __v[__j];
1763 template <class _Tp>
1764 template <class _Expr>
1768 __is_val_expr<_Expr>::value,
1771 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1773 typedef const size_t* _Ip;
1775 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1776 __vp_[*__i] ^= __v[__j];
1779 template <class _Tp>
1780 template <class _Expr>
1784 __is_val_expr<_Expr>::value,
1787 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1789 typedef const size_t* _Ip;
1791 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1792 __vp_[*__i] &= __v[__j];
1795 template <class _Tp>
1796 template <class _Expr>
1800 __is_val_expr<_Expr>::value,
1803 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1805 typedef const size_t* _Ip;
1807 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1808 __vp_[*__i] |= __v[__j];
1811 template <class _Tp>
1812 template <class _Expr>
1816 __is_val_expr<_Expr>::value,
1819 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1821 typedef const size_t* _Ip;
1823 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1824 __vp_[*__i] <<= __v[__j];
1827 template <class _Tp>
1828 template <class _Expr>
1832 __is_val_expr<_Expr>::value,
1835 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1837 typedef const size_t* _Ip;
1839 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1840 __vp_[*__i] >>= __v[__j];
1843 template <class _Tp>
1845 const gslice_array<_Tp>&
1846 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1848 typedef const size_t* _Ip;
1849 const value_type* __s = __ga.__vp_;
1850 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1851 __i != __e; ++__i, ++__j)
1852 __vp_[*__i] = __s[*__j];
1856 template <class _Tp>
1859 gslice_array<_Tp>::operator=(const value_type& __x) const
1861 typedef const size_t* _Ip;
1862 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1868 template <class _Tp>
1869 class _LIBCPP_TEMPLATE_VIS mask_array
1872 typedef _Tp value_type;
1876 valarray<size_t> __1d_;
1879 template <class _Expr>
1882 __is_val_expr<_Expr>::value,
1885 _LIBCPP_INLINE_VISIBILITY
1886 operator=(const _Expr& __v) const;
1888 template <class _Expr>
1891 __is_val_expr<_Expr>::value,
1894 _LIBCPP_INLINE_VISIBILITY
1895 operator*=(const _Expr& __v) const;
1897 template <class _Expr>
1900 __is_val_expr<_Expr>::value,
1903 _LIBCPP_INLINE_VISIBILITY
1904 operator/=(const _Expr& __v) const;
1906 template <class _Expr>
1909 __is_val_expr<_Expr>::value,
1912 _LIBCPP_INLINE_VISIBILITY
1913 operator%=(const _Expr& __v) const;
1915 template <class _Expr>
1918 __is_val_expr<_Expr>::value,
1921 _LIBCPP_INLINE_VISIBILITY
1922 operator+=(const _Expr& __v) const;
1924 template <class _Expr>
1927 __is_val_expr<_Expr>::value,
1930 _LIBCPP_INLINE_VISIBILITY
1931 operator-=(const _Expr& __v) const;
1933 template <class _Expr>
1936 __is_val_expr<_Expr>::value,
1939 _LIBCPP_INLINE_VISIBILITY
1940 operator^=(const _Expr& __v) const;
1942 template <class _Expr>
1945 __is_val_expr<_Expr>::value,
1948 _LIBCPP_INLINE_VISIBILITY
1949 operator&=(const _Expr& __v) const;
1951 template <class _Expr>
1954 __is_val_expr<_Expr>::value,
1957 _LIBCPP_INLINE_VISIBILITY
1958 operator|=(const _Expr& __v) const;
1960 template <class _Expr>
1963 __is_val_expr<_Expr>::value,
1966 _LIBCPP_INLINE_VISIBILITY
1967 operator<<=(const _Expr& __v) const;
1969 template <class _Expr>
1972 __is_val_expr<_Expr>::value,
1975 _LIBCPP_INLINE_VISIBILITY
1976 operator>>=(const _Expr& __v) const;
1978 _LIBCPP_INLINE_VISIBILITY
1979 const mask_array& operator=(const mask_array& __ma) const;
1981 _LIBCPP_INLINE_VISIBILITY
1982 void operator=(const value_type& __x) const;
1984 // mask_array(const mask_array&) = default;
1985 // mask_array(mask_array&&) = default;
1986 // mask_array& operator=(const mask_array&) = default;
1987 // mask_array& operator=(mask_array&&) = default;
1990 _LIBCPP_INLINE_VISIBILITY
1991 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1992 : __vp_(const_cast<value_type*>(__v.__begin_)),
1993 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1996 for (size_t __i = 0; __i < __vb.size(); ++__i)
2001 template <class> friend class valarray;
2004 template <class _Tp>
2005 template <class _Expr>
2009 __is_val_expr<_Expr>::value,
2012 mask_array<_Tp>::operator=(const _Expr& __v) const
2014 size_t __n = __1d_.size();
2015 for (size_t __i = 0; __i < __n; ++__i)
2016 __vp_[__1d_[__i]] = __v[__i];
2019 template <class _Tp>
2020 template <class _Expr>
2024 __is_val_expr<_Expr>::value,
2027 mask_array<_Tp>::operator*=(const _Expr& __v) const
2029 size_t __n = __1d_.size();
2030 for (size_t __i = 0; __i < __n; ++__i)
2031 __vp_[__1d_[__i]] *= __v[__i];
2034 template <class _Tp>
2035 template <class _Expr>
2039 __is_val_expr<_Expr>::value,
2042 mask_array<_Tp>::operator/=(const _Expr& __v) const
2044 size_t __n = __1d_.size();
2045 for (size_t __i = 0; __i < __n; ++__i)
2046 __vp_[__1d_[__i]] /= __v[__i];
2049 template <class _Tp>
2050 template <class _Expr>
2054 __is_val_expr<_Expr>::value,
2057 mask_array<_Tp>::operator%=(const _Expr& __v) const
2059 size_t __n = __1d_.size();
2060 for (size_t __i = 0; __i < __n; ++__i)
2061 __vp_[__1d_[__i]] %= __v[__i];
2064 template <class _Tp>
2065 template <class _Expr>
2069 __is_val_expr<_Expr>::value,
2072 mask_array<_Tp>::operator+=(const _Expr& __v) const
2074 size_t __n = __1d_.size();
2075 for (size_t __i = 0; __i < __n; ++__i)
2076 __vp_[__1d_[__i]] += __v[__i];
2079 template <class _Tp>
2080 template <class _Expr>
2084 __is_val_expr<_Expr>::value,
2087 mask_array<_Tp>::operator-=(const _Expr& __v) const
2089 size_t __n = __1d_.size();
2090 for (size_t __i = 0; __i < __n; ++__i)
2091 __vp_[__1d_[__i]] -= __v[__i];
2094 template <class _Tp>
2095 template <class _Expr>
2099 __is_val_expr<_Expr>::value,
2102 mask_array<_Tp>::operator^=(const _Expr& __v) const
2104 size_t __n = __1d_.size();
2105 for (size_t __i = 0; __i < __n; ++__i)
2106 __vp_[__1d_[__i]] ^= __v[__i];
2109 template <class _Tp>
2110 template <class _Expr>
2114 __is_val_expr<_Expr>::value,
2117 mask_array<_Tp>::operator&=(const _Expr& __v) const
2119 size_t __n = __1d_.size();
2120 for (size_t __i = 0; __i < __n; ++__i)
2121 __vp_[__1d_[__i]] &= __v[__i];
2124 template <class _Tp>
2125 template <class _Expr>
2129 __is_val_expr<_Expr>::value,
2132 mask_array<_Tp>::operator|=(const _Expr& __v) const
2134 size_t __n = __1d_.size();
2135 for (size_t __i = 0; __i < __n; ++__i)
2136 __vp_[__1d_[__i]] |= __v[__i];
2139 template <class _Tp>
2140 template <class _Expr>
2144 __is_val_expr<_Expr>::value,
2147 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2149 size_t __n = __1d_.size();
2150 for (size_t __i = 0; __i < __n; ++__i)
2151 __vp_[__1d_[__i]] <<= __v[__i];
2154 template <class _Tp>
2155 template <class _Expr>
2159 __is_val_expr<_Expr>::value,
2162 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2164 size_t __n = __1d_.size();
2165 for (size_t __i = 0; __i < __n; ++__i)
2166 __vp_[__1d_[__i]] >>= __v[__i];
2169 template <class _Tp>
2171 const mask_array<_Tp>&
2172 mask_array<_Tp>::operator=(const mask_array& __ma) const
2174 size_t __n = __1d_.size();
2175 for (size_t __i = 0; __i < __n; ++__i)
2176 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2180 template <class _Tp>
2183 mask_array<_Tp>::operator=(const value_type& __x) const
2185 size_t __n = __1d_.size();
2186 for (size_t __i = 0; __i < __n; ++__i)
2187 __vp_[__1d_[__i]] = __x;
2190 template <class _ValExpr>
2193 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2195 typedef typename _RmExpr::value_type value_type;
2196 typedef value_type result_type;
2200 valarray<size_t> __1d_;
2202 _LIBCPP_INLINE_VISIBILITY
2203 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2205 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2208 for (size_t __i = 0; __i < __vb.size(); ++__i)
2214 _LIBCPP_INLINE_VISIBILITY
2215 result_type operator[](size_t __i) const
2216 {return __expr_[__1d_[__i]];}
2218 _LIBCPP_INLINE_VISIBILITY
2219 size_t size() const {return __1d_.size();}
2221 template <class> friend class valarray;
2226 template <class _Tp>
2227 class _LIBCPP_TEMPLATE_VIS indirect_array
2230 typedef _Tp value_type;
2234 valarray<size_t> __1d_;
2237 template <class _Expr>
2240 __is_val_expr<_Expr>::value,
2243 _LIBCPP_INLINE_VISIBILITY
2244 operator=(const _Expr& __v) const;
2246 template <class _Expr>
2249 __is_val_expr<_Expr>::value,
2252 _LIBCPP_INLINE_VISIBILITY
2253 operator*=(const _Expr& __v) const;
2255 template <class _Expr>
2258 __is_val_expr<_Expr>::value,
2261 _LIBCPP_INLINE_VISIBILITY
2262 operator/=(const _Expr& __v) const;
2264 template <class _Expr>
2267 __is_val_expr<_Expr>::value,
2270 _LIBCPP_INLINE_VISIBILITY
2271 operator%=(const _Expr& __v) const;
2273 template <class _Expr>
2276 __is_val_expr<_Expr>::value,
2279 _LIBCPP_INLINE_VISIBILITY
2280 operator+=(const _Expr& __v) const;
2282 template <class _Expr>
2285 __is_val_expr<_Expr>::value,
2288 _LIBCPP_INLINE_VISIBILITY
2289 operator-=(const _Expr& __v) const;
2291 template <class _Expr>
2294 __is_val_expr<_Expr>::value,
2297 _LIBCPP_INLINE_VISIBILITY
2298 operator^=(const _Expr& __v) const;
2300 template <class _Expr>
2303 __is_val_expr<_Expr>::value,
2306 _LIBCPP_INLINE_VISIBILITY
2307 operator&=(const _Expr& __v) const;
2309 template <class _Expr>
2312 __is_val_expr<_Expr>::value,
2315 _LIBCPP_INLINE_VISIBILITY
2316 operator|=(const _Expr& __v) const;
2318 template <class _Expr>
2321 __is_val_expr<_Expr>::value,
2324 _LIBCPP_INLINE_VISIBILITY
2325 operator<<=(const _Expr& __v) const;
2327 template <class _Expr>
2330 __is_val_expr<_Expr>::value,
2333 _LIBCPP_INLINE_VISIBILITY
2334 operator>>=(const _Expr& __v) const;
2336 _LIBCPP_INLINE_VISIBILITY
2337 const indirect_array& operator=(const indirect_array& __ia) const;
2339 _LIBCPP_INLINE_VISIBILITY
2340 void operator=(const value_type& __x) const;
2342 // indirect_array(const indirect_array&) = default;
2343 // indirect_array(indirect_array&&) = default;
2344 // indirect_array& operator=(const indirect_array&) = default;
2345 // indirect_array& operator=(indirect_array&&) = default;
2348 _LIBCPP_INLINE_VISIBILITY
2349 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2350 : __vp_(const_cast<value_type*>(__v.__begin_)),
2354 #ifndef _LIBCPP_CXX03_LANG
2356 _LIBCPP_INLINE_VISIBILITY
2357 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2358 : __vp_(const_cast<value_type*>(__v.__begin_)),
2362 #endif // _LIBCPP_CXX03_LANG
2364 template <class> friend class valarray;
2367 template <class _Tp>
2368 template <class _Expr>
2372 __is_val_expr<_Expr>::value,
2375 indirect_array<_Tp>::operator=(const _Expr& __v) const
2377 size_t __n = __1d_.size();
2378 for (size_t __i = 0; __i < __n; ++__i)
2379 __vp_[__1d_[__i]] = __v[__i];
2382 template <class _Tp>
2383 template <class _Expr>
2387 __is_val_expr<_Expr>::value,
2390 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2392 size_t __n = __1d_.size();
2393 for (size_t __i = 0; __i < __n; ++__i)
2394 __vp_[__1d_[__i]] *= __v[__i];
2397 template <class _Tp>
2398 template <class _Expr>
2402 __is_val_expr<_Expr>::value,
2405 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2407 size_t __n = __1d_.size();
2408 for (size_t __i = 0; __i < __n; ++__i)
2409 __vp_[__1d_[__i]] /= __v[__i];
2412 template <class _Tp>
2413 template <class _Expr>
2417 __is_val_expr<_Expr>::value,
2420 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2422 size_t __n = __1d_.size();
2423 for (size_t __i = 0; __i < __n; ++__i)
2424 __vp_[__1d_[__i]] %= __v[__i];
2427 template <class _Tp>
2428 template <class _Expr>
2432 __is_val_expr<_Expr>::value,
2435 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2437 size_t __n = __1d_.size();
2438 for (size_t __i = 0; __i < __n; ++__i)
2439 __vp_[__1d_[__i]] += __v[__i];
2442 template <class _Tp>
2443 template <class _Expr>
2447 __is_val_expr<_Expr>::value,
2450 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2452 size_t __n = __1d_.size();
2453 for (size_t __i = 0; __i < __n; ++__i)
2454 __vp_[__1d_[__i]] -= __v[__i];
2457 template <class _Tp>
2458 template <class _Expr>
2462 __is_val_expr<_Expr>::value,
2465 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2467 size_t __n = __1d_.size();
2468 for (size_t __i = 0; __i < __n; ++__i)
2469 __vp_[__1d_[__i]] ^= __v[__i];
2472 template <class _Tp>
2473 template <class _Expr>
2477 __is_val_expr<_Expr>::value,
2480 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2482 size_t __n = __1d_.size();
2483 for (size_t __i = 0; __i < __n; ++__i)
2484 __vp_[__1d_[__i]] &= __v[__i];
2487 template <class _Tp>
2488 template <class _Expr>
2492 __is_val_expr<_Expr>::value,
2495 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2497 size_t __n = __1d_.size();
2498 for (size_t __i = 0; __i < __n; ++__i)
2499 __vp_[__1d_[__i]] |= __v[__i];
2502 template <class _Tp>
2503 template <class _Expr>
2507 __is_val_expr<_Expr>::value,
2510 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2512 size_t __n = __1d_.size();
2513 for (size_t __i = 0; __i < __n; ++__i)
2514 __vp_[__1d_[__i]] <<= __v[__i];
2517 template <class _Tp>
2518 template <class _Expr>
2522 __is_val_expr<_Expr>::value,
2525 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2527 size_t __n = __1d_.size();
2528 for (size_t __i = 0; __i < __n; ++__i)
2529 __vp_[__1d_[__i]] >>= __v[__i];
2532 template <class _Tp>
2534 const indirect_array<_Tp>&
2535 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2537 typedef const size_t* _Ip;
2538 const value_type* __s = __ia.__vp_;
2539 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2540 __i != __e; ++__i, ++__j)
2541 __vp_[*__i] = __s[*__j];
2545 template <class _Tp>
2548 indirect_array<_Tp>::operator=(const value_type& __x) const
2550 typedef const size_t* _Ip;
2551 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2555 template <class _ValExpr>
2556 class __indirect_expr
2558 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2560 typedef typename _RmExpr::value_type value_type;
2561 typedef value_type result_type;
2565 valarray<size_t> __1d_;
2567 _LIBCPP_INLINE_VISIBILITY
2568 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2573 #ifndef _LIBCPP_CXX03_LANG
2575 _LIBCPP_INLINE_VISIBILITY
2576 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2581 #endif // _LIBCPP_CXX03_LANG
2584 _LIBCPP_INLINE_VISIBILITY
2585 result_type operator[](size_t __i) const
2586 {return __expr_[__1d_[__i]];}
2588 _LIBCPP_INLINE_VISIBILITY
2589 size_t size() const {return __1d_.size();}
2591 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
2594 template<class _ValExpr>
2597 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2601 typedef typename _RmExpr::value_type value_type;
2602 typedef typename _RmExpr::result_type result_type;
2604 _LIBCPP_INLINE_VISIBILITY
2605 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2607 _LIBCPP_INLINE_VISIBILITY
2608 result_type operator[](size_t __i) const
2609 {return __expr_[__i];}
2611 _LIBCPP_INLINE_VISIBILITY
2612 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2613 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2615 _LIBCPP_INLINE_VISIBILITY
2616 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2617 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2619 _LIBCPP_INLINE_VISIBILITY
2620 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2621 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2623 _LIBCPP_INLINE_VISIBILITY
2624 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2625 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2627 _LIBCPP_INLINE_VISIBILITY
2628 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2631 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2632 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2635 _LIBCPP_INLINE_VISIBILITY
2636 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2639 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2640 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2643 _LIBCPP_INLINE_VISIBILITY
2644 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2647 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2648 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2651 _LIBCPP_INLINE_VISIBILITY
2652 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2655 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2656 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2659 operator valarray<result_type>() const;
2661 _LIBCPP_INLINE_VISIBILITY
2662 size_t size() const {return __expr_.size();}
2664 _LIBCPP_INLINE_VISIBILITY
2665 result_type sum() const
2667 size_t __n = __expr_.size();
2668 result_type __r = __n ? __expr_[0] : result_type();
2669 for (size_t __i = 1; __i < __n; ++__i)
2670 __r += __expr_[__i];
2674 _LIBCPP_INLINE_VISIBILITY
2675 result_type min() const
2677 size_t __n = size();
2678 result_type __r = __n ? (*this)[0] : result_type();
2679 for (size_t __i = 1; __i < __n; ++__i)
2681 result_type __x = __expr_[__i];
2688 _LIBCPP_INLINE_VISIBILITY
2689 result_type max() const
2691 size_t __n = size();
2692 result_type __r = __n ? (*this)[0] : result_type();
2693 for (size_t __i = 1; __i < __n; ++__i)
2695 result_type __x = __expr_[__i];
2702 _LIBCPP_INLINE_VISIBILITY
2703 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2704 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2706 _LIBCPP_INLINE_VISIBILITY
2707 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2708 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2710 _LIBCPP_INLINE_VISIBILITY
2711 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2712 apply(value_type __f(value_type)) const
2714 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2715 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2716 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2719 _LIBCPP_INLINE_VISIBILITY
2720 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2721 apply(value_type __f(const value_type&)) const
2723 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2724 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2725 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2729 template<class _ValExpr>
2730 __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2732 valarray<result_type> __r;
2733 size_t __n = __expr_.size();
2738 static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
2739 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2740 ::new (__r.__end_) result_type(__expr_[__i]);
2747 template <class _Tp>
2749 valarray<_Tp>::valarray(size_t __n)
2756 template <class _Tp>
2758 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2765 template <class _Tp>
2766 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2772 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2773 #ifndef _LIBCPP_NO_EXCEPTIONS
2776 #endif // _LIBCPP_NO_EXCEPTIONS
2777 for (; __n; ++__end_, ++__p, --__n)
2778 ::new (__end_) value_type(*__p);
2779 #ifndef _LIBCPP_NO_EXCEPTIONS
2786 #endif // _LIBCPP_NO_EXCEPTIONS
2790 template <class _Tp>
2791 valarray<_Tp>::valarray(const valarray& __v)
2797 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
2798 #ifndef _LIBCPP_NO_EXCEPTIONS
2801 #endif // _LIBCPP_NO_EXCEPTIONS
2802 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2803 ::new (__end_) value_type(*__p);
2804 #ifndef _LIBCPP_NO_EXCEPTIONS
2811 #endif // _LIBCPP_NO_EXCEPTIONS
2815 #ifndef _LIBCPP_CXX03_LANG
2817 template <class _Tp>
2819 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2820 : __begin_(__v.__begin_),
2823 __v.__begin_ = __v.__end_ = nullptr;
2826 template <class _Tp>
2827 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2831 size_t __n = __il.size();
2834 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2835 #ifndef _LIBCPP_NO_EXCEPTIONS
2838 #endif // _LIBCPP_NO_EXCEPTIONS
2839 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2840 ::new (__end_) value_type(*__p);
2841 #ifndef _LIBCPP_NO_EXCEPTIONS
2848 #endif // _LIBCPP_NO_EXCEPTIONS
2852 #endif // _LIBCPP_CXX03_LANG
2854 template <class _Tp>
2855 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2859 size_t __n = __sa.__size_;
2862 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2863 #ifndef _LIBCPP_NO_EXCEPTIONS
2866 #endif // _LIBCPP_NO_EXCEPTIONS
2867 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2868 ::new (__end_) value_type(*__p);
2869 #ifndef _LIBCPP_NO_EXCEPTIONS
2876 #endif // _LIBCPP_NO_EXCEPTIONS
2880 template <class _Tp>
2881 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2885 size_t __n = __ga.__1d_.size();
2888 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2889 #ifndef _LIBCPP_NO_EXCEPTIONS
2892 #endif // _LIBCPP_NO_EXCEPTIONS
2893 typedef const size_t* _Ip;
2894 const value_type* __s = __ga.__vp_;
2895 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2896 __i != __e; ++__i, ++__end_)
2897 ::new (__end_) value_type(__s[*__i]);
2898 #ifndef _LIBCPP_NO_EXCEPTIONS
2905 #endif // _LIBCPP_NO_EXCEPTIONS
2909 template <class _Tp>
2910 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2914 size_t __n = __ma.__1d_.size();
2917 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2918 #ifndef _LIBCPP_NO_EXCEPTIONS
2921 #endif // _LIBCPP_NO_EXCEPTIONS
2922 typedef const size_t* _Ip;
2923 const value_type* __s = __ma.__vp_;
2924 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2925 __i != __e; ++__i, ++__end_)
2926 ::new (__end_) value_type(__s[*__i]);
2927 #ifndef _LIBCPP_NO_EXCEPTIONS
2934 #endif // _LIBCPP_NO_EXCEPTIONS
2938 template <class _Tp>
2939 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2943 size_t __n = __ia.__1d_.size();
2946 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2947 #ifndef _LIBCPP_NO_EXCEPTIONS
2950 #endif // _LIBCPP_NO_EXCEPTIONS
2951 typedef const size_t* _Ip;
2952 const value_type* __s = __ia.__vp_;
2953 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2954 __i != __e; ++__i, ++__end_)
2955 ::new (__end_) value_type(__s[*__i]);
2956 #ifndef _LIBCPP_NO_EXCEPTIONS
2963 #endif // _LIBCPP_NO_EXCEPTIONS
2967 template <class _Tp>
2969 valarray<_Tp>::~valarray()
2974 template <class _Tp>
2976 valarray<_Tp>::operator=(const valarray& __v)
2980 if (size() != __v.size())
2982 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
2987 #ifndef _LIBCPP_CXX03_LANG
2989 template <class _Tp>
2992 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
2995 __begin_ = __v.__begin_;
2996 __end_ = __v.__end_;
2997 __v.__begin_ = nullptr;
2998 __v.__end_ = nullptr;
3002 template <class _Tp>
3005 valarray<_Tp>::operator=(initializer_list<value_type> __il)
3007 if (size() != __il.size())
3008 resize(__il.size());
3009 _VSTD::copy(__il.begin(), __il.end(), __begin_);
3013 #endif // _LIBCPP_CXX03_LANG
3015 template <class _Tp>
3018 valarray<_Tp>::operator=(const value_type& __x)
3020 _VSTD::fill(__begin_, __end_, __x);
3024 template <class _Tp>
3027 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3029 value_type* __t = __begin_;
3030 const value_type* __s = __sa.__vp_;
3031 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3036 template <class _Tp>
3039 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3041 typedef const size_t* _Ip;
3042 value_type* __t = __begin_;
3043 const value_type* __s = __ga.__vp_;
3044 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3045 __i != __e; ++__i, ++__t)
3050 template <class _Tp>
3053 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3055 typedef const size_t* _Ip;
3056 value_type* __t = __begin_;
3057 const value_type* __s = __ma.__vp_;
3058 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3059 __i != __e; ++__i, ++__t)
3064 template <class _Tp>
3067 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3069 typedef const size_t* _Ip;
3070 value_type* __t = __begin_;
3071 const value_type* __s = __ia.__vp_;
3072 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3073 __i != __e; ++__i, ++__t)
3078 template <class _Tp>
3079 template <class _ValExpr>
3082 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3084 size_t __n = __v.size();
3087 value_type* __t = __begin_;
3088 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3089 *__t = result_type(__v[__i]);
3093 template <class _Tp>
3095 __val_expr<__slice_expr<const valarray<_Tp>&> >
3096 valarray<_Tp>::operator[](slice __s) const
3098 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3101 template <class _Tp>
3104 valarray<_Tp>::operator[](slice __s)
3106 return slice_array<value_type>(__s, *this);
3109 template <class _Tp>
3111 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3112 valarray<_Tp>::operator[](const gslice& __gs) const
3114 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3117 template <class _Tp>
3120 valarray<_Tp>::operator[](const gslice& __gs)
3122 return gslice_array<value_type>(__gs, *this);
3125 #ifndef _LIBCPP_CXX03_LANG
3127 template <class _Tp>
3129 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3130 valarray<_Tp>::operator[](gslice&& __gs) const
3132 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3135 template <class _Tp>
3138 valarray<_Tp>::operator[](gslice&& __gs)
3140 return gslice_array<value_type>(move(__gs), *this);
3143 #endif // _LIBCPP_CXX03_LANG
3145 template <class _Tp>
3147 __val_expr<__mask_expr<const valarray<_Tp>&> >
3148 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3150 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3153 template <class _Tp>
3156 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3158 return mask_array<value_type>(__vb, *this);
3161 #ifndef _LIBCPP_CXX03_LANG
3163 template <class _Tp>
3165 __val_expr<__mask_expr<const valarray<_Tp>&> >
3166 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3168 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3171 template <class _Tp>
3174 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3176 return mask_array<value_type>(move(__vb), *this);
3179 #endif // _LIBCPP_CXX03_LANG
3181 template <class _Tp>
3183 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3184 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3186 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3189 template <class _Tp>
3192 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3194 return indirect_array<value_type>(__vs, *this);
3197 #ifndef _LIBCPP_CXX03_LANG
3199 template <class _Tp>
3201 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3202 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3204 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3207 template <class _Tp>
3210 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3212 return indirect_array<value_type>(move(__vs), *this);
3215 #endif // _LIBCPP_CXX03_LANG
3217 template <class _Tp>
3219 valarray<_Tp>::operator+() const
3221 valarray<value_type> __r;
3222 size_t __n = size();
3227 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3228 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3229 ::new (__r.__end_) value_type(+*__p);
3234 template <class _Tp>
3236 valarray<_Tp>::operator-() const
3238 valarray<value_type> __r;
3239 size_t __n = size();
3244 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3245 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3246 ::new (__r.__end_) value_type(-*__p);
3251 template <class _Tp>
3253 valarray<_Tp>::operator~() const
3255 valarray<value_type> __r;
3256 size_t __n = size();
3261 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3262 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3263 ::new (__r.__end_) value_type(~*__p);
3268 template <class _Tp>
3270 valarray<_Tp>::operator!() const
3273 size_t __n = size();
3278 static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
3279 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3280 ::new (__r.__end_) bool(!*__p);
3285 template <class _Tp>
3288 valarray<_Tp>::operator*=(const value_type& __x)
3290 for (value_type* __p = __begin_; __p != __end_; ++__p)
3295 template <class _Tp>
3298 valarray<_Tp>::operator/=(const value_type& __x)
3300 for (value_type* __p = __begin_; __p != __end_; ++__p)
3305 template <class _Tp>
3308 valarray<_Tp>::operator%=(const value_type& __x)
3310 for (value_type* __p = __begin_; __p != __end_; ++__p)
3315 template <class _Tp>
3318 valarray<_Tp>::operator+=(const value_type& __x)
3320 for (value_type* __p = __begin_; __p != __end_; ++__p)
3325 template <class _Tp>
3328 valarray<_Tp>::operator-=(const value_type& __x)
3330 for (value_type* __p = __begin_; __p != __end_; ++__p)
3335 template <class _Tp>
3338 valarray<_Tp>::operator^=(const value_type& __x)
3340 for (value_type* __p = __begin_; __p != __end_; ++__p)
3345 template <class _Tp>
3348 valarray<_Tp>::operator&=(const value_type& __x)
3350 for (value_type* __p = __begin_; __p != __end_; ++__p)
3355 template <class _Tp>
3358 valarray<_Tp>::operator|=(const value_type& __x)
3360 for (value_type* __p = __begin_; __p != __end_; ++__p)
3365 template <class _Tp>
3368 valarray<_Tp>::operator<<=(const value_type& __x)
3370 for (value_type* __p = __begin_; __p != __end_; ++__p)
3375 template <class _Tp>
3378 valarray<_Tp>::operator>>=(const value_type& __x)
3380 for (value_type* __p = __begin_; __p != __end_; ++__p)
3385 template <class _Tp>
3386 template <class _Expr>
3390 __is_val_expr<_Expr>::value,
3393 valarray<_Tp>::operator*=(const _Expr& __v)
3396 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3401 template <class _Tp>
3402 template <class _Expr>
3406 __is_val_expr<_Expr>::value,
3409 valarray<_Tp>::operator/=(const _Expr& __v)
3412 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3417 template <class _Tp>
3418 template <class _Expr>
3422 __is_val_expr<_Expr>::value,
3425 valarray<_Tp>::operator%=(const _Expr& __v)
3428 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3433 template <class _Tp>
3434 template <class _Expr>
3438 __is_val_expr<_Expr>::value,
3441 valarray<_Tp>::operator+=(const _Expr& __v)
3444 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3449 template <class _Tp>
3450 template <class _Expr>
3454 __is_val_expr<_Expr>::value,
3457 valarray<_Tp>::operator-=(const _Expr& __v)
3460 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3465 template <class _Tp>
3466 template <class _Expr>
3470 __is_val_expr<_Expr>::value,
3473 valarray<_Tp>::operator^=(const _Expr& __v)
3476 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3481 template <class _Tp>
3482 template <class _Expr>
3486 __is_val_expr<_Expr>::value,
3489 valarray<_Tp>::operator|=(const _Expr& __v)
3492 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3497 template <class _Tp>
3498 template <class _Expr>
3502 __is_val_expr<_Expr>::value,
3505 valarray<_Tp>::operator&=(const _Expr& __v)
3508 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3513 template <class _Tp>
3514 template <class _Expr>
3518 __is_val_expr<_Expr>::value,
3521 valarray<_Tp>::operator<<=(const _Expr& __v)
3524 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3529 template <class _Tp>
3530 template <class _Expr>
3534 __is_val_expr<_Expr>::value,
3537 valarray<_Tp>::operator>>=(const _Expr& __v)
3540 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3545 template <class _Tp>
3548 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3550 _VSTD::swap(__begin_, __v.__begin_);
3551 _VSTD::swap(__end_, __v.__end_);
3554 template <class _Tp>
3557 valarray<_Tp>::sum() const
3559 if (__begin_ == __end_)
3560 return value_type();
3561 const value_type* __p = __begin_;
3563 for (++__p; __p != __end_; ++__p)
3568 template <class _Tp>
3571 valarray<_Tp>::min() const
3573 if (__begin_ == __end_)
3574 return value_type();
3575 return *_VSTD::min_element(__begin_, __end_);
3578 template <class _Tp>
3581 valarray<_Tp>::max() const
3583 if (__begin_ == __end_)
3584 return value_type();
3585 return *_VSTD::max_element(__begin_, __end_);
3588 template <class _Tp>
3590 valarray<_Tp>::shift(int __i) const
3592 valarray<value_type> __r;
3593 size_t __n = size();
3598 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3599 const value_type* __sb;
3604 __i = _VSTD::min(__i, static_cast<int>(__n));
3605 __sb = __begin_ + __i;
3606 __tb = __r.__begin_;
3607 __te = __r.__begin_ + (__n - __i);
3611 __i = _VSTD::min(-__i, static_cast<int>(__n));
3613 __tb = __r.__begin_ + __i;
3614 __te = __r.__begin_ + __n;
3616 for (; __r.__end_ != __tb; ++__r.__end_)
3617 ::new (__r.__end_) value_type();
3618 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3619 ::new (__r.__end_) value_type(*__sb);
3620 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3621 ::new (__r.__end_) value_type();
3626 template <class _Tp>
3628 valarray<_Tp>::cshift(int __i) const
3630 valarray<value_type> __r;
3631 size_t __n = size();
3636 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3637 __i %= static_cast<int>(__n);
3638 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3639 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3640 ::new (__r.__end_) value_type(*__s);
3641 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3642 ::new (__r.__end_) value_type(*__s);
3647 template <class _Tp>
3649 valarray<_Tp>::apply(value_type __f(value_type)) const
3651 valarray<value_type> __r;
3652 size_t __n = size();
3657 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3658 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3659 ::new (__r.__end_) value_type(__f(*__p));
3664 template <class _Tp>
3666 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3668 valarray<value_type> __r;
3669 size_t __n = size();
3674 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3675 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3676 ::new (__r.__end_) value_type(__f(*__p));
3681 template <class _Tp>
3683 valarray<_Tp>::resize(size_t __n, value_type __x)
3685 if (__begin_ != nullptr)
3687 while (__end_ != __begin_)
3688 (--__end_)->~value_type();
3689 _VSTD::__libcpp_deallocate(__begin_);
3690 __begin_ = __end_ = nullptr;
3694 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3695 #ifndef _LIBCPP_NO_EXCEPTIONS
3698 #endif // _LIBCPP_NO_EXCEPTIONS
3699 for (; __n; --__n, ++__end_)
3700 ::new (__end_) value_type(__x);
3701 #ifndef _LIBCPP_NO_EXCEPTIONS
3708 #endif // _LIBCPP_NO_EXCEPTIONS
3713 inline _LIBCPP_INLINE_VISIBILITY
3715 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3720 template<class _Expr1, class _Expr2>
3721 inline _LIBCPP_INLINE_VISIBILITY
3724 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3725 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3727 operator*(const _Expr1& __x, const _Expr2& __y)
3729 typedef typename _Expr1::value_type value_type;
3730 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3731 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3734 template<class _Expr>
3735 inline _LIBCPP_INLINE_VISIBILITY
3738 __is_val_expr<_Expr>::value,
3739 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3740 _Expr, __scalar_expr<typename _Expr::value_type> > >
3742 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3744 typedef typename _Expr::value_type value_type;
3745 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3746 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3747 __x, __scalar_expr<value_type>(__y, __x.size())));
3750 template<class _Expr>
3751 inline _LIBCPP_INLINE_VISIBILITY
3754 __is_val_expr<_Expr>::value,
3755 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3756 __scalar_expr<typename _Expr::value_type>, _Expr> >
3758 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3760 typedef typename _Expr::value_type value_type;
3761 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3762 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3763 __scalar_expr<value_type>(__x, __y.size()), __y));
3766 template<class _Expr1, class _Expr2>
3767 inline _LIBCPP_INLINE_VISIBILITY
3770 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3771 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3773 operator/(const _Expr1& __x, const _Expr2& __y)
3775 typedef typename _Expr1::value_type value_type;
3776 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3777 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3780 template<class _Expr>
3781 inline _LIBCPP_INLINE_VISIBILITY
3784 __is_val_expr<_Expr>::value,
3785 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3786 _Expr, __scalar_expr<typename _Expr::value_type> > >
3788 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3790 typedef typename _Expr::value_type value_type;
3791 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3792 return __val_expr<_Op>(_Op(divides<value_type>(),
3793 __x, __scalar_expr<value_type>(__y, __x.size())));
3796 template<class _Expr>
3797 inline _LIBCPP_INLINE_VISIBILITY
3800 __is_val_expr<_Expr>::value,
3801 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3802 __scalar_expr<typename _Expr::value_type>, _Expr> >
3804 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3806 typedef typename _Expr::value_type value_type;
3807 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3808 return __val_expr<_Op>(_Op(divides<value_type>(),
3809 __scalar_expr<value_type>(__x, __y.size()), __y));
3812 template<class _Expr1, class _Expr2>
3813 inline _LIBCPP_INLINE_VISIBILITY
3816 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3817 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3819 operator%(const _Expr1& __x, const _Expr2& __y)
3821 typedef typename _Expr1::value_type value_type;
3822 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3823 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3826 template<class _Expr>
3827 inline _LIBCPP_INLINE_VISIBILITY
3830 __is_val_expr<_Expr>::value,
3831 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3832 _Expr, __scalar_expr<typename _Expr::value_type> > >
3834 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3836 typedef typename _Expr::value_type value_type;
3837 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3838 return __val_expr<_Op>(_Op(modulus<value_type>(),
3839 __x, __scalar_expr<value_type>(__y, __x.size())));
3842 template<class _Expr>
3843 inline _LIBCPP_INLINE_VISIBILITY
3846 __is_val_expr<_Expr>::value,
3847 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3848 __scalar_expr<typename _Expr::value_type>, _Expr> >
3850 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3852 typedef typename _Expr::value_type value_type;
3853 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3854 return __val_expr<_Op>(_Op(modulus<value_type>(),
3855 __scalar_expr<value_type>(__x, __y.size()), __y));
3858 template<class _Expr1, class _Expr2>
3859 inline _LIBCPP_INLINE_VISIBILITY
3862 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3863 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3865 operator+(const _Expr1& __x, const _Expr2& __y)
3867 typedef typename _Expr1::value_type value_type;
3868 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3869 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3872 template<class _Expr>
3873 inline _LIBCPP_INLINE_VISIBILITY
3876 __is_val_expr<_Expr>::value,
3877 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3878 _Expr, __scalar_expr<typename _Expr::value_type> > >
3880 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3882 typedef typename _Expr::value_type value_type;
3883 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3884 return __val_expr<_Op>(_Op(plus<value_type>(),
3885 __x, __scalar_expr<value_type>(__y, __x.size())));
3888 template<class _Expr>
3889 inline _LIBCPP_INLINE_VISIBILITY
3892 __is_val_expr<_Expr>::value,
3893 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3894 __scalar_expr<typename _Expr::value_type>, _Expr> >
3896 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3898 typedef typename _Expr::value_type value_type;
3899 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3900 return __val_expr<_Op>(_Op(plus<value_type>(),
3901 __scalar_expr<value_type>(__x, __y.size()), __y));
3904 template<class _Expr1, class _Expr2>
3905 inline _LIBCPP_INLINE_VISIBILITY
3908 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3909 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3911 operator-(const _Expr1& __x, const _Expr2& __y)
3913 typedef typename _Expr1::value_type value_type;
3914 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3915 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3918 template<class _Expr>
3919 inline _LIBCPP_INLINE_VISIBILITY
3922 __is_val_expr<_Expr>::value,
3923 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3924 _Expr, __scalar_expr<typename _Expr::value_type> > >
3926 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3928 typedef typename _Expr::value_type value_type;
3929 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3930 return __val_expr<_Op>(_Op(minus<value_type>(),
3931 __x, __scalar_expr<value_type>(__y, __x.size())));
3934 template<class _Expr>
3935 inline _LIBCPP_INLINE_VISIBILITY
3938 __is_val_expr<_Expr>::value,
3939 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3940 __scalar_expr<typename _Expr::value_type>, _Expr> >
3942 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3944 typedef typename _Expr::value_type value_type;
3945 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3946 return __val_expr<_Op>(_Op(minus<value_type>(),
3947 __scalar_expr<value_type>(__x, __y.size()), __y));
3950 template<class _Expr1, class _Expr2>
3951 inline _LIBCPP_INLINE_VISIBILITY
3954 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3955 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3957 operator^(const _Expr1& __x, const _Expr2& __y)
3959 typedef typename _Expr1::value_type value_type;
3960 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3961 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3964 template<class _Expr>
3965 inline _LIBCPP_INLINE_VISIBILITY
3968 __is_val_expr<_Expr>::value,
3969 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3970 _Expr, __scalar_expr<typename _Expr::value_type> > >
3972 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3974 typedef typename _Expr::value_type value_type;
3975 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3976 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3977 __x, __scalar_expr<value_type>(__y, __x.size())));
3980 template<class _Expr>
3981 inline _LIBCPP_INLINE_VISIBILITY
3984 __is_val_expr<_Expr>::value,
3985 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3986 __scalar_expr<typename _Expr::value_type>, _Expr> >
3988 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3990 typedef typename _Expr::value_type value_type;
3991 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3992 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3993 __scalar_expr<value_type>(__x, __y.size()), __y));
3996 template<class _Expr1, class _Expr2>
3997 inline _LIBCPP_INLINE_VISIBILITY
4000 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4001 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4003 operator&(const _Expr1& __x, const _Expr2& __y)
4005 typedef typename _Expr1::value_type value_type;
4006 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4007 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4010 template<class _Expr>
4011 inline _LIBCPP_INLINE_VISIBILITY
4014 __is_val_expr<_Expr>::value,
4015 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4016 _Expr, __scalar_expr<typename _Expr::value_type> > >
4018 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4020 typedef typename _Expr::value_type value_type;
4021 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4022 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4023 __x, __scalar_expr<value_type>(__y, __x.size())));
4026 template<class _Expr>
4027 inline _LIBCPP_INLINE_VISIBILITY
4030 __is_val_expr<_Expr>::value,
4031 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4032 __scalar_expr<typename _Expr::value_type>, _Expr> >
4034 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4036 typedef typename _Expr::value_type value_type;
4037 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4038 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4039 __scalar_expr<value_type>(__x, __y.size()), __y));
4042 template<class _Expr1, class _Expr2>
4043 inline _LIBCPP_INLINE_VISIBILITY
4046 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4047 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4049 operator|(const _Expr1& __x, const _Expr2& __y)
4051 typedef typename _Expr1::value_type value_type;
4052 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4053 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4056 template<class _Expr>
4057 inline _LIBCPP_INLINE_VISIBILITY
4060 __is_val_expr<_Expr>::value,
4061 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4062 _Expr, __scalar_expr<typename _Expr::value_type> > >
4064 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4066 typedef typename _Expr::value_type value_type;
4067 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4068 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4069 __x, __scalar_expr<value_type>(__y, __x.size())));
4072 template<class _Expr>
4073 inline _LIBCPP_INLINE_VISIBILITY
4076 __is_val_expr<_Expr>::value,
4077 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4078 __scalar_expr<typename _Expr::value_type>, _Expr> >
4080 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4082 typedef typename _Expr::value_type value_type;
4083 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4084 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4085 __scalar_expr<value_type>(__x, __y.size()), __y));
4088 template<class _Expr1, class _Expr2>
4089 inline _LIBCPP_INLINE_VISIBILITY
4092 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4093 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4095 operator<<(const _Expr1& __x, const _Expr2& __y)
4097 typedef typename _Expr1::value_type value_type;
4098 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4099 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4102 template<class _Expr>
4103 inline _LIBCPP_INLINE_VISIBILITY
4106 __is_val_expr<_Expr>::value,
4107 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4108 _Expr, __scalar_expr<typename _Expr::value_type> > >
4110 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4112 typedef typename _Expr::value_type value_type;
4113 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4114 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4115 __x, __scalar_expr<value_type>(__y, __x.size())));
4118 template<class _Expr>
4119 inline _LIBCPP_INLINE_VISIBILITY
4122 __is_val_expr<_Expr>::value,
4123 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4124 __scalar_expr<typename _Expr::value_type>, _Expr> >
4126 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4128 typedef typename _Expr::value_type value_type;
4129 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4130 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4131 __scalar_expr<value_type>(__x, __y.size()), __y));
4134 template<class _Expr1, class _Expr2>
4135 inline _LIBCPP_INLINE_VISIBILITY
4138 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4139 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4141 operator>>(const _Expr1& __x, const _Expr2& __y)
4143 typedef typename _Expr1::value_type value_type;
4144 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4145 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4148 template<class _Expr>
4149 inline _LIBCPP_INLINE_VISIBILITY
4152 __is_val_expr<_Expr>::value,
4153 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4154 _Expr, __scalar_expr<typename _Expr::value_type> > >
4156 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4158 typedef typename _Expr::value_type value_type;
4159 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4160 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4161 __x, __scalar_expr<value_type>(__y, __x.size())));
4164 template<class _Expr>
4165 inline _LIBCPP_INLINE_VISIBILITY
4168 __is_val_expr<_Expr>::value,
4169 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4170 __scalar_expr<typename _Expr::value_type>, _Expr> >
4172 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4174 typedef typename _Expr::value_type value_type;
4175 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4176 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4177 __scalar_expr<value_type>(__x, __y.size()), __y));
4180 template<class _Expr1, class _Expr2>
4181 inline _LIBCPP_INLINE_VISIBILITY
4184 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4185 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4187 operator&&(const _Expr1& __x, const _Expr2& __y)
4189 typedef typename _Expr1::value_type value_type;
4190 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4191 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4194 template<class _Expr>
4195 inline _LIBCPP_INLINE_VISIBILITY
4198 __is_val_expr<_Expr>::value,
4199 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4200 _Expr, __scalar_expr<typename _Expr::value_type> > >
4202 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4204 typedef typename _Expr::value_type value_type;
4205 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4206 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4207 __x, __scalar_expr<value_type>(__y, __x.size())));
4210 template<class _Expr>
4211 inline _LIBCPP_INLINE_VISIBILITY
4214 __is_val_expr<_Expr>::value,
4215 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4216 __scalar_expr<typename _Expr::value_type>, _Expr> >
4218 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4220 typedef typename _Expr::value_type value_type;
4221 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4222 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4223 __scalar_expr<value_type>(__x, __y.size()), __y));
4226 template<class _Expr1, class _Expr2>
4227 inline _LIBCPP_INLINE_VISIBILITY
4230 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4231 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4233 operator||(const _Expr1& __x, const _Expr2& __y)
4235 typedef typename _Expr1::value_type value_type;
4236 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4237 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4240 template<class _Expr>
4241 inline _LIBCPP_INLINE_VISIBILITY
4244 __is_val_expr<_Expr>::value,
4245 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4246 _Expr, __scalar_expr<typename _Expr::value_type> > >
4248 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4250 typedef typename _Expr::value_type value_type;
4251 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4252 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4253 __x, __scalar_expr<value_type>(__y, __x.size())));
4256 template<class _Expr>
4257 inline _LIBCPP_INLINE_VISIBILITY
4260 __is_val_expr<_Expr>::value,
4261 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4262 __scalar_expr<typename _Expr::value_type>, _Expr> >
4264 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4266 typedef typename _Expr::value_type value_type;
4267 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4268 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4269 __scalar_expr<value_type>(__x, __y.size()), __y));
4272 template<class _Expr1, class _Expr2>
4273 inline _LIBCPP_INLINE_VISIBILITY
4276 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4277 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4279 operator==(const _Expr1& __x, const _Expr2& __y)
4281 typedef typename _Expr1::value_type value_type;
4282 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4283 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4286 template<class _Expr>
4287 inline _LIBCPP_INLINE_VISIBILITY
4290 __is_val_expr<_Expr>::value,
4291 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4292 _Expr, __scalar_expr<typename _Expr::value_type> > >
4294 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4296 typedef typename _Expr::value_type value_type;
4297 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4298 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4299 __x, __scalar_expr<value_type>(__y, __x.size())));
4302 template<class _Expr>
4303 inline _LIBCPP_INLINE_VISIBILITY
4306 __is_val_expr<_Expr>::value,
4307 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4308 __scalar_expr<typename _Expr::value_type>, _Expr> >
4310 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4312 typedef typename _Expr::value_type value_type;
4313 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4314 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4315 __scalar_expr<value_type>(__x, __y.size()), __y));
4318 template<class _Expr1, class _Expr2>
4319 inline _LIBCPP_INLINE_VISIBILITY
4322 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4323 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4325 operator!=(const _Expr1& __x, const _Expr2& __y)
4327 typedef typename _Expr1::value_type value_type;
4328 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4329 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4332 template<class _Expr>
4333 inline _LIBCPP_INLINE_VISIBILITY
4336 __is_val_expr<_Expr>::value,
4337 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4338 _Expr, __scalar_expr<typename _Expr::value_type> > >
4340 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4342 typedef typename _Expr::value_type value_type;
4343 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4344 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4345 __x, __scalar_expr<value_type>(__y, __x.size())));
4348 template<class _Expr>
4349 inline _LIBCPP_INLINE_VISIBILITY
4352 __is_val_expr<_Expr>::value,
4353 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4354 __scalar_expr<typename _Expr::value_type>, _Expr> >
4356 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4358 typedef typename _Expr::value_type value_type;
4359 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4360 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4361 __scalar_expr<value_type>(__x, __y.size()), __y));
4364 template<class _Expr1, class _Expr2>
4365 inline _LIBCPP_INLINE_VISIBILITY
4368 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4369 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4371 operator<(const _Expr1& __x, const _Expr2& __y)
4373 typedef typename _Expr1::value_type value_type;
4374 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4375 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4378 template<class _Expr>
4379 inline _LIBCPP_INLINE_VISIBILITY
4382 __is_val_expr<_Expr>::value,
4383 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4384 _Expr, __scalar_expr<typename _Expr::value_type> > >
4386 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4388 typedef typename _Expr::value_type value_type;
4389 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4390 return __val_expr<_Op>(_Op(less<value_type>(),
4391 __x, __scalar_expr<value_type>(__y, __x.size())));
4394 template<class _Expr>
4395 inline _LIBCPP_INLINE_VISIBILITY
4398 __is_val_expr<_Expr>::value,
4399 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4400 __scalar_expr<typename _Expr::value_type>, _Expr> >
4402 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4404 typedef typename _Expr::value_type value_type;
4405 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4406 return __val_expr<_Op>(_Op(less<value_type>(),
4407 __scalar_expr<value_type>(__x, __y.size()), __y));
4410 template<class _Expr1, class _Expr2>
4411 inline _LIBCPP_INLINE_VISIBILITY
4414 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4415 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4417 operator>(const _Expr1& __x, const _Expr2& __y)
4419 typedef typename _Expr1::value_type value_type;
4420 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4421 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4424 template<class _Expr>
4425 inline _LIBCPP_INLINE_VISIBILITY
4428 __is_val_expr<_Expr>::value,
4429 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4430 _Expr, __scalar_expr<typename _Expr::value_type> > >
4432 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4434 typedef typename _Expr::value_type value_type;
4435 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4436 return __val_expr<_Op>(_Op(greater<value_type>(),
4437 __x, __scalar_expr<value_type>(__y, __x.size())));
4440 template<class _Expr>
4441 inline _LIBCPP_INLINE_VISIBILITY
4444 __is_val_expr<_Expr>::value,
4445 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4446 __scalar_expr<typename _Expr::value_type>, _Expr> >
4448 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4450 typedef typename _Expr::value_type value_type;
4451 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4452 return __val_expr<_Op>(_Op(greater<value_type>(),
4453 __scalar_expr<value_type>(__x, __y.size()), __y));
4456 template<class _Expr1, class _Expr2>
4457 inline _LIBCPP_INLINE_VISIBILITY
4460 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4461 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4463 operator<=(const _Expr1& __x, const _Expr2& __y)
4465 typedef typename _Expr1::value_type value_type;
4466 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4467 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4470 template<class _Expr>
4471 inline _LIBCPP_INLINE_VISIBILITY
4474 __is_val_expr<_Expr>::value,
4475 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4476 _Expr, __scalar_expr<typename _Expr::value_type> > >
4478 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4480 typedef typename _Expr::value_type value_type;
4481 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4482 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4483 __x, __scalar_expr<value_type>(__y, __x.size())));
4486 template<class _Expr>
4487 inline _LIBCPP_INLINE_VISIBILITY
4490 __is_val_expr<_Expr>::value,
4491 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4492 __scalar_expr<typename _Expr::value_type>, _Expr> >
4494 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4496 typedef typename _Expr::value_type value_type;
4497 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4498 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4499 __scalar_expr<value_type>(__x, __y.size()), __y));
4502 template<class _Expr1, class _Expr2>
4503 inline _LIBCPP_INLINE_VISIBILITY
4506 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4507 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4509 operator>=(const _Expr1& __x, const _Expr2& __y)
4511 typedef typename _Expr1::value_type value_type;
4512 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4513 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4516 template<class _Expr>
4517 inline _LIBCPP_INLINE_VISIBILITY
4520 __is_val_expr<_Expr>::value,
4521 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4522 _Expr, __scalar_expr<typename _Expr::value_type> > >
4524 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4526 typedef typename _Expr::value_type value_type;
4527 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4528 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4529 __x, __scalar_expr<value_type>(__y, __x.size())));
4532 template<class _Expr>
4533 inline _LIBCPP_INLINE_VISIBILITY
4536 __is_val_expr<_Expr>::value,
4537 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4538 __scalar_expr<typename _Expr::value_type>, _Expr> >
4540 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4542 typedef typename _Expr::value_type value_type;
4543 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4544 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4545 __scalar_expr<value_type>(__x, __y.size()), __y));
4548 template<class _Expr>
4549 inline _LIBCPP_INLINE_VISIBILITY
4552 __is_val_expr<_Expr>::value,
4553 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4555 abs(const _Expr& __x)
4557 typedef typename _Expr::value_type value_type;
4558 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4559 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4562 template<class _Expr>
4563 inline _LIBCPP_INLINE_VISIBILITY
4566 __is_val_expr<_Expr>::value,
4567 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4569 acos(const _Expr& __x)
4571 typedef typename _Expr::value_type value_type;
4572 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4573 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4576 template<class _Expr>
4577 inline _LIBCPP_INLINE_VISIBILITY
4580 __is_val_expr<_Expr>::value,
4581 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4583 asin(const _Expr& __x)
4585 typedef typename _Expr::value_type value_type;
4586 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4587 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4590 template<class _Expr>
4591 inline _LIBCPP_INLINE_VISIBILITY
4594 __is_val_expr<_Expr>::value,
4595 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4597 atan(const _Expr& __x)
4599 typedef typename _Expr::value_type value_type;
4600 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4601 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4604 template<class _Expr1, class _Expr2>
4605 inline _LIBCPP_INLINE_VISIBILITY
4608 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4609 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4611 atan2(const _Expr1& __x, const _Expr2& __y)
4613 typedef typename _Expr1::value_type value_type;
4614 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4615 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4618 template<class _Expr>
4619 inline _LIBCPP_INLINE_VISIBILITY
4622 __is_val_expr<_Expr>::value,
4623 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4624 _Expr, __scalar_expr<typename _Expr::value_type> > >
4626 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4628 typedef typename _Expr::value_type value_type;
4629 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4630 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4631 __x, __scalar_expr<value_type>(__y, __x.size())));
4634 template<class _Expr>
4635 inline _LIBCPP_INLINE_VISIBILITY
4638 __is_val_expr<_Expr>::value,
4639 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4640 __scalar_expr<typename _Expr::value_type>, _Expr> >
4642 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4644 typedef typename _Expr::value_type value_type;
4645 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4646 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4647 __scalar_expr<value_type>(__x, __y.size()), __y));
4650 template<class _Expr>
4651 inline _LIBCPP_INLINE_VISIBILITY
4654 __is_val_expr<_Expr>::value,
4655 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4657 cos(const _Expr& __x)
4659 typedef typename _Expr::value_type value_type;
4660 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4661 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4664 template<class _Expr>
4665 inline _LIBCPP_INLINE_VISIBILITY
4668 __is_val_expr<_Expr>::value,
4669 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4671 cosh(const _Expr& __x)
4673 typedef typename _Expr::value_type value_type;
4674 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4675 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4678 template<class _Expr>
4679 inline _LIBCPP_INLINE_VISIBILITY
4682 __is_val_expr<_Expr>::value,
4683 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4685 exp(const _Expr& __x)
4687 typedef typename _Expr::value_type value_type;
4688 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4689 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4692 template<class _Expr>
4693 inline _LIBCPP_INLINE_VISIBILITY
4696 __is_val_expr<_Expr>::value,
4697 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4699 log(const _Expr& __x)
4701 typedef typename _Expr::value_type value_type;
4702 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4703 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4706 template<class _Expr>
4707 inline _LIBCPP_INLINE_VISIBILITY
4710 __is_val_expr<_Expr>::value,
4711 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4713 log10(const _Expr& __x)
4715 typedef typename _Expr::value_type value_type;
4716 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4717 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4720 template<class _Expr1, class _Expr2>
4721 inline _LIBCPP_INLINE_VISIBILITY
4724 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4725 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4727 pow(const _Expr1& __x, const _Expr2& __y)
4729 typedef typename _Expr1::value_type value_type;
4730 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4731 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4734 template<class _Expr>
4735 inline _LIBCPP_INLINE_VISIBILITY
4738 __is_val_expr<_Expr>::value,
4739 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4740 _Expr, __scalar_expr<typename _Expr::value_type> > >
4742 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4744 typedef typename _Expr::value_type value_type;
4745 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4746 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4747 __x, __scalar_expr<value_type>(__y, __x.size())));
4750 template<class _Expr>
4751 inline _LIBCPP_INLINE_VISIBILITY
4754 __is_val_expr<_Expr>::value,
4755 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4756 __scalar_expr<typename _Expr::value_type>, _Expr> >
4758 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4760 typedef typename _Expr::value_type value_type;
4761 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4762 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4763 __scalar_expr<value_type>(__x, __y.size()), __y));
4766 template<class _Expr>
4767 inline _LIBCPP_INLINE_VISIBILITY
4770 __is_val_expr<_Expr>::value,
4771 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4773 sin(const _Expr& __x)
4775 typedef typename _Expr::value_type value_type;
4776 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4777 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4780 template<class _Expr>
4781 inline _LIBCPP_INLINE_VISIBILITY
4784 __is_val_expr<_Expr>::value,
4785 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4787 sinh(const _Expr& __x)
4789 typedef typename _Expr::value_type value_type;
4790 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4791 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4794 template<class _Expr>
4795 inline _LIBCPP_INLINE_VISIBILITY
4798 __is_val_expr<_Expr>::value,
4799 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4801 sqrt(const _Expr& __x)
4803 typedef typename _Expr::value_type value_type;
4804 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4805 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4808 template<class _Expr>
4809 inline _LIBCPP_INLINE_VISIBILITY
4812 __is_val_expr<_Expr>::value,
4813 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4815 tan(const _Expr& __x)
4817 typedef typename _Expr::value_type value_type;
4818 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4819 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4822 template<class _Expr>
4823 inline _LIBCPP_INLINE_VISIBILITY
4826 __is_val_expr<_Expr>::value,
4827 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4829 tanh(const _Expr& __x)
4831 typedef typename _Expr::value_type value_type;
4832 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4833 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4836 template <class _Tp>
4837 inline _LIBCPP_INLINE_VISIBILITY
4839 begin(valarray<_Tp>& __v)
4841 return __v.__begin_;
4844 template <class _Tp>
4845 inline _LIBCPP_INLINE_VISIBILITY
4847 begin(const valarray<_Tp>& __v)
4849 return __v.__begin_;
4852 template <class _Tp>
4853 inline _LIBCPP_INLINE_VISIBILITY
4855 end(valarray<_Tp>& __v)
4860 template <class _Tp>
4861 inline _LIBCPP_INLINE_VISIBILITY
4863 end(const valarray<_Tp>& __v)
4868 _LIBCPP_END_NAMESPACE_STD
4872 #endif // _LIBCPP_VALARRAY