2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_VALARRAY
11 #define _LIBCPP_VALARRAY
27 explicit valarray(size_t n);
28 valarray(const value_type& x, size_t n);
29 valarray(const value_type* px, size_t n);
30 valarray(const valarray& v);
31 valarray(valarray&& v) noexcept;
32 valarray(const slice_array<value_type>& sa);
33 valarray(const gslice_array<value_type>& ga);
34 valarray(const mask_array<value_type>& ma);
35 valarray(const indirect_array<value_type>& ia);
36 valarray(initializer_list<value_type> il);
40 valarray& operator=(const valarray& v);
41 valarray& operator=(valarray&& v) noexcept;
42 valarray& operator=(initializer_list<value_type> il);
43 valarray& operator=(const value_type& x);
44 valarray& operator=(const slice_array<value_type>& sa);
45 valarray& operator=(const gslice_array<value_type>& ga);
46 valarray& operator=(const mask_array<value_type>& ma);
47 valarray& operator=(const indirect_array<value_type>& ia);
50 const value_type& operator[](size_t i) const;
51 value_type& operator[](size_t i);
54 valarray operator[](slice s) const;
55 slice_array<value_type> operator[](slice s);
56 valarray operator[](const gslice& gs) const;
57 gslice_array<value_type> operator[](const gslice& gs);
58 valarray operator[](const valarray<bool>& vb) const;
59 mask_array<value_type> operator[](const valarray<bool>& vb);
60 valarray operator[](const valarray<size_t>& vs) const;
61 indirect_array<value_type> operator[](const valarray<size_t>& vs);
64 valarray operator+() const;
65 valarray operator-() const;
66 valarray operator~() const;
67 valarray<bool> operator!() const;
69 // computed assignment:
70 valarray& operator*= (const value_type& x);
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);
81 valarray& operator*= (const valarray& v);
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);
93 void swap(valarray& v) noexcept;
97 value_type sum() const;
98 value_type min() const;
99 value_type max() const;
101 valarray shift (int i) const;
102 valarray cshift(int i) const;
103 valarray apply(value_type f(value_type)) const;
104 valarray apply(value_type f(const value_type&)) const;
105 void resize(size_t n, value_type x = value_type());
108 template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>;
114 slice(size_t start, size_t size, size_t stride);
116 size_t start() const;
118 size_t stride() const;
125 typedef T value_type;
127 const slice_array& operator=(const slice_array& sa) 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;
138 void operator>>=(const valarray<value_type>& v) const;
140 void operator=(const value_type& x) const;
141 void operator=(const valarray<T>& val_arr) const;
143 slice_array() = delete;
150 gslice(size_t start, const valarray<size_t>& size,
151 const valarray<size_t>& stride);
153 size_t start() const;
154 valarray<size_t> size() const;
155 valarray<size_t> stride() const;
162 typedef T value_type;
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;
173 void operator<<=(const valarray<value_type>& v) const;
174 void operator>>=(const valarray<value_type>& v) const;
176 gslice_array(const gslice_array& ga);
178 const gslice_array& operator=(const gslice_array& ga) const;
179 void operator=(const value_type& x) const;
181 gslice_array() = delete;
188 typedef T value_type;
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;
199 void operator<<=(const valarray<value_type>& v) const;
200 void operator>>=(const valarray<value_type>& v) const;
202 mask_array(const mask_array& ma);
204 const mask_array& operator=(const mask_array& ma) const;
205 void operator=(const value_type& x) const;
207 mask_array() = delete;
214 typedef T value_type;
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;
225 void operator<<=(const valarray<value_type>& v) const;
226 void operator>>=(const valarray<value_type>& v) const;
228 indirect_array(const indirect_array& ia);
230 const indirect_array& operator=(const indirect_array& ia) const;
231 void operator=(const value_type& x) const;
233 indirect_array() = delete;
236 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
238 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
239 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
240 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
242 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
243 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
244 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
246 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
247 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
248 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
250 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
251 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
252 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
254 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
255 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
256 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
258 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
259 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
260 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
262 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
263 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
264 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
266 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
267 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
268 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
270 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
271 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
272 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
274 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
275 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
276 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
278 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
279 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
280 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
282 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
283 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
284 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
286 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
287 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
288 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
290 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
291 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
292 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
294 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
295 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
296 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
298 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
299 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
300 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
302 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
303 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
304 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
306 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
307 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
308 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
310 template<class T> valarray<T> abs (const valarray<T>& x);
311 template<class T> valarray<T> acos (const valarray<T>& x);
312 template<class T> valarray<T> asin (const valarray<T>& x);
313 template<class T> valarray<T> atan (const valarray<T>& x);
315 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
316 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
317 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
319 template<class T> valarray<T> cos (const valarray<T>& x);
320 template<class T> valarray<T> cosh (const valarray<T>& x);
321 template<class T> valarray<T> exp (const valarray<T>& x);
322 template<class T> valarray<T> log (const valarray<T>& x);
323 template<class T> valarray<T> log10(const valarray<T>& x);
325 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
326 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
327 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
329 template<class T> valarray<T> sin (const valarray<T>& x);
330 template<class T> valarray<T> sinh (const valarray<T>& x);
331 template<class T> valarray<T> sqrt (const valarray<T>& x);
332 template<class T> valarray<T> tan (const valarray<T>& x);
333 template<class T> valarray<T> tanh (const valarray<T>& x);
335 template <class T> unspecified1 begin(valarray<T>& v);
336 template <class T> unspecified2 begin(const valarray<T>& v);
337 template <class T> unspecified1 end(valarray<T>& v);
338 template <class T> unspecified2 end(const valarray<T>& v);
348 #include <functional>
349 #include <initializer_list>
353 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
354 #pragma GCC system_header
358 #include <__undef_macros>
360 _LIBCPP_BEGIN_NAMESPACE_STD
362 template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
364 class _LIBCPP_TEMPLATE_VIS slice
370 _LIBCPP_INLINE_VISIBILITY
377 _LIBCPP_INLINE_VISIBILITY
378 slice(size_t __start, size_t __size, size_t __stride)
384 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
385 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
386 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
389 template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
390 class _LIBCPP_TYPE_VIS gslice;
391 template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
392 template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
393 template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
396 _LIBCPP_INLINE_VISIBILITY
398 begin(valarray<_Tp>& __v);
401 _LIBCPP_INLINE_VISIBILITY
403 begin(const valarray<_Tp>& __v);
406 _LIBCPP_INLINE_VISIBILITY
408 end(valarray<_Tp>& __v);
411 _LIBCPP_INLINE_VISIBILITY
413 end(const valarray<_Tp>& __v);
415 template <class _Op, class _A0>
418 typedef typename _Op::__result_type __result_type;
419 typedef typename decay<__result_type>::type value_type;
424 _LIBCPP_INLINE_VISIBILITY
425 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
427 _LIBCPP_INLINE_VISIBILITY
428 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
430 _LIBCPP_INLINE_VISIBILITY
431 size_t size() const {return __a0_.size();}
434 template <class _Op, class _A0, class _A1>
437 typedef typename _Op::__result_type __result_type;
438 typedef typename decay<__result_type>::type value_type;
444 _LIBCPP_INLINE_VISIBILITY
445 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
446 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
448 _LIBCPP_INLINE_VISIBILITY
449 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
451 _LIBCPP_INLINE_VISIBILITY
452 size_t size() const {return __a0_.size();}
459 typedef _Tp value_type;
460 typedef const _Tp& __result_type;
462 const value_type& __t_;
465 _LIBCPP_INLINE_VISIBILITY
466 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
468 _LIBCPP_INLINE_VISIBILITY
469 __result_type operator[](size_t) const {return __t_;}
471 _LIBCPP_INLINE_VISIBILITY
472 size_t size() const {return __s_;}
478 typedef _Tp __result_type;
479 _LIBCPP_INLINE_VISIBILITY
480 _Tp operator()(const _Tp& __x) const
487 typedef _Tp __result_type;
488 _LIBCPP_INLINE_VISIBILITY
489 _Tp operator()(const _Tp& __x) const
494 struct __bit_shift_left
496 typedef _Tp __result_type;
497 _LIBCPP_INLINE_VISIBILITY
498 _Tp operator()(const _Tp& __x, const _Tp& __y) const
503 struct __bit_shift_right
505 typedef _Tp __result_type;
506 _LIBCPP_INLINE_VISIBILITY
507 _Tp operator()(const _Tp& __x, const _Tp& __y) const
511 template <class _Tp, class _Fp>
517 typedef _Tp __result_type;
519 _LIBCPP_INLINE_VISIBILITY
520 explicit __apply_expr(_Fp __f) : __f_(__f) {}
522 _LIBCPP_INLINE_VISIBILITY
523 _Tp operator()(const _Tp& __x) const
530 typedef _Tp __result_type;
531 _LIBCPP_INLINE_VISIBILITY
532 _Tp operator()(const _Tp& __x) const
539 typedef _Tp __result_type;
540 _LIBCPP_INLINE_VISIBILITY
541 _Tp operator()(const _Tp& __x) const
548 typedef _Tp __result_type;
549 _LIBCPP_INLINE_VISIBILITY
550 _Tp operator()(const _Tp& __x) const
557 typedef _Tp __result_type;
558 _LIBCPP_INLINE_VISIBILITY
559 _Tp operator()(const _Tp& __x) const
566 typedef _Tp __result_type;
567 _LIBCPP_INLINE_VISIBILITY
568 _Tp operator()(const _Tp& __x, const _Tp& __y) const
569 {return atan2(__x, __y);}
575 typedef _Tp __result_type;
576 _LIBCPP_INLINE_VISIBILITY
577 _Tp operator()(const _Tp& __x) const
584 typedef _Tp __result_type;
585 _LIBCPP_INLINE_VISIBILITY
586 _Tp operator()(const _Tp& __x) const
593 typedef _Tp __result_type;
594 _LIBCPP_INLINE_VISIBILITY
595 _Tp operator()(const _Tp& __x) const
602 typedef _Tp __result_type;
603 _LIBCPP_INLINE_VISIBILITY
604 _Tp operator()(const _Tp& __x) const
611 typedef _Tp __result_type;
612 _LIBCPP_INLINE_VISIBILITY
613 _Tp operator()(const _Tp& __x) const
620 typedef _Tp __result_type;
621 _LIBCPP_INLINE_VISIBILITY
622 _Tp operator()(const _Tp& __x, const _Tp& __y) const
623 {return pow(__x, __y);}
629 typedef _Tp __result_type;
630 _LIBCPP_INLINE_VISIBILITY
631 _Tp operator()(const _Tp& __x) const
638 typedef _Tp __result_type;
639 _LIBCPP_INLINE_VISIBILITY
640 _Tp operator()(const _Tp& __x) const
647 typedef _Tp __result_type;
648 _LIBCPP_INLINE_VISIBILITY
649 _Tp operator()(const _Tp& __x) const
656 typedef _Tp __result_type;
657 _LIBCPP_INLINE_VISIBILITY
658 _Tp operator()(const _Tp& __x) const
665 typedef _Tp __result_type;
666 _LIBCPP_INLINE_VISIBILITY
667 _Tp operator()(const _Tp& __x) const
671 template <class _ValExpr>
674 typedef typename remove_reference<_ValExpr>::type _RmExpr;
676 typedef typename _RmExpr::value_type value_type;
677 typedef value_type __result_type;
685 _LIBCPP_INLINE_VISIBILITY
686 __slice_expr(const slice& __sl, const _RmExpr& __e)
688 __start_(__sl.start()),
689 __size_(__sl.size()),
690 __stride_(__sl.stride())
694 _LIBCPP_INLINE_VISIBILITY
695 __result_type operator[](size_t __i) const
696 {return __expr_[__start_ + __i * __stride_];}
698 _LIBCPP_INLINE_VISIBILITY
699 size_t size() const {return __size_;}
701 template <class> friend class __val_expr;
702 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
705 template <class _ValExpr>
708 template <class _ValExpr>
709 class __indirect_expr;
711 template <class _ValExpr>
714 typedef typename remove_reference<_ValExpr>::type _RmExpr;
716 typedef typename _RmExpr::value_type value_type;
717 typedef value_type __result_type;
725 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
726 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
728 _LIBCPP_INLINE_VISIBILITY
729 __shift_expr(int __n, const _RmExpr& __e)
734 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
735 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
736 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
740 _LIBCPP_INLINE_VISIBILITY
741 __result_type operator[](size_t __j) const
743 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
744 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
745 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
748 _LIBCPP_INLINE_VISIBILITY
749 size_t size() const {return __size_;}
751 template <class> friend class __val_expr;
754 template <class _ValExpr>
757 typedef typename remove_reference<_ValExpr>::type _RmExpr;
759 typedef typename _RmExpr::value_type value_type;
760 typedef value_type __result_type;
769 _LIBCPP_INLINE_VISIBILITY
770 __cshift_expr(int __n, const _RmExpr& __e)
774 __n %= static_cast<int>(__size_);
777 __m_ = __size_ - __n;
779 __o2_ = __n - __size_;
784 __o1_ = __n + __size_;
790 _LIBCPP_INLINE_VISIBILITY
791 __result_type operator[](size_t __i) const
794 return __expr_[__i + __o1_];
795 return __expr_[__i + __o2_];
798 _LIBCPP_INLINE_VISIBILITY
799 size_t size() const {return __size_;}
801 template <class> friend class __val_expr;
804 template<class _ValExpr>
807 template<class _ValExpr>
808 struct __is_val_expr : false_type {};
810 template<class _ValExpr>
811 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
814 struct __is_val_expr<valarray<_Tp> > : true_type {};
817 class _LIBCPP_TEMPLATE_VIS valarray
820 typedef _Tp value_type;
821 typedef _Tp __result_type;
824 value_type* __begin_;
828 // construct/destroy:
829 _LIBCPP_INLINE_VISIBILITY
830 valarray() : __begin_(nullptr), __end_(nullptr) {}
831 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
832 explicit valarray(size_t __n);
833 _LIBCPP_INLINE_VISIBILITY
834 valarray(const value_type& __x, size_t __n);
835 valarray(const value_type* __p, size_t __n);
836 valarray(const valarray& __v);
837 #ifndef _LIBCPP_CXX03_LANG
838 _LIBCPP_INLINE_VISIBILITY
839 valarray(valarray&& __v) _NOEXCEPT;
840 valarray(initializer_list<value_type> __il);
841 #endif // _LIBCPP_CXX03_LANG
842 valarray(const slice_array<value_type>& __sa);
843 valarray(const gslice_array<value_type>& __ga);
844 valarray(const mask_array<value_type>& __ma);
845 valarray(const indirect_array<value_type>& __ia);
846 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
850 valarray& operator=(const valarray& __v);
851 #ifndef _LIBCPP_CXX03_LANG
852 _LIBCPP_INLINE_VISIBILITY
853 valarray& operator=(valarray&& __v) _NOEXCEPT;
854 _LIBCPP_INLINE_VISIBILITY
855 valarray& operator=(initializer_list<value_type>);
856 #endif // _LIBCPP_CXX03_LANG
857 _LIBCPP_INLINE_VISIBILITY
858 valarray& operator=(const value_type& __x);
859 _LIBCPP_INLINE_VISIBILITY
860 valarray& operator=(const slice_array<value_type>& __sa);
861 _LIBCPP_INLINE_VISIBILITY
862 valarray& operator=(const gslice_array<value_type>& __ga);
863 _LIBCPP_INLINE_VISIBILITY
864 valarray& operator=(const mask_array<value_type>& __ma);
865 _LIBCPP_INLINE_VISIBILITY
866 valarray& operator=(const indirect_array<value_type>& __ia);
867 template <class _ValExpr>
868 _LIBCPP_INLINE_VISIBILITY
869 valarray& operator=(const __val_expr<_ValExpr>& __v);
872 _LIBCPP_INLINE_VISIBILITY
873 const value_type& operator[](size_t __i) const {return __begin_[__i];}
875 _LIBCPP_INLINE_VISIBILITY
876 value_type& operator[](size_t __i) {return __begin_[__i];}
878 // subset operations:
879 _LIBCPP_INLINE_VISIBILITY
880 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
881 _LIBCPP_INLINE_VISIBILITY
882 slice_array<value_type> operator[](slice __s);
883 _LIBCPP_INLINE_VISIBILITY
884 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
885 _LIBCPP_INLINE_VISIBILITY
886 gslice_array<value_type> operator[](const gslice& __gs);
887 #ifndef _LIBCPP_CXX03_LANG
888 _LIBCPP_INLINE_VISIBILITY
889 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
890 _LIBCPP_INLINE_VISIBILITY
891 gslice_array<value_type> operator[](gslice&& __gs);
892 #endif // _LIBCPP_CXX03_LANG
893 _LIBCPP_INLINE_VISIBILITY
894 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
895 _LIBCPP_INLINE_VISIBILITY
896 mask_array<value_type> operator[](const valarray<bool>& __vb);
897 #ifndef _LIBCPP_CXX03_LANG
898 _LIBCPP_INLINE_VISIBILITY
899 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
900 _LIBCPP_INLINE_VISIBILITY
901 mask_array<value_type> operator[](valarray<bool>&& __vb);
902 #endif // _LIBCPP_CXX03_LANG
903 _LIBCPP_INLINE_VISIBILITY
904 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
905 _LIBCPP_INLINE_VISIBILITY
906 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
907 #ifndef _LIBCPP_CXX03_LANG
908 _LIBCPP_INLINE_VISIBILITY
909 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
910 _LIBCPP_INLINE_VISIBILITY
911 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
912 #endif // _LIBCPP_CXX03_LANG
915 valarray operator+() const;
916 valarray operator-() const;
917 valarray operator~() const;
918 valarray<bool> operator!() const;
920 // computed assignment:
921 _LIBCPP_INLINE_VISIBILITY
922 valarray& operator*= (const value_type& __x);
923 _LIBCPP_INLINE_VISIBILITY
924 valarray& operator/= (const value_type& __x);
925 _LIBCPP_INLINE_VISIBILITY
926 valarray& operator%= (const value_type& __x);
927 _LIBCPP_INLINE_VISIBILITY
928 valarray& operator+= (const value_type& __x);
929 _LIBCPP_INLINE_VISIBILITY
930 valarray& operator-= (const value_type& __x);
931 _LIBCPP_INLINE_VISIBILITY
932 valarray& operator^= (const value_type& __x);
933 _LIBCPP_INLINE_VISIBILITY
934 valarray& operator&= (const value_type& __x);
935 _LIBCPP_INLINE_VISIBILITY
936 valarray& operator|= (const value_type& __x);
937 _LIBCPP_INLINE_VISIBILITY
938 valarray& operator<<=(const value_type& __x);
939 _LIBCPP_INLINE_VISIBILITY
940 valarray& operator>>=(const value_type& __x);
942 template <class _Expr>
945 __is_val_expr<_Expr>::value,
948 _LIBCPP_INLINE_VISIBILITY
949 operator*= (const _Expr& __v);
951 template <class _Expr>
954 __is_val_expr<_Expr>::value,
957 _LIBCPP_INLINE_VISIBILITY
958 operator/= (const _Expr& __v);
960 template <class _Expr>
963 __is_val_expr<_Expr>::value,
966 _LIBCPP_INLINE_VISIBILITY
967 operator%= (const _Expr& __v);
969 template <class _Expr>
972 __is_val_expr<_Expr>::value,
975 _LIBCPP_INLINE_VISIBILITY
976 operator+= (const _Expr& __v);
978 template <class _Expr>
981 __is_val_expr<_Expr>::value,
984 _LIBCPP_INLINE_VISIBILITY
985 operator-= (const _Expr& __v);
987 template <class _Expr>
990 __is_val_expr<_Expr>::value,
993 _LIBCPP_INLINE_VISIBILITY
994 operator^= (const _Expr& __v);
996 template <class _Expr>
999 __is_val_expr<_Expr>::value,
1002 _LIBCPP_INLINE_VISIBILITY
1003 operator|= (const _Expr& __v);
1005 template <class _Expr>
1008 __is_val_expr<_Expr>::value,
1011 _LIBCPP_INLINE_VISIBILITY
1012 operator&= (const _Expr& __v);
1014 template <class _Expr>
1017 __is_val_expr<_Expr>::value,
1020 _LIBCPP_INLINE_VISIBILITY
1021 operator<<= (const _Expr& __v);
1023 template <class _Expr>
1026 __is_val_expr<_Expr>::value,
1029 _LIBCPP_INLINE_VISIBILITY
1030 operator>>= (const _Expr& __v);
1032 // member functions:
1033 _LIBCPP_INLINE_VISIBILITY
1034 void swap(valarray& __v) _NOEXCEPT;
1036 _LIBCPP_INLINE_VISIBILITY
1037 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
1039 _LIBCPP_INLINE_VISIBILITY
1040 value_type sum() const;
1041 _LIBCPP_INLINE_VISIBILITY
1042 value_type min() const;
1043 _LIBCPP_INLINE_VISIBILITY
1044 value_type max() const;
1046 valarray shift (int __i) const;
1047 valarray cshift(int __i) const;
1048 valarray apply(value_type __f(value_type)) const;
1049 valarray apply(value_type __f(const value_type&)) const;
1050 void resize(size_t __n, value_type __x = value_type());
1053 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1054 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1055 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1056 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
1057 template <class> friend class __mask_expr;
1058 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
1059 template <class> friend class __indirect_expr;
1060 template <class> friend class __val_expr;
1062 template <class _Up>
1065 begin(valarray<_Up>& __v);
1067 template <class _Up>
1070 begin(const valarray<_Up>& __v);
1072 template <class _Up>
1075 end(valarray<_Up>& __v);
1077 template <class _Up>
1080 end(const valarray<_Up>& __v);
1082 _LIBCPP_INLINE_VISIBILITY
1083 void __clear(size_t __capacity);
1084 valarray& __assign_range(const value_type* __f, const value_type* __l);
1087 #if _LIBCPP_STD_VER > 14
1088 template<class _Tp, size_t _Size>
1089 valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>;
1092 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1094 template <class _Op, class _Tp>
1095 struct _UnaryOp<_Op, valarray<_Tp> >
1097 typedef typename _Op::__result_type __result_type;
1098 typedef typename decay<__result_type>::type value_type;
1101 const valarray<_Tp>& __a0_;
1103 _LIBCPP_INLINE_VISIBILITY
1104 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1106 _LIBCPP_INLINE_VISIBILITY
1107 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1109 _LIBCPP_INLINE_VISIBILITY
1110 size_t size() const {return __a0_.size();}
1113 template <class _Op, class _Tp, class _A1>
1114 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1116 typedef typename _Op::__result_type __result_type;
1117 typedef typename decay<__result_type>::type value_type;
1120 const valarray<_Tp>& __a0_;
1123 _LIBCPP_INLINE_VISIBILITY
1124 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1125 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1127 _LIBCPP_INLINE_VISIBILITY
1128 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1130 _LIBCPP_INLINE_VISIBILITY
1131 size_t size() const {return __a0_.size();}
1134 template <class _Op, class _A0, class _Tp>
1135 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1137 typedef typename _Op::__result_type __result_type;
1138 typedef typename decay<__result_type>::type value_type;
1142 const valarray<_Tp>& __a1_;
1144 _LIBCPP_INLINE_VISIBILITY
1145 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1146 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1148 _LIBCPP_INLINE_VISIBILITY
1149 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1151 _LIBCPP_INLINE_VISIBILITY
1152 size_t size() const {return __a0_.size();}
1155 template <class _Op, class _Tp>
1156 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1158 typedef typename _Op::__result_type __result_type;
1159 typedef typename decay<__result_type>::type value_type;
1162 const valarray<_Tp>& __a0_;
1163 const valarray<_Tp>& __a1_;
1165 _LIBCPP_INLINE_VISIBILITY
1166 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1167 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1169 _LIBCPP_INLINE_VISIBILITY
1170 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1172 _LIBCPP_INLINE_VISIBILITY
1173 size_t size() const {return __a0_.size();}
1178 template <class _Tp>
1179 class _LIBCPP_TEMPLATE_VIS slice_array
1182 typedef _Tp value_type;
1190 template <class _Expr>
1193 __is_val_expr<_Expr>::value,
1196 _LIBCPP_INLINE_VISIBILITY
1197 operator=(const _Expr& __v) const;
1199 template <class _Expr>
1202 __is_val_expr<_Expr>::value,
1205 _LIBCPP_INLINE_VISIBILITY
1206 operator*=(const _Expr& __v) const;
1208 template <class _Expr>
1211 __is_val_expr<_Expr>::value,
1214 _LIBCPP_INLINE_VISIBILITY
1215 operator/=(const _Expr& __v) const;
1217 template <class _Expr>
1220 __is_val_expr<_Expr>::value,
1223 _LIBCPP_INLINE_VISIBILITY
1224 operator%=(const _Expr& __v) const;
1226 template <class _Expr>
1229 __is_val_expr<_Expr>::value,
1232 _LIBCPP_INLINE_VISIBILITY
1233 operator+=(const _Expr& __v) const;
1235 template <class _Expr>
1238 __is_val_expr<_Expr>::value,
1241 _LIBCPP_INLINE_VISIBILITY
1242 operator-=(const _Expr& __v) const;
1244 template <class _Expr>
1247 __is_val_expr<_Expr>::value,
1250 _LIBCPP_INLINE_VISIBILITY
1251 operator^=(const _Expr& __v) const;
1253 template <class _Expr>
1256 __is_val_expr<_Expr>::value,
1259 _LIBCPP_INLINE_VISIBILITY
1260 operator&=(const _Expr& __v) const;
1262 template <class _Expr>
1265 __is_val_expr<_Expr>::value,
1268 _LIBCPP_INLINE_VISIBILITY
1269 operator|=(const _Expr& __v) const;
1271 template <class _Expr>
1274 __is_val_expr<_Expr>::value,
1277 _LIBCPP_INLINE_VISIBILITY
1278 operator<<=(const _Expr& __v) const;
1280 template <class _Expr>
1283 __is_val_expr<_Expr>::value,
1286 _LIBCPP_INLINE_VISIBILITY
1287 operator>>=(const _Expr& __v) const;
1289 slice_array(slice_array const&) = default;
1291 _LIBCPP_INLINE_VISIBILITY
1292 const slice_array& operator=(const slice_array& __sa) const;
1294 _LIBCPP_INLINE_VISIBILITY
1295 void operator=(const value_type& __x) const;
1297 _LIBCPP_INLINE_VISIBILITY
1298 void operator=(const valarray<value_type>& __va) const;
1301 _LIBCPP_INLINE_VISIBILITY
1302 slice_array(const slice& __sl, const valarray<value_type>& __v)
1303 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1304 __size_(__sl.size()),
1305 __stride_(__sl.stride())
1308 template <class> friend class valarray;
1309 template <class> friend class sliceExpr;
1312 template <class _Tp>
1314 const slice_array<_Tp>&
1315 slice_array<_Tp>::operator=(const slice_array& __sa) const
1317 value_type* __t = __vp_;
1318 const value_type* __s = __sa.__vp_;
1319 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1324 template <class _Tp>
1325 template <class _Expr>
1329 __is_val_expr<_Expr>::value,
1332 slice_array<_Tp>::operator=(const _Expr& __v) const
1334 value_type* __t = __vp_;
1335 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1339 template <class _Tp>
1341 slice_array<_Tp>::operator=(const valarray<value_type>& __va) const
1343 value_type* __t = __vp_;
1344 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_)
1348 template <class _Tp>
1349 template <class _Expr>
1353 __is_val_expr<_Expr>::value,
1356 slice_array<_Tp>::operator*=(const _Expr& __v) const
1358 value_type* __t = __vp_;
1359 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1363 template <class _Tp>
1364 template <class _Expr>
1368 __is_val_expr<_Expr>::value,
1371 slice_array<_Tp>::operator/=(const _Expr& __v) const
1373 value_type* __t = __vp_;
1374 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1378 template <class _Tp>
1379 template <class _Expr>
1383 __is_val_expr<_Expr>::value,
1386 slice_array<_Tp>::operator%=(const _Expr& __v) const
1388 value_type* __t = __vp_;
1389 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1393 template <class _Tp>
1394 template <class _Expr>
1398 __is_val_expr<_Expr>::value,
1401 slice_array<_Tp>::operator+=(const _Expr& __v) const
1403 value_type* __t = __vp_;
1404 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1408 template <class _Tp>
1409 template <class _Expr>
1413 __is_val_expr<_Expr>::value,
1416 slice_array<_Tp>::operator-=(const _Expr& __v) const
1418 value_type* __t = __vp_;
1419 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1423 template <class _Tp>
1424 template <class _Expr>
1428 __is_val_expr<_Expr>::value,
1431 slice_array<_Tp>::operator^=(const _Expr& __v) const
1433 value_type* __t = __vp_;
1434 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1438 template <class _Tp>
1439 template <class _Expr>
1443 __is_val_expr<_Expr>::value,
1446 slice_array<_Tp>::operator&=(const _Expr& __v) const
1448 value_type* __t = __vp_;
1449 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1453 template <class _Tp>
1454 template <class _Expr>
1458 __is_val_expr<_Expr>::value,
1461 slice_array<_Tp>::operator|=(const _Expr& __v) const
1463 value_type* __t = __vp_;
1464 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1468 template <class _Tp>
1469 template <class _Expr>
1473 __is_val_expr<_Expr>::value,
1476 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1478 value_type* __t = __vp_;
1479 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1483 template <class _Tp>
1484 template <class _Expr>
1488 __is_val_expr<_Expr>::value,
1491 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1493 value_type* __t = __vp_;
1494 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1498 template <class _Tp>
1501 slice_array<_Tp>::operator=(const value_type& __x) const
1503 value_type* __t = __vp_;
1504 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1510 class _LIBCPP_TYPE_VIS gslice
1512 valarray<size_t> __size_;
1513 valarray<size_t> __stride_;
1514 valarray<size_t> __1d_;
1517 _LIBCPP_INLINE_VISIBILITY
1520 _LIBCPP_INLINE_VISIBILITY
1521 gslice(size_t __start, const valarray<size_t>& __size,
1522 const valarray<size_t>& __stride)
1527 #ifndef _LIBCPP_CXX03_LANG
1529 _LIBCPP_INLINE_VISIBILITY
1530 gslice(size_t __start, const valarray<size_t>& __size,
1531 valarray<size_t>&& __stride)
1533 __stride_(move(__stride))
1536 _LIBCPP_INLINE_VISIBILITY
1537 gslice(size_t __start, valarray<size_t>&& __size,
1538 const valarray<size_t>& __stride)
1539 : __size_(move(__size)),
1543 _LIBCPP_INLINE_VISIBILITY
1544 gslice(size_t __start, valarray<size_t>&& __size,
1545 valarray<size_t>&& __stride)
1546 : __size_(move(__size)),
1547 __stride_(move(__stride))
1550 #endif // _LIBCPP_CXX03_LANG
1552 _LIBCPP_INLINE_VISIBILITY
1553 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1555 _LIBCPP_INLINE_VISIBILITY
1556 valarray<size_t> size() const {return __size_;}
1558 _LIBCPP_INLINE_VISIBILITY
1559 valarray<size_t> stride() const {return __stride_;}
1562 void __init(size_t __start);
1564 template <class> friend class gslice_array;
1565 template <class> friend class valarray;
1566 template <class> friend class __val_expr;
1571 template <class _Tp>
1572 class _LIBCPP_TEMPLATE_VIS gslice_array
1575 typedef _Tp value_type;
1579 valarray<size_t> __1d_;
1582 template <class _Expr>
1585 __is_val_expr<_Expr>::value,
1588 _LIBCPP_INLINE_VISIBILITY
1589 operator=(const _Expr& __v) const;
1591 template <class _Expr>
1594 __is_val_expr<_Expr>::value,
1597 _LIBCPP_INLINE_VISIBILITY
1598 operator*=(const _Expr& __v) const;
1600 template <class _Expr>
1603 __is_val_expr<_Expr>::value,
1606 _LIBCPP_INLINE_VISIBILITY
1607 operator/=(const _Expr& __v) const;
1609 template <class _Expr>
1612 __is_val_expr<_Expr>::value,
1615 _LIBCPP_INLINE_VISIBILITY
1616 operator%=(const _Expr& __v) const;
1618 template <class _Expr>
1621 __is_val_expr<_Expr>::value,
1624 _LIBCPP_INLINE_VISIBILITY
1625 operator+=(const _Expr& __v) const;
1627 template <class _Expr>
1630 __is_val_expr<_Expr>::value,
1633 _LIBCPP_INLINE_VISIBILITY
1634 operator-=(const _Expr& __v) const;
1636 template <class _Expr>
1639 __is_val_expr<_Expr>::value,
1642 _LIBCPP_INLINE_VISIBILITY
1643 operator^=(const _Expr& __v) const;
1645 template <class _Expr>
1648 __is_val_expr<_Expr>::value,
1651 _LIBCPP_INLINE_VISIBILITY
1652 operator&=(const _Expr& __v) const;
1654 template <class _Expr>
1657 __is_val_expr<_Expr>::value,
1660 _LIBCPP_INLINE_VISIBILITY
1661 operator|=(const _Expr& __v) const;
1663 template <class _Expr>
1666 __is_val_expr<_Expr>::value,
1669 _LIBCPP_INLINE_VISIBILITY
1670 operator<<=(const _Expr& __v) const;
1672 template <class _Expr>
1675 __is_val_expr<_Expr>::value,
1678 _LIBCPP_INLINE_VISIBILITY
1679 operator>>=(const _Expr& __v) const;
1681 _LIBCPP_INLINE_VISIBILITY
1682 const gslice_array& operator=(const gslice_array& __ga) const;
1684 _LIBCPP_INLINE_VISIBILITY
1685 void operator=(const value_type& __x) const;
1687 gslice_array(const gslice_array&) = default;
1690 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1691 : __vp_(const_cast<value_type*>(__v.__begin_)),
1695 #ifndef _LIBCPP_CXX03_LANG
1696 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1697 : __vp_(const_cast<value_type*>(__v.__begin_)),
1698 __1d_(move(__gs.__1d_))
1700 #endif // _LIBCPP_CXX03_LANG
1702 template <class> friend class valarray;
1705 template <class _Tp>
1706 template <class _Expr>
1710 __is_val_expr<_Expr>::value,
1713 gslice_array<_Tp>::operator=(const _Expr& __v) const
1715 typedef const size_t* _Ip;
1717 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1718 __vp_[*__i] = __v[__j];
1721 template <class _Tp>
1722 template <class _Expr>
1726 __is_val_expr<_Expr>::value,
1729 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1731 typedef const size_t* _Ip;
1733 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1734 __vp_[*__i] *= __v[__j];
1737 template <class _Tp>
1738 template <class _Expr>
1742 __is_val_expr<_Expr>::value,
1745 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1747 typedef const size_t* _Ip;
1749 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1750 __vp_[*__i] /= __v[__j];
1753 template <class _Tp>
1754 template <class _Expr>
1758 __is_val_expr<_Expr>::value,
1761 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1763 typedef const size_t* _Ip;
1765 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1766 __vp_[*__i] %= __v[__j];
1769 template <class _Tp>
1770 template <class _Expr>
1774 __is_val_expr<_Expr>::value,
1777 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1779 typedef const size_t* _Ip;
1781 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1782 __vp_[*__i] += __v[__j];
1785 template <class _Tp>
1786 template <class _Expr>
1790 __is_val_expr<_Expr>::value,
1793 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1795 typedef const size_t* _Ip;
1797 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1798 __vp_[*__i] -= __v[__j];
1801 template <class _Tp>
1802 template <class _Expr>
1806 __is_val_expr<_Expr>::value,
1809 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1811 typedef const size_t* _Ip;
1813 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1814 __vp_[*__i] ^= __v[__j];
1817 template <class _Tp>
1818 template <class _Expr>
1822 __is_val_expr<_Expr>::value,
1825 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1827 typedef const size_t* _Ip;
1829 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1830 __vp_[*__i] &= __v[__j];
1833 template <class _Tp>
1834 template <class _Expr>
1838 __is_val_expr<_Expr>::value,
1841 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1843 typedef const size_t* _Ip;
1845 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1846 __vp_[*__i] |= __v[__j];
1849 template <class _Tp>
1850 template <class _Expr>
1854 __is_val_expr<_Expr>::value,
1857 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1859 typedef const size_t* _Ip;
1861 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1862 __vp_[*__i] <<= __v[__j];
1865 template <class _Tp>
1866 template <class _Expr>
1870 __is_val_expr<_Expr>::value,
1873 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1875 typedef const size_t* _Ip;
1877 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1878 __vp_[*__i] >>= __v[__j];
1881 template <class _Tp>
1883 const gslice_array<_Tp>&
1884 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1886 typedef const size_t* _Ip;
1887 const value_type* __s = __ga.__vp_;
1888 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1889 __i != __e; ++__i, ++__j)
1890 __vp_[*__i] = __s[*__j];
1894 template <class _Tp>
1897 gslice_array<_Tp>::operator=(const value_type& __x) const
1899 typedef const size_t* _Ip;
1900 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1906 template <class _Tp>
1907 class _LIBCPP_TEMPLATE_VIS mask_array
1910 typedef _Tp value_type;
1914 valarray<size_t> __1d_;
1917 template <class _Expr>
1920 __is_val_expr<_Expr>::value,
1923 _LIBCPP_INLINE_VISIBILITY
1924 operator=(const _Expr& __v) const;
1926 template <class _Expr>
1929 __is_val_expr<_Expr>::value,
1932 _LIBCPP_INLINE_VISIBILITY
1933 operator*=(const _Expr& __v) const;
1935 template <class _Expr>
1938 __is_val_expr<_Expr>::value,
1941 _LIBCPP_INLINE_VISIBILITY
1942 operator/=(const _Expr& __v) const;
1944 template <class _Expr>
1947 __is_val_expr<_Expr>::value,
1950 _LIBCPP_INLINE_VISIBILITY
1951 operator%=(const _Expr& __v) const;
1953 template <class _Expr>
1956 __is_val_expr<_Expr>::value,
1959 _LIBCPP_INLINE_VISIBILITY
1960 operator+=(const _Expr& __v) const;
1962 template <class _Expr>
1965 __is_val_expr<_Expr>::value,
1968 _LIBCPP_INLINE_VISIBILITY
1969 operator-=(const _Expr& __v) const;
1971 template <class _Expr>
1974 __is_val_expr<_Expr>::value,
1977 _LIBCPP_INLINE_VISIBILITY
1978 operator^=(const _Expr& __v) const;
1980 template <class _Expr>
1983 __is_val_expr<_Expr>::value,
1986 _LIBCPP_INLINE_VISIBILITY
1987 operator&=(const _Expr& __v) const;
1989 template <class _Expr>
1992 __is_val_expr<_Expr>::value,
1995 _LIBCPP_INLINE_VISIBILITY
1996 operator|=(const _Expr& __v) const;
1998 template <class _Expr>
2001 __is_val_expr<_Expr>::value,
2004 _LIBCPP_INLINE_VISIBILITY
2005 operator<<=(const _Expr& __v) const;
2007 template <class _Expr>
2010 __is_val_expr<_Expr>::value,
2013 _LIBCPP_INLINE_VISIBILITY
2014 operator>>=(const _Expr& __v) const;
2016 mask_array(const mask_array&) = default;
2018 _LIBCPP_INLINE_VISIBILITY
2019 const mask_array& operator=(const mask_array& __ma) const;
2021 _LIBCPP_INLINE_VISIBILITY
2022 void operator=(const value_type& __x) const;
2025 _LIBCPP_INLINE_VISIBILITY
2026 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
2027 : __vp_(const_cast<value_type*>(__v.__begin_)),
2028 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2031 for (size_t __i = 0; __i < __vb.size(); ++__i)
2036 template <class> friend class valarray;
2039 template <class _Tp>
2040 template <class _Expr>
2044 __is_val_expr<_Expr>::value,
2047 mask_array<_Tp>::operator=(const _Expr& __v) const
2049 size_t __n = __1d_.size();
2050 for (size_t __i = 0; __i < __n; ++__i)
2051 __vp_[__1d_[__i]] = __v[__i];
2054 template <class _Tp>
2055 template <class _Expr>
2059 __is_val_expr<_Expr>::value,
2062 mask_array<_Tp>::operator*=(const _Expr& __v) const
2064 size_t __n = __1d_.size();
2065 for (size_t __i = 0; __i < __n; ++__i)
2066 __vp_[__1d_[__i]] *= __v[__i];
2069 template <class _Tp>
2070 template <class _Expr>
2074 __is_val_expr<_Expr>::value,
2077 mask_array<_Tp>::operator/=(const _Expr& __v) const
2079 size_t __n = __1d_.size();
2080 for (size_t __i = 0; __i < __n; ++__i)
2081 __vp_[__1d_[__i]] /= __v[__i];
2084 template <class _Tp>
2085 template <class _Expr>
2089 __is_val_expr<_Expr>::value,
2092 mask_array<_Tp>::operator%=(const _Expr& __v) const
2094 size_t __n = __1d_.size();
2095 for (size_t __i = 0; __i < __n; ++__i)
2096 __vp_[__1d_[__i]] %= __v[__i];
2099 template <class _Tp>
2100 template <class _Expr>
2104 __is_val_expr<_Expr>::value,
2107 mask_array<_Tp>::operator+=(const _Expr& __v) const
2109 size_t __n = __1d_.size();
2110 for (size_t __i = 0; __i < __n; ++__i)
2111 __vp_[__1d_[__i]] += __v[__i];
2114 template <class _Tp>
2115 template <class _Expr>
2119 __is_val_expr<_Expr>::value,
2122 mask_array<_Tp>::operator-=(const _Expr& __v) const
2124 size_t __n = __1d_.size();
2125 for (size_t __i = 0; __i < __n; ++__i)
2126 __vp_[__1d_[__i]] -= __v[__i];
2129 template <class _Tp>
2130 template <class _Expr>
2134 __is_val_expr<_Expr>::value,
2137 mask_array<_Tp>::operator^=(const _Expr& __v) const
2139 size_t __n = __1d_.size();
2140 for (size_t __i = 0; __i < __n; ++__i)
2141 __vp_[__1d_[__i]] ^= __v[__i];
2144 template <class _Tp>
2145 template <class _Expr>
2149 __is_val_expr<_Expr>::value,
2152 mask_array<_Tp>::operator&=(const _Expr& __v) const
2154 size_t __n = __1d_.size();
2155 for (size_t __i = 0; __i < __n; ++__i)
2156 __vp_[__1d_[__i]] &= __v[__i];
2159 template <class _Tp>
2160 template <class _Expr>
2164 __is_val_expr<_Expr>::value,
2167 mask_array<_Tp>::operator|=(const _Expr& __v) const
2169 size_t __n = __1d_.size();
2170 for (size_t __i = 0; __i < __n; ++__i)
2171 __vp_[__1d_[__i]] |= __v[__i];
2174 template <class _Tp>
2175 template <class _Expr>
2179 __is_val_expr<_Expr>::value,
2182 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2184 size_t __n = __1d_.size();
2185 for (size_t __i = 0; __i < __n; ++__i)
2186 __vp_[__1d_[__i]] <<= __v[__i];
2189 template <class _Tp>
2190 template <class _Expr>
2194 __is_val_expr<_Expr>::value,
2197 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2199 size_t __n = __1d_.size();
2200 for (size_t __i = 0; __i < __n; ++__i)
2201 __vp_[__1d_[__i]] >>= __v[__i];
2204 template <class _Tp>
2206 const mask_array<_Tp>&
2207 mask_array<_Tp>::operator=(const mask_array& __ma) const
2209 size_t __n = __1d_.size();
2210 for (size_t __i = 0; __i < __n; ++__i)
2211 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2215 template <class _Tp>
2218 mask_array<_Tp>::operator=(const value_type& __x) const
2220 size_t __n = __1d_.size();
2221 for (size_t __i = 0; __i < __n; ++__i)
2222 __vp_[__1d_[__i]] = __x;
2225 template <class _ValExpr>
2228 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2230 typedef typename _RmExpr::value_type value_type;
2231 typedef value_type __result_type;
2235 valarray<size_t> __1d_;
2237 _LIBCPP_INLINE_VISIBILITY
2238 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2240 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2243 for (size_t __i = 0; __i < __vb.size(); ++__i)
2249 _LIBCPP_INLINE_VISIBILITY
2250 __result_type operator[](size_t __i) const
2251 {return __expr_[__1d_[__i]];}
2253 _LIBCPP_INLINE_VISIBILITY
2254 size_t size() const {return __1d_.size();}
2256 template <class> friend class __val_expr;
2257 template <class> friend class valarray;
2262 template <class _Tp>
2263 class _LIBCPP_TEMPLATE_VIS indirect_array
2266 typedef _Tp value_type;
2270 valarray<size_t> __1d_;
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 template <class _Expr>
2339 __is_val_expr<_Expr>::value,
2342 _LIBCPP_INLINE_VISIBILITY
2343 operator&=(const _Expr& __v) const;
2345 template <class _Expr>
2348 __is_val_expr<_Expr>::value,
2351 _LIBCPP_INLINE_VISIBILITY
2352 operator|=(const _Expr& __v) const;
2354 template <class _Expr>
2357 __is_val_expr<_Expr>::value,
2360 _LIBCPP_INLINE_VISIBILITY
2361 operator<<=(const _Expr& __v) const;
2363 template <class _Expr>
2366 __is_val_expr<_Expr>::value,
2369 _LIBCPP_INLINE_VISIBILITY
2370 operator>>=(const _Expr& __v) const;
2372 indirect_array(const indirect_array&) = default;
2374 _LIBCPP_INLINE_VISIBILITY
2375 const indirect_array& operator=(const indirect_array& __ia) const;
2377 _LIBCPP_INLINE_VISIBILITY
2378 void operator=(const value_type& __x) const;
2381 _LIBCPP_INLINE_VISIBILITY
2382 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2383 : __vp_(const_cast<value_type*>(__v.__begin_)),
2387 #ifndef _LIBCPP_CXX03_LANG
2389 _LIBCPP_INLINE_VISIBILITY
2390 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2391 : __vp_(const_cast<value_type*>(__v.__begin_)),
2395 #endif // _LIBCPP_CXX03_LANG
2397 template <class> friend class valarray;
2400 template <class _Tp>
2401 template <class _Expr>
2405 __is_val_expr<_Expr>::value,
2408 indirect_array<_Tp>::operator=(const _Expr& __v) const
2410 size_t __n = __1d_.size();
2411 for (size_t __i = 0; __i < __n; ++__i)
2412 __vp_[__1d_[__i]] = __v[__i];
2415 template <class _Tp>
2416 template <class _Expr>
2420 __is_val_expr<_Expr>::value,
2423 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2425 size_t __n = __1d_.size();
2426 for (size_t __i = 0; __i < __n; ++__i)
2427 __vp_[__1d_[__i]] *= __v[__i];
2430 template <class _Tp>
2431 template <class _Expr>
2435 __is_val_expr<_Expr>::value,
2438 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2440 size_t __n = __1d_.size();
2441 for (size_t __i = 0; __i < __n; ++__i)
2442 __vp_[__1d_[__i]] /= __v[__i];
2445 template <class _Tp>
2446 template <class _Expr>
2450 __is_val_expr<_Expr>::value,
2453 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2455 size_t __n = __1d_.size();
2456 for (size_t __i = 0; __i < __n; ++__i)
2457 __vp_[__1d_[__i]] %= __v[__i];
2460 template <class _Tp>
2461 template <class _Expr>
2465 __is_val_expr<_Expr>::value,
2468 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2470 size_t __n = __1d_.size();
2471 for (size_t __i = 0; __i < __n; ++__i)
2472 __vp_[__1d_[__i]] += __v[__i];
2475 template <class _Tp>
2476 template <class _Expr>
2480 __is_val_expr<_Expr>::value,
2483 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2485 size_t __n = __1d_.size();
2486 for (size_t __i = 0; __i < __n; ++__i)
2487 __vp_[__1d_[__i]] -= __v[__i];
2490 template <class _Tp>
2491 template <class _Expr>
2495 __is_val_expr<_Expr>::value,
2498 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2500 size_t __n = __1d_.size();
2501 for (size_t __i = 0; __i < __n; ++__i)
2502 __vp_[__1d_[__i]] ^= __v[__i];
2505 template <class _Tp>
2506 template <class _Expr>
2510 __is_val_expr<_Expr>::value,
2513 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2515 size_t __n = __1d_.size();
2516 for (size_t __i = 0; __i < __n; ++__i)
2517 __vp_[__1d_[__i]] &= __v[__i];
2520 template <class _Tp>
2521 template <class _Expr>
2525 __is_val_expr<_Expr>::value,
2528 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2530 size_t __n = __1d_.size();
2531 for (size_t __i = 0; __i < __n; ++__i)
2532 __vp_[__1d_[__i]] |= __v[__i];
2535 template <class _Tp>
2536 template <class _Expr>
2540 __is_val_expr<_Expr>::value,
2543 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2545 size_t __n = __1d_.size();
2546 for (size_t __i = 0; __i < __n; ++__i)
2547 __vp_[__1d_[__i]] <<= __v[__i];
2550 template <class _Tp>
2551 template <class _Expr>
2555 __is_val_expr<_Expr>::value,
2558 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2560 size_t __n = __1d_.size();
2561 for (size_t __i = 0; __i < __n; ++__i)
2562 __vp_[__1d_[__i]] >>= __v[__i];
2565 template <class _Tp>
2567 const indirect_array<_Tp>&
2568 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2570 typedef const size_t* _Ip;
2571 const value_type* __s = __ia.__vp_;
2572 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2573 __i != __e; ++__i, ++__j)
2574 __vp_[*__i] = __s[*__j];
2578 template <class _Tp>
2581 indirect_array<_Tp>::operator=(const value_type& __x) const
2583 typedef const size_t* _Ip;
2584 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2588 template <class _ValExpr>
2589 class __indirect_expr
2591 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2593 typedef typename _RmExpr::value_type value_type;
2594 typedef value_type __result_type;
2598 valarray<size_t> __1d_;
2600 _LIBCPP_INLINE_VISIBILITY
2601 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2606 #ifndef _LIBCPP_CXX03_LANG
2608 _LIBCPP_INLINE_VISIBILITY
2609 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2614 #endif // _LIBCPP_CXX03_LANG
2617 _LIBCPP_INLINE_VISIBILITY
2618 __result_type operator[](size_t __i) const
2619 {return __expr_[__1d_[__i]];}
2621 _LIBCPP_INLINE_VISIBILITY
2622 size_t size() const {return __1d_.size();}
2624 template <class> friend class __val_expr;
2625 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
2628 template<class _ValExpr>
2631 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2635 typedef typename _RmExpr::value_type value_type;
2636 typedef typename _RmExpr::__result_type __result_type;
2638 _LIBCPP_INLINE_VISIBILITY
2639 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2641 _LIBCPP_INLINE_VISIBILITY
2642 __result_type operator[](size_t __i) const
2643 {return __expr_[__i];}
2645 _LIBCPP_INLINE_VISIBILITY
2646 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2648 typedef __slice_expr<_ValExpr> _NewExpr;
2649 return __val_expr< _NewExpr >(_NewExpr(__s, __expr_));
2652 _LIBCPP_INLINE_VISIBILITY
2653 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2655 typedef __indirect_expr<_ValExpr> _NewExpr;
2656 return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_));
2659 _LIBCPP_INLINE_VISIBILITY
2660 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2662 typedef __mask_expr<_ValExpr> _NewExpr;
2663 return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_));
2666 _LIBCPP_INLINE_VISIBILITY
2667 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2669 typedef __indirect_expr<_ValExpr> _NewExpr;
2670 return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_));
2673 _LIBCPP_INLINE_VISIBILITY
2674 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2677 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2678 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2681 _LIBCPP_INLINE_VISIBILITY
2682 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2685 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2686 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2689 _LIBCPP_INLINE_VISIBILITY
2690 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2693 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2694 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2697 _LIBCPP_INLINE_VISIBILITY
2698 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2701 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2702 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2705 operator valarray<__result_type>() const;
2707 _LIBCPP_INLINE_VISIBILITY
2708 size_t size() const {return __expr_.size();}
2710 _LIBCPP_INLINE_VISIBILITY
2711 __result_type sum() const
2713 size_t __n = __expr_.size();
2714 __result_type __r = __n ? __expr_[0] : __result_type();
2715 for (size_t __i = 1; __i < __n; ++__i)
2716 __r += __expr_[__i];
2720 _LIBCPP_INLINE_VISIBILITY
2721 __result_type min() const
2723 size_t __n = size();
2724 __result_type __r = __n ? (*this)[0] : __result_type();
2725 for (size_t __i = 1; __i < __n; ++__i)
2727 __result_type __x = __expr_[__i];
2734 _LIBCPP_INLINE_VISIBILITY
2735 __result_type max() const
2737 size_t __n = size();
2738 __result_type __r = __n ? (*this)[0] : __result_type();
2739 for (size_t __i = 1; __i < __n; ++__i)
2741 __result_type __x = __expr_[__i];
2748 _LIBCPP_INLINE_VISIBILITY
2749 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2750 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2752 _LIBCPP_INLINE_VISIBILITY
2753 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2754 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2756 _LIBCPP_INLINE_VISIBILITY
2757 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2758 apply(value_type __f(value_type)) const
2760 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2761 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2762 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2765 _LIBCPP_INLINE_VISIBILITY
2766 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2767 apply(value_type __f(const value_type&)) const
2769 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2770 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2771 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2775 template<class _ValExpr>
2776 __val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const
2778 valarray<__result_type> __r;
2779 size_t __n = __expr_.size();
2783 __r.__end_ = allocator<__result_type>().allocate(__n);
2784 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2785 ::new ((void*)__r.__end_) __result_type(__expr_[__i]);
2792 template <class _Tp>
2794 valarray<_Tp>::valarray(size_t __n)
2795 : __begin_(nullptr),
2800 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2801 #ifndef _LIBCPP_NO_EXCEPTIONS
2804 #endif // _LIBCPP_NO_EXCEPTIONS
2805 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
2806 ::new ((void*)__end_) value_type();
2807 #ifndef _LIBCPP_NO_EXCEPTIONS
2814 #endif // _LIBCPP_NO_EXCEPTIONS
2818 template <class _Tp>
2820 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2821 : __begin_(nullptr),
2827 template <class _Tp>
2828 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2829 : __begin_(nullptr),
2834 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2835 #ifndef _LIBCPP_NO_EXCEPTIONS
2838 #endif // _LIBCPP_NO_EXCEPTIONS
2839 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left)
2840 ::new ((void*)__end_) value_type(*__p);
2841 #ifndef _LIBCPP_NO_EXCEPTIONS
2848 #endif // _LIBCPP_NO_EXCEPTIONS
2852 template <class _Tp>
2853 valarray<_Tp>::valarray(const valarray& __v)
2854 : __begin_(nullptr),
2859 __begin_ = __end_ = allocator<value_type>().allocate(__v.size());
2860 #ifndef _LIBCPP_NO_EXCEPTIONS
2863 #endif // _LIBCPP_NO_EXCEPTIONS
2864 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2865 ::new ((void*)__end_) value_type(*__p);
2866 #ifndef _LIBCPP_NO_EXCEPTIONS
2870 __clear(__v.size());
2873 #endif // _LIBCPP_NO_EXCEPTIONS
2877 #ifndef _LIBCPP_CXX03_LANG
2879 template <class _Tp>
2881 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2882 : __begin_(__v.__begin_),
2885 __v.__begin_ = __v.__end_ = nullptr;
2888 template <class _Tp>
2889 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2890 : __begin_(nullptr),
2893 const size_t __n = __il.size();
2896 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2897 #ifndef _LIBCPP_NO_EXCEPTIONS
2900 #endif // _LIBCPP_NO_EXCEPTIONS
2901 size_t __n_left = __n;
2902 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left)
2903 ::new ((void*)__end_) value_type(*__p);
2904 #ifndef _LIBCPP_NO_EXCEPTIONS
2911 #endif // _LIBCPP_NO_EXCEPTIONS
2915 #endif // _LIBCPP_CXX03_LANG
2917 template <class _Tp>
2918 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2919 : __begin_(nullptr),
2922 const size_t __n = __sa.__size_;
2925 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2926 #ifndef _LIBCPP_NO_EXCEPTIONS
2929 #endif // _LIBCPP_NO_EXCEPTIONS
2930 size_t __n_left = __n;
2931 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left)
2932 ::new ((void*)__end_) value_type(*__p);
2933 #ifndef _LIBCPP_NO_EXCEPTIONS
2940 #endif // _LIBCPP_NO_EXCEPTIONS
2944 template <class _Tp>
2945 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2946 : __begin_(nullptr),
2949 const size_t __n = __ga.__1d_.size();
2952 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2953 #ifndef _LIBCPP_NO_EXCEPTIONS
2956 #endif // _LIBCPP_NO_EXCEPTIONS
2957 typedef const size_t* _Ip;
2958 const value_type* __s = __ga.__vp_;
2959 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2960 __i != __e; ++__i, ++__end_)
2961 ::new ((void*)__end_) value_type(__s[*__i]);
2962 #ifndef _LIBCPP_NO_EXCEPTIONS
2969 #endif // _LIBCPP_NO_EXCEPTIONS
2973 template <class _Tp>
2974 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2975 : __begin_(nullptr),
2978 const size_t __n = __ma.__1d_.size();
2981 __begin_ = __end_ = allocator<value_type>().allocate(__n);
2982 #ifndef _LIBCPP_NO_EXCEPTIONS
2985 #endif // _LIBCPP_NO_EXCEPTIONS
2986 typedef const size_t* _Ip;
2987 const value_type* __s = __ma.__vp_;
2988 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2989 __i != __e; ++__i, ++__end_)
2990 ::new ((void*)__end_) value_type(__s[*__i]);
2991 #ifndef _LIBCPP_NO_EXCEPTIONS
2998 #endif // _LIBCPP_NO_EXCEPTIONS
3002 template <class _Tp>
3003 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
3004 : __begin_(nullptr),
3007 const size_t __n = __ia.__1d_.size();
3010 __begin_ = __end_ = allocator<value_type>().allocate(__n);
3011 #ifndef _LIBCPP_NO_EXCEPTIONS
3014 #endif // _LIBCPP_NO_EXCEPTIONS
3015 typedef const size_t* _Ip;
3016 const value_type* __s = __ia.__vp_;
3017 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3018 __i != __e; ++__i, ++__end_)
3019 ::new ((void*)__end_) value_type(__s[*__i]);
3020 #ifndef _LIBCPP_NO_EXCEPTIONS
3027 #endif // _LIBCPP_NO_EXCEPTIONS
3031 template <class _Tp>
3033 valarray<_Tp>::~valarray()
3038 template <class _Tp>
3040 valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
3042 size_t __n = __l - __f;
3046 __begin_ = allocator<value_type>().allocate(__n);
3047 __end_ = __begin_ + __n;
3048 _VSTD::uninitialized_copy(__f, __l, __begin_);
3050 _VSTD::copy(__f, __l, __begin_);
3055 template <class _Tp>
3057 valarray<_Tp>::operator=(const valarray& __v)
3059 if (this != _VSTD::addressof(__v))
3060 return __assign_range(__v.__begin_, __v.__end_);
3064 #ifndef _LIBCPP_CXX03_LANG
3066 template <class _Tp>
3069 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
3072 __begin_ = __v.__begin_;
3073 __end_ = __v.__end_;
3074 __v.__begin_ = nullptr;
3075 __v.__end_ = nullptr;
3079 template <class _Tp>
3082 valarray<_Tp>::operator=(initializer_list<value_type> __il)
3084 return __assign_range(__il.begin(), __il.end());
3087 #endif // _LIBCPP_CXX03_LANG
3089 template <class _Tp>
3092 valarray<_Tp>::operator=(const value_type& __x)
3094 _VSTD::fill(__begin_, __end_, __x);
3098 template <class _Tp>
3101 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3103 value_type* __t = __begin_;
3104 const value_type* __s = __sa.__vp_;
3105 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3110 template <class _Tp>
3113 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3115 typedef const size_t* _Ip;
3116 value_type* __t = __begin_;
3117 const value_type* __s = __ga.__vp_;
3118 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3119 __i != __e; ++__i, ++__t)
3124 template <class _Tp>
3127 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3129 typedef const size_t* _Ip;
3130 value_type* __t = __begin_;
3131 const value_type* __s = __ma.__vp_;
3132 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3133 __i != __e; ++__i, ++__t)
3138 template <class _Tp>
3141 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3143 typedef const size_t* _Ip;
3144 value_type* __t = __begin_;
3145 const value_type* __s = __ia.__vp_;
3146 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3147 __i != __e; ++__i, ++__t)
3152 template <class _Tp>
3153 template <class _ValExpr>
3156 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3158 size_t __n = __v.size();
3161 value_type* __t = __begin_;
3162 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3163 *__t = __result_type(__v[__i]);
3167 template <class _Tp>
3169 __val_expr<__slice_expr<const valarray<_Tp>&> >
3170 valarray<_Tp>::operator[](slice __s) const
3172 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3175 template <class _Tp>
3178 valarray<_Tp>::operator[](slice __s)
3180 return slice_array<value_type>(__s, *this);
3183 template <class _Tp>
3185 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3186 valarray<_Tp>::operator[](const gslice& __gs) const
3188 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3191 template <class _Tp>
3194 valarray<_Tp>::operator[](const gslice& __gs)
3196 return gslice_array<value_type>(__gs, *this);
3199 #ifndef _LIBCPP_CXX03_LANG
3201 template <class _Tp>
3203 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3204 valarray<_Tp>::operator[](gslice&& __gs) const
3206 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3209 template <class _Tp>
3212 valarray<_Tp>::operator[](gslice&& __gs)
3214 return gslice_array<value_type>(move(__gs), *this);
3217 #endif // _LIBCPP_CXX03_LANG
3219 template <class _Tp>
3221 __val_expr<__mask_expr<const valarray<_Tp>&> >
3222 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3224 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3227 template <class _Tp>
3230 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3232 return mask_array<value_type>(__vb, *this);
3235 #ifndef _LIBCPP_CXX03_LANG
3237 template <class _Tp>
3239 __val_expr<__mask_expr<const valarray<_Tp>&> >
3240 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3242 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3245 template <class _Tp>
3248 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3250 return mask_array<value_type>(move(__vb), *this);
3253 #endif // _LIBCPP_CXX03_LANG
3255 template <class _Tp>
3257 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3258 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3260 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3263 template <class _Tp>
3266 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3268 return indirect_array<value_type>(__vs, *this);
3271 #ifndef _LIBCPP_CXX03_LANG
3273 template <class _Tp>
3275 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3276 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3278 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3281 template <class _Tp>
3284 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3286 return indirect_array<value_type>(move(__vs), *this);
3289 #endif // _LIBCPP_CXX03_LANG
3291 template <class _Tp>
3293 valarray<_Tp>::operator+() const
3295 valarray<value_type> __r;
3296 size_t __n = size();
3299 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3300 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3301 ::new ((void*)__r.__end_) value_type(+*__p);
3306 template <class _Tp>
3308 valarray<_Tp>::operator-() const
3310 valarray<value_type> __r;
3311 size_t __n = size();
3314 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3315 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3316 ::new ((void*)__r.__end_) value_type(-*__p);
3321 template <class _Tp>
3323 valarray<_Tp>::operator~() const
3325 valarray<value_type> __r;
3326 size_t __n = size();
3329 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3330 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3331 ::new ((void*)__r.__end_) value_type(~*__p);
3336 template <class _Tp>
3338 valarray<_Tp>::operator!() const
3341 size_t __n = size();
3344 __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n);
3345 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3346 ::new ((void*)__r.__end_) bool(!*__p);
3351 template <class _Tp>
3354 valarray<_Tp>::operator*=(const value_type& __x)
3356 for (value_type* __p = __begin_; __p != __end_; ++__p)
3361 template <class _Tp>
3364 valarray<_Tp>::operator/=(const value_type& __x)
3366 for (value_type* __p = __begin_; __p != __end_; ++__p)
3371 template <class _Tp>
3374 valarray<_Tp>::operator%=(const value_type& __x)
3376 for (value_type* __p = __begin_; __p != __end_; ++__p)
3381 template <class _Tp>
3384 valarray<_Tp>::operator+=(const value_type& __x)
3386 for (value_type* __p = __begin_; __p != __end_; ++__p)
3391 template <class _Tp>
3394 valarray<_Tp>::operator-=(const value_type& __x)
3396 for (value_type* __p = __begin_; __p != __end_; ++__p)
3401 template <class _Tp>
3404 valarray<_Tp>::operator^=(const value_type& __x)
3406 for (value_type* __p = __begin_; __p != __end_; ++__p)
3411 template <class _Tp>
3414 valarray<_Tp>::operator&=(const value_type& __x)
3416 for (value_type* __p = __begin_; __p != __end_; ++__p)
3421 template <class _Tp>
3424 valarray<_Tp>::operator|=(const value_type& __x)
3426 for (value_type* __p = __begin_; __p != __end_; ++__p)
3431 template <class _Tp>
3434 valarray<_Tp>::operator<<=(const value_type& __x)
3436 for (value_type* __p = __begin_; __p != __end_; ++__p)
3441 template <class _Tp>
3444 valarray<_Tp>::operator>>=(const value_type& __x)
3446 for (value_type* __p = __begin_; __p != __end_; ++__p)
3451 template <class _Tp>
3452 template <class _Expr>
3456 __is_val_expr<_Expr>::value,
3459 valarray<_Tp>::operator*=(const _Expr& __v)
3462 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3467 template <class _Tp>
3468 template <class _Expr>
3472 __is_val_expr<_Expr>::value,
3475 valarray<_Tp>::operator/=(const _Expr& __v)
3478 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3483 template <class _Tp>
3484 template <class _Expr>
3488 __is_val_expr<_Expr>::value,
3491 valarray<_Tp>::operator%=(const _Expr& __v)
3494 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3499 template <class _Tp>
3500 template <class _Expr>
3504 __is_val_expr<_Expr>::value,
3507 valarray<_Tp>::operator+=(const _Expr& __v)
3510 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3515 template <class _Tp>
3516 template <class _Expr>
3520 __is_val_expr<_Expr>::value,
3523 valarray<_Tp>::operator-=(const _Expr& __v)
3526 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3531 template <class _Tp>
3532 template <class _Expr>
3536 __is_val_expr<_Expr>::value,
3539 valarray<_Tp>::operator^=(const _Expr& __v)
3542 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3547 template <class _Tp>
3548 template <class _Expr>
3552 __is_val_expr<_Expr>::value,
3555 valarray<_Tp>::operator|=(const _Expr& __v)
3558 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3563 template <class _Tp>
3564 template <class _Expr>
3568 __is_val_expr<_Expr>::value,
3571 valarray<_Tp>::operator&=(const _Expr& __v)
3574 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3579 template <class _Tp>
3580 template <class _Expr>
3584 __is_val_expr<_Expr>::value,
3587 valarray<_Tp>::operator<<=(const _Expr& __v)
3590 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3595 template <class _Tp>
3596 template <class _Expr>
3600 __is_val_expr<_Expr>::value,
3603 valarray<_Tp>::operator>>=(const _Expr& __v)
3606 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3611 template <class _Tp>
3614 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3616 _VSTD::swap(__begin_, __v.__begin_);
3617 _VSTD::swap(__end_, __v.__end_);
3620 template <class _Tp>
3623 valarray<_Tp>::sum() const
3625 if (__begin_ == __end_)
3626 return value_type();
3627 const value_type* __p = __begin_;
3629 for (++__p; __p != __end_; ++__p)
3634 template <class _Tp>
3637 valarray<_Tp>::min() const
3639 if (__begin_ == __end_)
3640 return value_type();
3641 return *_VSTD::min_element(__begin_, __end_);
3644 template <class _Tp>
3647 valarray<_Tp>::max() const
3649 if (__begin_ == __end_)
3650 return value_type();
3651 return *_VSTD::max_element(__begin_, __end_);
3654 template <class _Tp>
3656 valarray<_Tp>::shift(int __i) const
3658 valarray<value_type> __r;
3659 size_t __n = size();
3662 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3663 const value_type* __sb;
3668 __i = _VSTD::min(__i, static_cast<int>(__n));
3669 __sb = __begin_ + __i;
3670 __tb = __r.__begin_;
3671 __te = __r.__begin_ + (__n - __i);
3675 __i = _VSTD::min(-__i, static_cast<int>(__n));
3677 __tb = __r.__begin_ + __i;
3678 __te = __r.__begin_ + __n;
3680 for (; __r.__end_ != __tb; ++__r.__end_)
3681 ::new ((void*)__r.__end_) value_type();
3682 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3683 ::new ((void*)__r.__end_) value_type(*__sb);
3684 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3685 ::new ((void*)__r.__end_) value_type();
3690 template <class _Tp>
3692 valarray<_Tp>::cshift(int __i) const
3694 valarray<value_type> __r;
3695 size_t __n = size();
3698 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3699 __i %= static_cast<int>(__n);
3700 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3701 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3702 ::new ((void*)__r.__end_) value_type(*__s);
3703 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3704 ::new ((void*)__r.__end_) value_type(*__s);
3709 template <class _Tp>
3711 valarray<_Tp>::apply(value_type __f(value_type)) const
3713 valarray<value_type> __r;
3714 size_t __n = size();
3717 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3718 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3719 ::new ((void*)__r.__end_) value_type(__f(*__p));
3724 template <class _Tp>
3726 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3728 valarray<value_type> __r;
3729 size_t __n = size();
3732 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n);
3733 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3734 ::new ((void*)__r.__end_) value_type(__f(*__p));
3739 template <class _Tp>
3741 void valarray<_Tp>::__clear(size_t __capacity)
3743 if (__begin_ != nullptr)
3745 while (__end_ != __begin_)
3746 (--__end_)->~value_type();
3747 allocator<value_type>().deallocate(__begin_, __capacity);
3748 __begin_ = __end_ = nullptr;
3752 template <class _Tp>
3754 valarray<_Tp>::resize(size_t __n, value_type __x)
3759 __begin_ = __end_ = allocator<value_type>().allocate(__n);
3760 #ifndef _LIBCPP_NO_EXCEPTIONS
3763 #endif // _LIBCPP_NO_EXCEPTIONS
3764 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_)
3765 ::new ((void*)__end_) value_type(__x);
3766 #ifndef _LIBCPP_NO_EXCEPTIONS
3773 #endif // _LIBCPP_NO_EXCEPTIONS
3778 inline _LIBCPP_INLINE_VISIBILITY
3780 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3785 template<class _Expr1, class _Expr2>
3786 inline _LIBCPP_INLINE_VISIBILITY
3789 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3790 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3792 operator*(const _Expr1& __x, const _Expr2& __y)
3794 typedef typename _Expr1::value_type value_type;
3795 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3796 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3799 template<class _Expr>
3800 inline _LIBCPP_INLINE_VISIBILITY
3803 __is_val_expr<_Expr>::value,
3804 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3805 _Expr, __scalar_expr<typename _Expr::value_type> > >
3807 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3809 typedef typename _Expr::value_type value_type;
3810 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3811 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3812 __x, __scalar_expr<value_type>(__y, __x.size())));
3815 template<class _Expr>
3816 inline _LIBCPP_INLINE_VISIBILITY
3819 __is_val_expr<_Expr>::value,
3820 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3821 __scalar_expr<typename _Expr::value_type>, _Expr> >
3823 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3825 typedef typename _Expr::value_type value_type;
3826 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3827 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3828 __scalar_expr<value_type>(__x, __y.size()), __y));
3831 template<class _Expr1, class _Expr2>
3832 inline _LIBCPP_INLINE_VISIBILITY
3835 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3836 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3838 operator/(const _Expr1& __x, const _Expr2& __y)
3840 typedef typename _Expr1::value_type value_type;
3841 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3842 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3845 template<class _Expr>
3846 inline _LIBCPP_INLINE_VISIBILITY
3849 __is_val_expr<_Expr>::value,
3850 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3851 _Expr, __scalar_expr<typename _Expr::value_type> > >
3853 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3855 typedef typename _Expr::value_type value_type;
3856 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3857 return __val_expr<_Op>(_Op(divides<value_type>(),
3858 __x, __scalar_expr<value_type>(__y, __x.size())));
3861 template<class _Expr>
3862 inline _LIBCPP_INLINE_VISIBILITY
3865 __is_val_expr<_Expr>::value,
3866 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3867 __scalar_expr<typename _Expr::value_type>, _Expr> >
3869 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3871 typedef typename _Expr::value_type value_type;
3872 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3873 return __val_expr<_Op>(_Op(divides<value_type>(),
3874 __scalar_expr<value_type>(__x, __y.size()), __y));
3877 template<class _Expr1, class _Expr2>
3878 inline _LIBCPP_INLINE_VISIBILITY
3881 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3882 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3884 operator%(const _Expr1& __x, const _Expr2& __y)
3886 typedef typename _Expr1::value_type value_type;
3887 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3888 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3891 template<class _Expr>
3892 inline _LIBCPP_INLINE_VISIBILITY
3895 __is_val_expr<_Expr>::value,
3896 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3897 _Expr, __scalar_expr<typename _Expr::value_type> > >
3899 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3901 typedef typename _Expr::value_type value_type;
3902 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3903 return __val_expr<_Op>(_Op(modulus<value_type>(),
3904 __x, __scalar_expr<value_type>(__y, __x.size())));
3907 template<class _Expr>
3908 inline _LIBCPP_INLINE_VISIBILITY
3911 __is_val_expr<_Expr>::value,
3912 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3913 __scalar_expr<typename _Expr::value_type>, _Expr> >
3915 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3917 typedef typename _Expr::value_type value_type;
3918 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3919 return __val_expr<_Op>(_Op(modulus<value_type>(),
3920 __scalar_expr<value_type>(__x, __y.size()), __y));
3923 template<class _Expr1, class _Expr2>
3924 inline _LIBCPP_INLINE_VISIBILITY
3927 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3928 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3930 operator+(const _Expr1& __x, const _Expr2& __y)
3932 typedef typename _Expr1::value_type value_type;
3933 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3934 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3937 template<class _Expr>
3938 inline _LIBCPP_INLINE_VISIBILITY
3941 __is_val_expr<_Expr>::value,
3942 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3943 _Expr, __scalar_expr<typename _Expr::value_type> > >
3945 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3947 typedef typename _Expr::value_type value_type;
3948 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3949 return __val_expr<_Op>(_Op(plus<value_type>(),
3950 __x, __scalar_expr<value_type>(__y, __x.size())));
3953 template<class _Expr>
3954 inline _LIBCPP_INLINE_VISIBILITY
3957 __is_val_expr<_Expr>::value,
3958 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3959 __scalar_expr<typename _Expr::value_type>, _Expr> >
3961 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3963 typedef typename _Expr::value_type value_type;
3964 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3965 return __val_expr<_Op>(_Op(plus<value_type>(),
3966 __scalar_expr<value_type>(__x, __y.size()), __y));
3969 template<class _Expr1, class _Expr2>
3970 inline _LIBCPP_INLINE_VISIBILITY
3973 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3974 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3976 operator-(const _Expr1& __x, const _Expr2& __y)
3978 typedef typename _Expr1::value_type value_type;
3979 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3980 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3983 template<class _Expr>
3984 inline _LIBCPP_INLINE_VISIBILITY
3987 __is_val_expr<_Expr>::value,
3988 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3989 _Expr, __scalar_expr<typename _Expr::value_type> > >
3991 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3993 typedef typename _Expr::value_type value_type;
3994 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3995 return __val_expr<_Op>(_Op(minus<value_type>(),
3996 __x, __scalar_expr<value_type>(__y, __x.size())));
3999 template<class _Expr>
4000 inline _LIBCPP_INLINE_VISIBILITY
4003 __is_val_expr<_Expr>::value,
4004 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
4005 __scalar_expr<typename _Expr::value_type>, _Expr> >
4007 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
4009 typedef typename _Expr::value_type value_type;
4010 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4011 return __val_expr<_Op>(_Op(minus<value_type>(),
4012 __scalar_expr<value_type>(__x, __y.size()), __y));
4015 template<class _Expr1, class _Expr2>
4016 inline _LIBCPP_INLINE_VISIBILITY
4019 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4020 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
4022 operator^(const _Expr1& __x, const _Expr2& __y)
4024 typedef typename _Expr1::value_type value_type;
4025 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
4026 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
4029 template<class _Expr>
4030 inline _LIBCPP_INLINE_VISIBILITY
4033 __is_val_expr<_Expr>::value,
4034 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
4035 _Expr, __scalar_expr<typename _Expr::value_type> > >
4037 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
4039 typedef typename _Expr::value_type value_type;
4040 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4041 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
4042 __x, __scalar_expr<value_type>(__y, __x.size())));
4045 template<class _Expr>
4046 inline _LIBCPP_INLINE_VISIBILITY
4049 __is_val_expr<_Expr>::value,
4050 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
4051 __scalar_expr<typename _Expr::value_type>, _Expr> >
4053 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
4055 typedef typename _Expr::value_type value_type;
4056 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4057 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
4058 __scalar_expr<value_type>(__x, __y.size()), __y));
4061 template<class _Expr1, class _Expr2>
4062 inline _LIBCPP_INLINE_VISIBILITY
4065 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4066 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4068 operator&(const _Expr1& __x, const _Expr2& __y)
4070 typedef typename _Expr1::value_type value_type;
4071 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4072 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4075 template<class _Expr>
4076 inline _LIBCPP_INLINE_VISIBILITY
4079 __is_val_expr<_Expr>::value,
4080 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4081 _Expr, __scalar_expr<typename _Expr::value_type> > >
4083 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4085 typedef typename _Expr::value_type value_type;
4086 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4087 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4088 __x, __scalar_expr<value_type>(__y, __x.size())));
4091 template<class _Expr>
4092 inline _LIBCPP_INLINE_VISIBILITY
4095 __is_val_expr<_Expr>::value,
4096 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4097 __scalar_expr<typename _Expr::value_type>, _Expr> >
4099 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4101 typedef typename _Expr::value_type value_type;
4102 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4103 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4104 __scalar_expr<value_type>(__x, __y.size()), __y));
4107 template<class _Expr1, class _Expr2>
4108 inline _LIBCPP_INLINE_VISIBILITY
4111 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4112 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4114 operator|(const _Expr1& __x, const _Expr2& __y)
4116 typedef typename _Expr1::value_type value_type;
4117 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4118 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4121 template<class _Expr>
4122 inline _LIBCPP_INLINE_VISIBILITY
4125 __is_val_expr<_Expr>::value,
4126 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4127 _Expr, __scalar_expr<typename _Expr::value_type> > >
4129 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4131 typedef typename _Expr::value_type value_type;
4132 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4133 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4134 __x, __scalar_expr<value_type>(__y, __x.size())));
4137 template<class _Expr>
4138 inline _LIBCPP_INLINE_VISIBILITY
4141 __is_val_expr<_Expr>::value,
4142 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4143 __scalar_expr<typename _Expr::value_type>, _Expr> >
4145 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4147 typedef typename _Expr::value_type value_type;
4148 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4149 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4150 __scalar_expr<value_type>(__x, __y.size()), __y));
4153 template<class _Expr1, class _Expr2>
4154 inline _LIBCPP_INLINE_VISIBILITY
4157 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4158 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4160 operator<<(const _Expr1& __x, const _Expr2& __y)
4162 typedef typename _Expr1::value_type value_type;
4163 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4164 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4167 template<class _Expr>
4168 inline _LIBCPP_INLINE_VISIBILITY
4171 __is_val_expr<_Expr>::value,
4172 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4173 _Expr, __scalar_expr<typename _Expr::value_type> > >
4175 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4177 typedef typename _Expr::value_type value_type;
4178 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4179 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4180 __x, __scalar_expr<value_type>(__y, __x.size())));
4183 template<class _Expr>
4184 inline _LIBCPP_INLINE_VISIBILITY
4187 __is_val_expr<_Expr>::value,
4188 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4189 __scalar_expr<typename _Expr::value_type>, _Expr> >
4191 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4193 typedef typename _Expr::value_type value_type;
4194 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4195 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4196 __scalar_expr<value_type>(__x, __y.size()), __y));
4199 template<class _Expr1, class _Expr2>
4200 inline _LIBCPP_INLINE_VISIBILITY
4203 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4204 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4206 operator>>(const _Expr1& __x, const _Expr2& __y)
4208 typedef typename _Expr1::value_type value_type;
4209 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4210 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4213 template<class _Expr>
4214 inline _LIBCPP_INLINE_VISIBILITY
4217 __is_val_expr<_Expr>::value,
4218 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4219 _Expr, __scalar_expr<typename _Expr::value_type> > >
4221 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4223 typedef typename _Expr::value_type value_type;
4224 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4225 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4226 __x, __scalar_expr<value_type>(__y, __x.size())));
4229 template<class _Expr>
4230 inline _LIBCPP_INLINE_VISIBILITY
4233 __is_val_expr<_Expr>::value,
4234 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4235 __scalar_expr<typename _Expr::value_type>, _Expr> >
4237 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4239 typedef typename _Expr::value_type value_type;
4240 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4241 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4242 __scalar_expr<value_type>(__x, __y.size()), __y));
4245 template<class _Expr1, class _Expr2>
4246 inline _LIBCPP_INLINE_VISIBILITY
4249 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4250 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4252 operator&&(const _Expr1& __x, const _Expr2& __y)
4254 typedef typename _Expr1::value_type value_type;
4255 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4256 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4259 template<class _Expr>
4260 inline _LIBCPP_INLINE_VISIBILITY
4263 __is_val_expr<_Expr>::value,
4264 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4265 _Expr, __scalar_expr<typename _Expr::value_type> > >
4267 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4269 typedef typename _Expr::value_type value_type;
4270 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4271 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4272 __x, __scalar_expr<value_type>(__y, __x.size())));
4275 template<class _Expr>
4276 inline _LIBCPP_INLINE_VISIBILITY
4279 __is_val_expr<_Expr>::value,
4280 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4281 __scalar_expr<typename _Expr::value_type>, _Expr> >
4283 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4285 typedef typename _Expr::value_type value_type;
4286 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4287 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4288 __scalar_expr<value_type>(__x, __y.size()), __y));
4291 template<class _Expr1, class _Expr2>
4292 inline _LIBCPP_INLINE_VISIBILITY
4295 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4296 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4298 operator||(const _Expr1& __x, const _Expr2& __y)
4300 typedef typename _Expr1::value_type value_type;
4301 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4302 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4305 template<class _Expr>
4306 inline _LIBCPP_INLINE_VISIBILITY
4309 __is_val_expr<_Expr>::value,
4310 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4311 _Expr, __scalar_expr<typename _Expr::value_type> > >
4313 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4315 typedef typename _Expr::value_type value_type;
4316 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4317 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4318 __x, __scalar_expr<value_type>(__y, __x.size())));
4321 template<class _Expr>
4322 inline _LIBCPP_INLINE_VISIBILITY
4325 __is_val_expr<_Expr>::value,
4326 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4327 __scalar_expr<typename _Expr::value_type>, _Expr> >
4329 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4331 typedef typename _Expr::value_type value_type;
4332 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4333 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4334 __scalar_expr<value_type>(__x, __y.size()), __y));
4337 template<class _Expr1, class _Expr2>
4338 inline _LIBCPP_INLINE_VISIBILITY
4341 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4342 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4344 operator==(const _Expr1& __x, const _Expr2& __y)
4346 typedef typename _Expr1::value_type value_type;
4347 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4348 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4351 template<class _Expr>
4352 inline _LIBCPP_INLINE_VISIBILITY
4355 __is_val_expr<_Expr>::value,
4356 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4357 _Expr, __scalar_expr<typename _Expr::value_type> > >
4359 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4361 typedef typename _Expr::value_type value_type;
4362 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4363 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4364 __x, __scalar_expr<value_type>(__y, __x.size())));
4367 template<class _Expr>
4368 inline _LIBCPP_INLINE_VISIBILITY
4371 __is_val_expr<_Expr>::value,
4372 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4373 __scalar_expr<typename _Expr::value_type>, _Expr> >
4375 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4377 typedef typename _Expr::value_type value_type;
4378 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4379 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4380 __scalar_expr<value_type>(__x, __y.size()), __y));
4383 template<class _Expr1, class _Expr2>
4384 inline _LIBCPP_INLINE_VISIBILITY
4387 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4388 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4390 operator!=(const _Expr1& __x, const _Expr2& __y)
4392 typedef typename _Expr1::value_type value_type;
4393 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4394 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4397 template<class _Expr>
4398 inline _LIBCPP_INLINE_VISIBILITY
4401 __is_val_expr<_Expr>::value,
4402 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4403 _Expr, __scalar_expr<typename _Expr::value_type> > >
4405 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4407 typedef typename _Expr::value_type value_type;
4408 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4409 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4410 __x, __scalar_expr<value_type>(__y, __x.size())));
4413 template<class _Expr>
4414 inline _LIBCPP_INLINE_VISIBILITY
4417 __is_val_expr<_Expr>::value,
4418 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4419 __scalar_expr<typename _Expr::value_type>, _Expr> >
4421 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4423 typedef typename _Expr::value_type value_type;
4424 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4425 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4426 __scalar_expr<value_type>(__x, __y.size()), __y));
4429 template<class _Expr1, class _Expr2>
4430 inline _LIBCPP_INLINE_VISIBILITY
4433 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4434 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4436 operator<(const _Expr1& __x, const _Expr2& __y)
4438 typedef typename _Expr1::value_type value_type;
4439 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4440 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4443 template<class _Expr>
4444 inline _LIBCPP_INLINE_VISIBILITY
4447 __is_val_expr<_Expr>::value,
4448 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4449 _Expr, __scalar_expr<typename _Expr::value_type> > >
4451 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4453 typedef typename _Expr::value_type value_type;
4454 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4455 return __val_expr<_Op>(_Op(less<value_type>(),
4456 __x, __scalar_expr<value_type>(__y, __x.size())));
4459 template<class _Expr>
4460 inline _LIBCPP_INLINE_VISIBILITY
4463 __is_val_expr<_Expr>::value,
4464 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4465 __scalar_expr<typename _Expr::value_type>, _Expr> >
4467 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4469 typedef typename _Expr::value_type value_type;
4470 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4471 return __val_expr<_Op>(_Op(less<value_type>(),
4472 __scalar_expr<value_type>(__x, __y.size()), __y));
4475 template<class _Expr1, class _Expr2>
4476 inline _LIBCPP_INLINE_VISIBILITY
4479 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4480 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4482 operator>(const _Expr1& __x, const _Expr2& __y)
4484 typedef typename _Expr1::value_type value_type;
4485 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4486 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4489 template<class _Expr>
4490 inline _LIBCPP_INLINE_VISIBILITY
4493 __is_val_expr<_Expr>::value,
4494 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4495 _Expr, __scalar_expr<typename _Expr::value_type> > >
4497 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4499 typedef typename _Expr::value_type value_type;
4500 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4501 return __val_expr<_Op>(_Op(greater<value_type>(),
4502 __x, __scalar_expr<value_type>(__y, __x.size())));
4505 template<class _Expr>
4506 inline _LIBCPP_INLINE_VISIBILITY
4509 __is_val_expr<_Expr>::value,
4510 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4511 __scalar_expr<typename _Expr::value_type>, _Expr> >
4513 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4515 typedef typename _Expr::value_type value_type;
4516 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4517 return __val_expr<_Op>(_Op(greater<value_type>(),
4518 __scalar_expr<value_type>(__x, __y.size()), __y));
4521 template<class _Expr1, class _Expr2>
4522 inline _LIBCPP_INLINE_VISIBILITY
4525 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4526 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4528 operator<=(const _Expr1& __x, const _Expr2& __y)
4530 typedef typename _Expr1::value_type value_type;
4531 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4532 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4535 template<class _Expr>
4536 inline _LIBCPP_INLINE_VISIBILITY
4539 __is_val_expr<_Expr>::value,
4540 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4541 _Expr, __scalar_expr<typename _Expr::value_type> > >
4543 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4545 typedef typename _Expr::value_type value_type;
4546 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4547 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4548 __x, __scalar_expr<value_type>(__y, __x.size())));
4551 template<class _Expr>
4552 inline _LIBCPP_INLINE_VISIBILITY
4555 __is_val_expr<_Expr>::value,
4556 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4557 __scalar_expr<typename _Expr::value_type>, _Expr> >
4559 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4561 typedef typename _Expr::value_type value_type;
4562 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4563 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4564 __scalar_expr<value_type>(__x, __y.size()), __y));
4567 template<class _Expr1, class _Expr2>
4568 inline _LIBCPP_INLINE_VISIBILITY
4571 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4572 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4574 operator>=(const _Expr1& __x, const _Expr2& __y)
4576 typedef typename _Expr1::value_type value_type;
4577 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4578 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4581 template<class _Expr>
4582 inline _LIBCPP_INLINE_VISIBILITY
4585 __is_val_expr<_Expr>::value,
4586 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4587 _Expr, __scalar_expr<typename _Expr::value_type> > >
4589 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4591 typedef typename _Expr::value_type value_type;
4592 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4593 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4594 __x, __scalar_expr<value_type>(__y, __x.size())));
4597 template<class _Expr>
4598 inline _LIBCPP_INLINE_VISIBILITY
4601 __is_val_expr<_Expr>::value,
4602 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4603 __scalar_expr<typename _Expr::value_type>, _Expr> >
4605 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4607 typedef typename _Expr::value_type value_type;
4608 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4609 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4610 __scalar_expr<value_type>(__x, __y.size()), __y));
4613 template<class _Expr>
4614 inline _LIBCPP_INLINE_VISIBILITY
4617 __is_val_expr<_Expr>::value,
4618 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4620 abs(const _Expr& __x)
4622 typedef typename _Expr::value_type value_type;
4623 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4624 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4627 template<class _Expr>
4628 inline _LIBCPP_INLINE_VISIBILITY
4631 __is_val_expr<_Expr>::value,
4632 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4634 acos(const _Expr& __x)
4636 typedef typename _Expr::value_type value_type;
4637 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4638 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4641 template<class _Expr>
4642 inline _LIBCPP_INLINE_VISIBILITY
4645 __is_val_expr<_Expr>::value,
4646 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4648 asin(const _Expr& __x)
4650 typedef typename _Expr::value_type value_type;
4651 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4652 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4655 template<class _Expr>
4656 inline _LIBCPP_INLINE_VISIBILITY
4659 __is_val_expr<_Expr>::value,
4660 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4662 atan(const _Expr& __x)
4664 typedef typename _Expr::value_type value_type;
4665 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4666 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4669 template<class _Expr1, class _Expr2>
4670 inline _LIBCPP_INLINE_VISIBILITY
4673 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4674 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4676 atan2(const _Expr1& __x, const _Expr2& __y)
4678 typedef typename _Expr1::value_type value_type;
4679 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4680 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4683 template<class _Expr>
4684 inline _LIBCPP_INLINE_VISIBILITY
4687 __is_val_expr<_Expr>::value,
4688 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4689 _Expr, __scalar_expr<typename _Expr::value_type> > >
4691 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4693 typedef typename _Expr::value_type value_type;
4694 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4695 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4696 __x, __scalar_expr<value_type>(__y, __x.size())));
4699 template<class _Expr>
4700 inline _LIBCPP_INLINE_VISIBILITY
4703 __is_val_expr<_Expr>::value,
4704 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4705 __scalar_expr<typename _Expr::value_type>, _Expr> >
4707 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4709 typedef typename _Expr::value_type value_type;
4710 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4711 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4712 __scalar_expr<value_type>(__x, __y.size()), __y));
4715 template<class _Expr>
4716 inline _LIBCPP_INLINE_VISIBILITY
4719 __is_val_expr<_Expr>::value,
4720 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4722 cos(const _Expr& __x)
4724 typedef typename _Expr::value_type value_type;
4725 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4726 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4729 template<class _Expr>
4730 inline _LIBCPP_INLINE_VISIBILITY
4733 __is_val_expr<_Expr>::value,
4734 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4736 cosh(const _Expr& __x)
4738 typedef typename _Expr::value_type value_type;
4739 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4740 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4743 template<class _Expr>
4744 inline _LIBCPP_INLINE_VISIBILITY
4747 __is_val_expr<_Expr>::value,
4748 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4750 exp(const _Expr& __x)
4752 typedef typename _Expr::value_type value_type;
4753 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4754 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4757 template<class _Expr>
4758 inline _LIBCPP_INLINE_VISIBILITY
4761 __is_val_expr<_Expr>::value,
4762 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4764 log(const _Expr& __x)
4766 typedef typename _Expr::value_type value_type;
4767 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4768 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4771 template<class _Expr>
4772 inline _LIBCPP_INLINE_VISIBILITY
4775 __is_val_expr<_Expr>::value,
4776 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4778 log10(const _Expr& __x)
4780 typedef typename _Expr::value_type value_type;
4781 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4782 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4785 template<class _Expr1, class _Expr2>
4786 inline _LIBCPP_INLINE_VISIBILITY
4789 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4790 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4792 pow(const _Expr1& __x, const _Expr2& __y)
4794 typedef typename _Expr1::value_type value_type;
4795 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4796 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4799 template<class _Expr>
4800 inline _LIBCPP_INLINE_VISIBILITY
4803 __is_val_expr<_Expr>::value,
4804 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4805 _Expr, __scalar_expr<typename _Expr::value_type> > >
4807 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4809 typedef typename _Expr::value_type value_type;
4810 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4811 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4812 __x, __scalar_expr<value_type>(__y, __x.size())));
4815 template<class _Expr>
4816 inline _LIBCPP_INLINE_VISIBILITY
4819 __is_val_expr<_Expr>::value,
4820 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4821 __scalar_expr<typename _Expr::value_type>, _Expr> >
4823 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4825 typedef typename _Expr::value_type value_type;
4826 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4827 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4828 __scalar_expr<value_type>(__x, __y.size()), __y));
4831 template<class _Expr>
4832 inline _LIBCPP_INLINE_VISIBILITY
4835 __is_val_expr<_Expr>::value,
4836 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4838 sin(const _Expr& __x)
4840 typedef typename _Expr::value_type value_type;
4841 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4842 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4845 template<class _Expr>
4846 inline _LIBCPP_INLINE_VISIBILITY
4849 __is_val_expr<_Expr>::value,
4850 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4852 sinh(const _Expr& __x)
4854 typedef typename _Expr::value_type value_type;
4855 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4856 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4859 template<class _Expr>
4860 inline _LIBCPP_INLINE_VISIBILITY
4863 __is_val_expr<_Expr>::value,
4864 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4866 sqrt(const _Expr& __x)
4868 typedef typename _Expr::value_type value_type;
4869 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4870 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4873 template<class _Expr>
4874 inline _LIBCPP_INLINE_VISIBILITY
4877 __is_val_expr<_Expr>::value,
4878 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4880 tan(const _Expr& __x)
4882 typedef typename _Expr::value_type value_type;
4883 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4884 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4887 template<class _Expr>
4888 inline _LIBCPP_INLINE_VISIBILITY
4891 __is_val_expr<_Expr>::value,
4892 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4894 tanh(const _Expr& __x)
4896 typedef typename _Expr::value_type value_type;
4897 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4898 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4901 template <class _Tp>
4902 inline _LIBCPP_INLINE_VISIBILITY
4904 begin(valarray<_Tp>& __v)
4906 return __v.__begin_;
4909 template <class _Tp>
4910 inline _LIBCPP_INLINE_VISIBILITY
4912 begin(const valarray<_Tp>& __v)
4914 return __v.__begin_;
4917 template <class _Tp>
4918 inline _LIBCPP_INLINE_VISIBILITY
4920 end(valarray<_Tp>& __v)
4925 template <class _Tp>
4926 inline _LIBCPP_INLINE_VISIBILITY
4928 end(const valarray<_Tp>& __v)
4933 _LIBCPP_END_NAMESPACE_STD
4937 #endif // _LIBCPP_VALARRAY