2 //===-------------------------- valarray ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_VALARRAY
12 #define _LIBCPP_VALARRAY
28 explicit valarray(size_t n);
29 valarray(const value_type& x, size_t n);
30 valarray(const value_type* px, size_t n);
31 valarray(const valarray& v);
32 valarray(valarray&& v) noexcept;
33 valarray(const slice_array<value_type>& sa);
34 valarray(const gslice_array<value_type>& ga);
35 valarray(const mask_array<value_type>& ma);
36 valarray(const indirect_array<value_type>& ia);
37 valarray(initializer_list<value_type> il);
41 valarray& operator=(const valarray& v);
42 valarray& operator=(valarray&& v) noexcept;
43 valarray& operator=(initializer_list<value_type> il);
44 valarray& operator=(const value_type& x);
45 valarray& operator=(const slice_array<value_type>& sa);
46 valarray& operator=(const gslice_array<value_type>& ga);
47 valarray& operator=(const mask_array<value_type>& ma);
48 valarray& operator=(const indirect_array<value_type>& ia);
51 const value_type& operator[](size_t i) const;
52 value_type& operator[](size_t i);
55 valarray operator[](slice s) const;
56 slice_array<value_type> operator[](slice s);
57 valarray operator[](const gslice& gs) const;
58 gslice_array<value_type> operator[](const gslice& gs);
59 valarray operator[](const valarray<bool>& vb) const;
60 mask_array<value_type> operator[](const valarray<bool>& vb);
61 valarray operator[](const valarray<size_t>& vs) const;
62 indirect_array<value_type> operator[](const valarray<size_t>& vs);
65 valarray operator+() const;
66 valarray operator-() const;
67 valarray operator~() const;
68 valarray<bool> operator!() const;
70 // computed assignment:
71 valarray& operator*= (const value_type& x);
72 valarray& operator/= (const value_type& x);
73 valarray& operator%= (const value_type& x);
74 valarray& operator+= (const value_type& x);
75 valarray& operator-= (const value_type& x);
76 valarray& operator^= (const value_type& x);
77 valarray& operator&= (const value_type& x);
78 valarray& operator|= (const value_type& x);
79 valarray& operator<<=(const value_type& x);
80 valarray& operator>>=(const value_type& x);
82 valarray& operator*= (const valarray& v);
83 valarray& operator/= (const valarray& v);
84 valarray& operator%= (const valarray& v);
85 valarray& operator+= (const valarray& v);
86 valarray& operator-= (const valarray& v);
87 valarray& operator^= (const valarray& v);
88 valarray& operator|= (const valarray& v);
89 valarray& operator&= (const valarray& v);
90 valarray& operator<<=(const valarray& v);
91 valarray& operator>>=(const valarray& v);
94 void swap(valarray& v) noexcept;
98 value_type sum() const;
99 value_type min() const;
100 value_type max() const;
102 valarray shift (int i) const;
103 valarray cshift(int i) const;
104 valarray apply(value_type f(value_type)) const;
105 valarray apply(value_type f(const value_type&)) const;
106 void resize(size_t n, value_type x = value_type());
113 slice(size_t start, size_t size, size_t stride);
115 size_t start() const;
117 size_t stride() const;
124 typedef T value_type;
126 const slice_array& operator=(const slice_array& sa) const;
127 void operator= (const valarray<value_type>& v) const;
128 void operator*= (const valarray<value_type>& v) const;
129 void operator/= (const valarray<value_type>& v) const;
130 void operator%= (const valarray<value_type>& v) const;
131 void operator+= (const valarray<value_type>& v) const;
132 void operator-= (const valarray<value_type>& v) const;
133 void operator^= (const valarray<value_type>& v) const;
134 void operator&= (const valarray<value_type>& v) const;
135 void operator|= (const valarray<value_type>& v) const;
136 void operator<<=(const valarray<value_type>& v) const;
137 void operator>>=(const valarray<value_type>& v) const;
139 void operator=(const value_type& x) const;
141 slice_array() = delete;
148 gslice(size_t start, const valarray<size_t>& size,
149 const valarray<size_t>& stride);
151 size_t start() const;
152 valarray<size_t> size() const;
153 valarray<size_t> stride() const;
160 typedef T value_type;
162 void operator= (const valarray<value_type>& v) const;
163 void operator*= (const valarray<value_type>& v) const;
164 void operator/= (const valarray<value_type>& v) const;
165 void operator%= (const valarray<value_type>& v) const;
166 void operator+= (const valarray<value_type>& v) const;
167 void operator-= (const valarray<value_type>& v) const;
168 void operator^= (const valarray<value_type>& v) const;
169 void operator&= (const valarray<value_type>& v) const;
170 void operator|= (const valarray<value_type>& v) const;
171 void operator<<=(const valarray<value_type>& v) const;
172 void operator>>=(const valarray<value_type>& v) const;
174 gslice_array(const gslice_array& ga);
176 const gslice_array& operator=(const gslice_array& ga) const;
177 void operator=(const value_type& x) const;
179 gslice_array() = delete;
186 typedef T value_type;
188 void operator= (const valarray<value_type>& v) const;
189 void operator*= (const valarray<value_type>& v) const;
190 void operator/= (const valarray<value_type>& v) const;
191 void operator%= (const valarray<value_type>& v) const;
192 void operator+= (const valarray<value_type>& v) const;
193 void operator-= (const valarray<value_type>& v) const;
194 void operator^= (const valarray<value_type>& v) const;
195 void operator&= (const valarray<value_type>& v) const;
196 void operator|= (const valarray<value_type>& v) const;
197 void operator<<=(const valarray<value_type>& v) const;
198 void operator>>=(const valarray<value_type>& v) const;
200 mask_array(const mask_array& ma);
202 const mask_array& operator=(const mask_array& ma) const;
203 void operator=(const value_type& x) const;
205 mask_array() = delete;
212 typedef T value_type;
214 void operator= (const valarray<value_type>& v) const;
215 void operator*= (const valarray<value_type>& v) const;
216 void operator/= (const valarray<value_type>& v) const;
217 void operator%= (const valarray<value_type>& v) const;
218 void operator+= (const valarray<value_type>& v) const;
219 void operator-= (const valarray<value_type>& v) const;
220 void operator^= (const valarray<value_type>& v) const;
221 void operator&= (const valarray<value_type>& v) const;
222 void operator|= (const valarray<value_type>& v) const;
223 void operator<<=(const valarray<value_type>& v) const;
224 void operator>>=(const valarray<value_type>& v) const;
226 indirect_array(const indirect_array& ia);
228 const indirect_array& operator=(const indirect_array& ia) const;
229 void operator=(const value_type& x) const;
231 indirect_array() = delete;
234 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
236 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
237 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
238 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
240 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
241 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
242 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
244 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
245 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
246 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
248 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
249 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
250 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
252 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
253 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
254 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
256 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
257 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
258 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
260 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
261 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
262 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
264 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
265 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
266 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
268 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
269 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
270 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
272 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
273 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
274 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
276 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
277 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
278 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
280 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
281 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
282 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
284 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
285 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
286 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
288 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
289 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
290 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
292 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
293 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
294 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
296 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
297 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
298 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
300 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
301 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
302 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
304 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
305 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
306 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
308 template<class T> valarray<T> abs (const valarray<T>& x);
309 template<class T> valarray<T> acos (const valarray<T>& x);
310 template<class T> valarray<T> asin (const valarray<T>& x);
311 template<class T> valarray<T> atan (const valarray<T>& x);
313 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
314 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
315 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
317 template<class T> valarray<T> cos (const valarray<T>& x);
318 template<class T> valarray<T> cosh (const valarray<T>& x);
319 template<class T> valarray<T> exp (const valarray<T>& x);
320 template<class T> valarray<T> log (const valarray<T>& x);
321 template<class T> valarray<T> log10(const valarray<T>& x);
323 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
324 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
325 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
327 template<class T> valarray<T> sin (const valarray<T>& x);
328 template<class T> valarray<T> sinh (const valarray<T>& x);
329 template<class T> valarray<T> sqrt (const valarray<T>& x);
330 template<class T> valarray<T> tan (const valarray<T>& x);
331 template<class T> valarray<T> tanh (const valarray<T>& x);
333 template <class T> unspecified1 begin(valarray<T>& v);
334 template <class T> unspecified2 begin(const valarray<T>& v);
335 template <class T> unspecified1 end(valarray<T>& v);
336 template <class T> unspecified2 end(const valarray<T>& v);
345 #include <initializer_list>
347 #include <functional>
349 #include <__undef_min_max>
351 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
352 #pragma GCC system_header
355 _LIBCPP_BEGIN_NAMESPACE_STD
357 template<class _Tp> class _LIBCPP_TYPE_VIS valarray;
359 class _LIBCPP_TYPE_VIS slice
365 _LIBCPP_INLINE_VISIBILITY
372 _LIBCPP_INLINE_VISIBILITY
373 slice(size_t __start, size_t __size, size_t __stride)
379 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
380 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
381 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
384 template <class _Tp> class _LIBCPP_TYPE_VIS slice_array;
385 class _LIBCPP_TYPE_VIS gslice;
386 template <class _Tp> class _LIBCPP_TYPE_VIS gslice_array;
387 template <class _Tp> class _LIBCPP_TYPE_VIS mask_array;
388 template <class _Tp> class _LIBCPP_TYPE_VIS indirect_array;
391 _LIBCPP_INLINE_VISIBILITY
393 begin(valarray<_Tp>& __v);
396 _LIBCPP_INLINE_VISIBILITY
398 begin(const valarray<_Tp>& __v);
401 _LIBCPP_INLINE_VISIBILITY
403 end(valarray<_Tp>& __v);
406 _LIBCPP_INLINE_VISIBILITY
408 end(const valarray<_Tp>& __v);
410 template <class _Op, class _A0>
413 typedef typename _Op::result_type result_type;
414 typedef typename _A0::value_type value_type;
419 _LIBCPP_INLINE_VISIBILITY
420 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
422 _LIBCPP_INLINE_VISIBILITY
423 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
425 _LIBCPP_INLINE_VISIBILITY
426 size_t size() const {return __a0_.size();}
429 template <class _Op, class _A0, class _A1>
432 typedef typename _Op::result_type result_type;
433 typedef typename _A0::value_type value_type;
439 _LIBCPP_INLINE_VISIBILITY
440 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
441 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
443 _LIBCPP_INLINE_VISIBILITY
444 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
446 _LIBCPP_INLINE_VISIBILITY
447 size_t size() const {return __a0_.size();}
454 typedef _Tp value_type;
455 typedef const _Tp& result_type;
457 const value_type& __t_;
460 _LIBCPP_INLINE_VISIBILITY
461 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
463 _LIBCPP_INLINE_VISIBILITY
464 result_type operator[](size_t) const {return __t_;}
466 _LIBCPP_INLINE_VISIBILITY
467 size_t size() const {return __s_;}
471 struct __unary_plus : unary_function<_Tp, _Tp>
473 _LIBCPP_INLINE_VISIBILITY
474 _Tp operator()(const _Tp& __x) const
479 struct __bit_not : unary_function<_Tp, _Tp>
481 _LIBCPP_INLINE_VISIBILITY
482 _Tp operator()(const _Tp& __x) const
487 struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
489 _LIBCPP_INLINE_VISIBILITY
490 _Tp operator()(const _Tp& __x, const _Tp& __y) const
495 struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
497 _LIBCPP_INLINE_VISIBILITY
498 _Tp operator()(const _Tp& __x, const _Tp& __y) const
502 template <class _Tp, class _Fp>
503 struct __apply_expr : unary_function<_Tp, _Tp>
508 _LIBCPP_INLINE_VISIBILITY
509 explicit __apply_expr(_Fp __f) : __f_(__f) {}
511 _LIBCPP_INLINE_VISIBILITY
512 _Tp operator()(const _Tp& __x) const
517 struct __abs_expr : unary_function<_Tp, _Tp>
519 _LIBCPP_INLINE_VISIBILITY
520 _Tp operator()(const _Tp& __x) const
525 struct __acos_expr : unary_function<_Tp, _Tp>
527 _LIBCPP_INLINE_VISIBILITY
528 _Tp operator()(const _Tp& __x) const
533 struct __asin_expr : unary_function<_Tp, _Tp>
535 _LIBCPP_INLINE_VISIBILITY
536 _Tp operator()(const _Tp& __x) const
541 struct __atan_expr : unary_function<_Tp, _Tp>
543 _LIBCPP_INLINE_VISIBILITY
544 _Tp operator()(const _Tp& __x) const
549 struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
551 _LIBCPP_INLINE_VISIBILITY
552 _Tp operator()(const _Tp& __x, const _Tp& __y) const
553 {return atan2(__x, __y);}
557 struct __cos_expr : unary_function<_Tp, _Tp>
559 _LIBCPP_INLINE_VISIBILITY
560 _Tp operator()(const _Tp& __x) const
565 struct __cosh_expr : unary_function<_Tp, _Tp>
567 _LIBCPP_INLINE_VISIBILITY
568 _Tp operator()(const _Tp& __x) const
573 struct __exp_expr : unary_function<_Tp, _Tp>
575 _LIBCPP_INLINE_VISIBILITY
576 _Tp operator()(const _Tp& __x) const
581 struct __log_expr : unary_function<_Tp, _Tp>
583 _LIBCPP_INLINE_VISIBILITY
584 _Tp operator()(const _Tp& __x) const
589 struct __log10_expr : unary_function<_Tp, _Tp>
591 _LIBCPP_INLINE_VISIBILITY
592 _Tp operator()(const _Tp& __x) const
597 struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
599 _LIBCPP_INLINE_VISIBILITY
600 _Tp operator()(const _Tp& __x, const _Tp& __y) const
601 {return pow(__x, __y);}
605 struct __sin_expr : unary_function<_Tp, _Tp>
607 _LIBCPP_INLINE_VISIBILITY
608 _Tp operator()(const _Tp& __x) const
613 struct __sinh_expr : unary_function<_Tp, _Tp>
615 _LIBCPP_INLINE_VISIBILITY
616 _Tp operator()(const _Tp& __x) const
621 struct __sqrt_expr : unary_function<_Tp, _Tp>
623 _LIBCPP_INLINE_VISIBILITY
624 _Tp operator()(const _Tp& __x) const
629 struct __tan_expr : unary_function<_Tp, _Tp>
631 _LIBCPP_INLINE_VISIBILITY
632 _Tp operator()(const _Tp& __x) const
637 struct __tanh_expr : unary_function<_Tp, _Tp>
639 _LIBCPP_INLINE_VISIBILITY
640 _Tp operator()(const _Tp& __x) const
644 template <class _ValExpr>
647 typedef typename remove_reference<_ValExpr>::type _RmExpr;
649 typedef typename _RmExpr::value_type value_type;
650 typedef value_type result_type;
658 _LIBCPP_INLINE_VISIBILITY
659 __slice_expr(const slice& __sl, const _RmExpr& __e)
661 __start_(__sl.start()),
662 __size_(__sl.size()),
663 __stride_(__sl.stride())
667 _LIBCPP_INLINE_VISIBILITY
668 result_type operator[](size_t __i) const
669 {return __expr_[__start_ + __i * __stride_];}
671 _LIBCPP_INLINE_VISIBILITY
672 size_t size() const {return __size_;}
674 template <class> friend class _LIBCPP_TYPE_VIS valarray;
677 template <class _ValExpr>
680 template <class _ValExpr>
681 class __indirect_expr;
683 template <class _ValExpr>
686 typedef typename remove_reference<_ValExpr>::type _RmExpr;
688 typedef typename _RmExpr::value_type value_type;
689 typedef value_type result_type;
697 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
698 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
700 _LIBCPP_INLINE_VISIBILITY
701 __shift_expr(int __n, const _RmExpr& __e)
706 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
707 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
708 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
712 _LIBCPP_INLINE_VISIBILITY
713 result_type operator[](size_t __j) const
715 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
716 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
717 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
720 _LIBCPP_INLINE_VISIBILITY
721 size_t size() const {return __size_;}
723 template <class> friend class __val_expr;
726 template <class _ValExpr>
729 typedef typename remove_reference<_ValExpr>::type _RmExpr;
731 typedef typename _RmExpr::value_type value_type;
732 typedef value_type result_type;
741 _LIBCPP_INLINE_VISIBILITY
742 __cshift_expr(int __n, const _RmExpr& __e)
746 __n %= static_cast<int>(__size_);
749 __m_ = __size_ - __n;
751 __o2_ = __n - __size_;
756 __o1_ = __n + __size_;
762 _LIBCPP_INLINE_VISIBILITY
763 result_type operator[](size_t __i) const
766 return __expr_[__i + __o1_];
767 return __expr_[__i + __o2_];
770 _LIBCPP_INLINE_VISIBILITY
771 size_t size() const {return __size_;}
773 template <class> friend class __val_expr;
776 template<class _ValExpr>
779 template<class _ValExpr>
780 struct __is_val_expr : false_type {};
782 template<class _ValExpr>
783 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
786 struct __is_val_expr<valarray<_Tp> > : true_type {};
789 class _LIBCPP_TYPE_VIS valarray
792 typedef _Tp value_type;
793 typedef _Tp result_type;
796 value_type* __begin_;
800 // construct/destroy:
801 _LIBCPP_INLINE_VISIBILITY
802 valarray() : __begin_(0), __end_(0) {}
803 explicit valarray(size_t __n);
804 valarray(const value_type& __x, size_t __n);
805 valarray(const value_type* __p, size_t __n);
806 valarray(const valarray& __v);
807 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
808 valarray(valarray&& __v) _NOEXCEPT;
809 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
810 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
811 valarray(initializer_list<value_type> __il);
812 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
813 valarray(const slice_array<value_type>& __sa);
814 valarray(const gslice_array<value_type>& __ga);
815 valarray(const mask_array<value_type>& __ma);
816 valarray(const indirect_array<value_type>& __ia);
820 valarray& operator=(const valarray& __v);
821 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
822 valarray& operator=(valarray&& __v) _NOEXCEPT;
823 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
824 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
825 valarray& operator=(initializer_list<value_type>);
826 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
827 valarray& operator=(const value_type& __x);
828 valarray& operator=(const slice_array<value_type>& __sa);
829 valarray& operator=(const gslice_array<value_type>& __ga);
830 valarray& operator=(const mask_array<value_type>& __ma);
831 valarray& operator=(const indirect_array<value_type>& __ia);
832 template <class _ValExpr>
833 valarray& operator=(const __val_expr<_ValExpr>& __v);
836 _LIBCPP_INLINE_VISIBILITY
837 const value_type& operator[](size_t __i) const {return __begin_[__i];}
839 _LIBCPP_INLINE_VISIBILITY
840 value_type& operator[](size_t __i) {return __begin_[__i];}
842 // subset operations:
843 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
844 slice_array<value_type> operator[](slice __s);
845 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
846 gslice_array<value_type> operator[](const gslice& __gs);
847 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
848 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
849 gslice_array<value_type> operator[](gslice&& __gs);
850 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
851 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
852 mask_array<value_type> operator[](const valarray<bool>& __vb);
853 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
854 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
855 mask_array<value_type> operator[](valarray<bool>&& __vb);
856 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
857 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
858 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
859 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
860 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
861 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
862 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
865 valarray operator+() const;
866 valarray operator-() const;
867 valarray operator~() const;
868 valarray<bool> operator!() const;
870 // computed assignment:
871 valarray& operator*= (const value_type& __x);
872 valarray& operator/= (const value_type& __x);
873 valarray& operator%= (const value_type& __x);
874 valarray& operator+= (const value_type& __x);
875 valarray& operator-= (const value_type& __x);
876 valarray& operator^= (const value_type& __x);
877 valarray& operator&= (const value_type& __x);
878 valarray& operator|= (const value_type& __x);
879 valarray& operator<<=(const value_type& __x);
880 valarray& operator>>=(const value_type& __x);
882 template <class _Expr>
885 __is_val_expr<_Expr>::value,
888 operator*= (const _Expr& __v);
890 template <class _Expr>
893 __is_val_expr<_Expr>::value,
896 operator/= (const _Expr& __v);
898 template <class _Expr>
901 __is_val_expr<_Expr>::value,
904 operator%= (const _Expr& __v);
906 template <class _Expr>
909 __is_val_expr<_Expr>::value,
912 operator+= (const _Expr& __v);
914 template <class _Expr>
917 __is_val_expr<_Expr>::value,
920 operator-= (const _Expr& __v);
922 template <class _Expr>
925 __is_val_expr<_Expr>::value,
928 operator^= (const _Expr& __v);
930 template <class _Expr>
933 __is_val_expr<_Expr>::value,
936 operator|= (const _Expr& __v);
938 template <class _Expr>
941 __is_val_expr<_Expr>::value,
944 operator&= (const _Expr& __v);
946 template <class _Expr>
949 __is_val_expr<_Expr>::value,
952 operator<<= (const _Expr& __v);
954 template <class _Expr>
957 __is_val_expr<_Expr>::value,
960 operator>>= (const _Expr& __v);
963 void swap(valarray& __v) _NOEXCEPT;
965 _LIBCPP_INLINE_VISIBILITY
966 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
968 value_type sum() const;
969 value_type min() const;
970 value_type max() const;
972 valarray shift (int __i) const;
973 valarray cshift(int __i) const;
974 valarray apply(value_type __f(value_type)) const;
975 valarray apply(value_type __f(const value_type&)) const;
976 void resize(size_t __n, value_type __x = value_type());
979 template <class> friend class _LIBCPP_TYPE_VIS valarray;
980 template <class> friend class _LIBCPP_TYPE_VIS slice_array;
981 template <class> friend class _LIBCPP_TYPE_VIS gslice_array;
982 template <class> friend class _LIBCPP_TYPE_VIS mask_array;
983 template <class> friend class __mask_expr;
984 template <class> friend class _LIBCPP_TYPE_VIS indirect_array;
985 template <class> friend class __indirect_expr;
986 template <class> friend class __val_expr;
991 begin(valarray<_Up>& __v);
996 begin(const valarray<_Up>& __v);
1001 end(valarray<_Up>& __v);
1003 template <class _Up>
1006 end(const valarray<_Up>& __v);
1009 template <class _Op, class _Tp>
1010 struct _UnaryOp<_Op, valarray<_Tp> >
1012 typedef typename _Op::result_type result_type;
1013 typedef _Tp value_type;
1016 const valarray<_Tp>& __a0_;
1018 _LIBCPP_INLINE_VISIBILITY
1019 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1021 _LIBCPP_INLINE_VISIBILITY
1022 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1024 _LIBCPP_INLINE_VISIBILITY
1025 size_t size() const {return __a0_.size();}
1028 template <class _Op, class _Tp, class _A1>
1029 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1031 typedef typename _Op::result_type result_type;
1032 typedef _Tp value_type;
1035 const valarray<_Tp>& __a0_;
1038 _LIBCPP_INLINE_VISIBILITY
1039 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1040 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1042 _LIBCPP_INLINE_VISIBILITY
1043 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1045 _LIBCPP_INLINE_VISIBILITY
1046 size_t size() const {return __a0_.size();}
1049 template <class _Op, class _A0, class _Tp>
1050 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1052 typedef typename _Op::result_type result_type;
1053 typedef _Tp value_type;
1057 const valarray<_Tp>& __a1_;
1059 _LIBCPP_INLINE_VISIBILITY
1060 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1061 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1063 _LIBCPP_INLINE_VISIBILITY
1064 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1066 _LIBCPP_INLINE_VISIBILITY
1067 size_t size() const {return __a0_.size();}
1070 template <class _Op, class _Tp>
1071 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1073 typedef typename _Op::result_type result_type;
1074 typedef _Tp value_type;
1077 const valarray<_Tp>& __a0_;
1078 const valarray<_Tp>& __a1_;
1080 _LIBCPP_INLINE_VISIBILITY
1081 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1082 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1084 _LIBCPP_INLINE_VISIBILITY
1085 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1087 _LIBCPP_INLINE_VISIBILITY
1088 size_t size() const {return __a0_.size();}
1093 template <class _Tp>
1094 class _LIBCPP_TYPE_VIS slice_array
1097 typedef _Tp value_type;
1105 template <class _Expr>
1108 __is_val_expr<_Expr>::value,
1111 operator=(const _Expr& __v) const;
1113 template <class _Expr>
1116 __is_val_expr<_Expr>::value,
1119 operator*=(const _Expr& __v) const;
1121 template <class _Expr>
1124 __is_val_expr<_Expr>::value,
1127 operator/=(const _Expr& __v) const;
1129 template <class _Expr>
1132 __is_val_expr<_Expr>::value,
1135 operator%=(const _Expr& __v) const;
1137 template <class _Expr>
1140 __is_val_expr<_Expr>::value,
1143 operator+=(const _Expr& __v) const;
1145 template <class _Expr>
1148 __is_val_expr<_Expr>::value,
1151 operator-=(const _Expr& __v) const;
1153 template <class _Expr>
1156 __is_val_expr<_Expr>::value,
1159 operator^=(const _Expr& __v) const;
1161 template <class _Expr>
1164 __is_val_expr<_Expr>::value,
1167 operator&=(const _Expr& __v) const;
1169 template <class _Expr>
1172 __is_val_expr<_Expr>::value,
1175 operator|=(const _Expr& __v) const;
1177 template <class _Expr>
1180 __is_val_expr<_Expr>::value,
1183 operator<<=(const _Expr& __v) const;
1185 template <class _Expr>
1188 __is_val_expr<_Expr>::value,
1191 operator>>=(const _Expr& __v) const;
1193 const slice_array& operator=(const slice_array& __sa) const;
1195 void operator=(const value_type& __x) const;
1198 _LIBCPP_INLINE_VISIBILITY
1199 slice_array(const slice& __sl, const valarray<value_type>& __v)
1200 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1201 __size_(__sl.size()),
1202 __stride_(__sl.stride())
1205 template <class> friend class valarray;
1206 template <class> friend class sliceExpr;
1209 template <class _Tp>
1210 inline _LIBCPP_INLINE_VISIBILITY
1211 const slice_array<_Tp>&
1212 slice_array<_Tp>::operator=(const slice_array& __sa) const
1214 value_type* __t = __vp_;
1215 const value_type* __s = __sa.__vp_;
1216 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1220 template <class _Tp>
1221 template <class _Expr>
1222 inline _LIBCPP_INLINE_VISIBILITY
1225 __is_val_expr<_Expr>::value,
1228 slice_array<_Tp>::operator=(const _Expr& __v) const
1230 value_type* __t = __vp_;
1231 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1235 template <class _Tp>
1236 template <class _Expr>
1237 inline _LIBCPP_INLINE_VISIBILITY
1240 __is_val_expr<_Expr>::value,
1243 slice_array<_Tp>::operator*=(const _Expr& __v) const
1245 value_type* __t = __vp_;
1246 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1250 template <class _Tp>
1251 template <class _Expr>
1252 inline _LIBCPP_INLINE_VISIBILITY
1255 __is_val_expr<_Expr>::value,
1258 slice_array<_Tp>::operator/=(const _Expr& __v) const
1260 value_type* __t = __vp_;
1261 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1265 template <class _Tp>
1266 template <class _Expr>
1267 inline _LIBCPP_INLINE_VISIBILITY
1270 __is_val_expr<_Expr>::value,
1273 slice_array<_Tp>::operator%=(const _Expr& __v) const
1275 value_type* __t = __vp_;
1276 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1280 template <class _Tp>
1281 template <class _Expr>
1282 inline _LIBCPP_INLINE_VISIBILITY
1285 __is_val_expr<_Expr>::value,
1288 slice_array<_Tp>::operator+=(const _Expr& __v) const
1290 value_type* __t = __vp_;
1291 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1295 template <class _Tp>
1296 template <class _Expr>
1297 inline _LIBCPP_INLINE_VISIBILITY
1300 __is_val_expr<_Expr>::value,
1303 slice_array<_Tp>::operator-=(const _Expr& __v) const
1305 value_type* __t = __vp_;
1306 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1310 template <class _Tp>
1311 template <class _Expr>
1312 inline _LIBCPP_INLINE_VISIBILITY
1315 __is_val_expr<_Expr>::value,
1318 slice_array<_Tp>::operator^=(const _Expr& __v) const
1320 value_type* __t = __vp_;
1321 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1325 template <class _Tp>
1326 template <class _Expr>
1327 inline _LIBCPP_INLINE_VISIBILITY
1330 __is_val_expr<_Expr>::value,
1333 slice_array<_Tp>::operator&=(const _Expr& __v) const
1335 value_type* __t = __vp_;
1336 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1340 template <class _Tp>
1341 template <class _Expr>
1342 inline _LIBCPP_INLINE_VISIBILITY
1345 __is_val_expr<_Expr>::value,
1348 slice_array<_Tp>::operator|=(const _Expr& __v) const
1350 value_type* __t = __vp_;
1351 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1355 template <class _Tp>
1356 template <class _Expr>
1357 inline _LIBCPP_INLINE_VISIBILITY
1360 __is_val_expr<_Expr>::value,
1363 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1365 value_type* __t = __vp_;
1366 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1370 template <class _Tp>
1371 template <class _Expr>
1372 inline _LIBCPP_INLINE_VISIBILITY
1375 __is_val_expr<_Expr>::value,
1378 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1380 value_type* __t = __vp_;
1381 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1385 template <class _Tp>
1386 inline _LIBCPP_INLINE_VISIBILITY
1388 slice_array<_Tp>::operator=(const value_type& __x) const
1390 value_type* __t = __vp_;
1391 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1397 class _LIBCPP_TYPE_VIS gslice
1399 valarray<size_t> __size_;
1400 valarray<size_t> __stride_;
1401 valarray<size_t> __1d_;
1404 _LIBCPP_INLINE_VISIBILITY
1407 _LIBCPP_INLINE_VISIBILITY
1408 gslice(size_t __start, const valarray<size_t>& __size,
1409 const valarray<size_t>& __stride)
1414 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1416 _LIBCPP_INLINE_VISIBILITY
1417 gslice(size_t __start, const valarray<size_t>& __size,
1418 valarray<size_t>&& __stride)
1420 __stride_(move(__stride))
1423 _LIBCPP_INLINE_VISIBILITY
1424 gslice(size_t __start, valarray<size_t>&& __size,
1425 const valarray<size_t>& __stride)
1426 : __size_(move(__size)),
1430 _LIBCPP_INLINE_VISIBILITY
1431 gslice(size_t __start, valarray<size_t>&& __size,
1432 valarray<size_t>&& __stride)
1433 : __size_(move(__size)),
1434 __stride_(move(__stride))
1437 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1439 // gslice(const gslice&) = default;
1440 // gslice(gslice&&) = default;
1441 // gslice& operator=(const gslice&) = default;
1442 // gslice& operator=(gslice&&) = default;
1444 _LIBCPP_INLINE_VISIBILITY
1445 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1447 _LIBCPP_INLINE_VISIBILITY
1448 valarray<size_t> size() const {return __size_;}
1450 _LIBCPP_INLINE_VISIBILITY
1451 valarray<size_t> stride() const {return __stride_;}
1454 void __init(size_t __start);
1456 template <class> friend class gslice_array;
1457 template <class> friend class valarray;
1458 template <class> friend class __val_expr;
1463 template <class _Tp>
1464 class _LIBCPP_TYPE_VIS gslice_array
1467 typedef _Tp value_type;
1471 valarray<size_t> __1d_;
1474 template <class _Expr>
1477 __is_val_expr<_Expr>::value,
1480 operator=(const _Expr& __v) const;
1482 template <class _Expr>
1485 __is_val_expr<_Expr>::value,
1488 operator*=(const _Expr& __v) const;
1490 template <class _Expr>
1493 __is_val_expr<_Expr>::value,
1496 operator/=(const _Expr& __v) const;
1498 template <class _Expr>
1501 __is_val_expr<_Expr>::value,
1504 operator%=(const _Expr& __v) const;
1506 template <class _Expr>
1509 __is_val_expr<_Expr>::value,
1512 operator+=(const _Expr& __v) const;
1514 template <class _Expr>
1517 __is_val_expr<_Expr>::value,
1520 operator-=(const _Expr& __v) const;
1522 template <class _Expr>
1525 __is_val_expr<_Expr>::value,
1528 operator^=(const _Expr& __v) const;
1530 template <class _Expr>
1533 __is_val_expr<_Expr>::value,
1536 operator&=(const _Expr& __v) const;
1538 template <class _Expr>
1541 __is_val_expr<_Expr>::value,
1544 operator|=(const _Expr& __v) const;
1546 template <class _Expr>
1549 __is_val_expr<_Expr>::value,
1552 operator<<=(const _Expr& __v) const;
1554 template <class _Expr>
1557 __is_val_expr<_Expr>::value,
1560 operator>>=(const _Expr& __v) const;
1562 const gslice_array& operator=(const gslice_array& __ga) const;
1564 void operator=(const value_type& __x) const;
1566 // gslice_array(const gslice_array&) = default;
1567 // gslice_array(gslice_array&&) = default;
1568 // gslice_array& operator=(const gslice_array&) = default;
1569 // gslice_array& operator=(gslice_array&&) = default;
1572 _LIBCPP_INLINE_VISIBILITY
1573 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1574 : __vp_(const_cast<value_type*>(__v.__begin_)),
1578 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1580 _LIBCPP_INLINE_VISIBILITY
1581 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1582 : __vp_(const_cast<value_type*>(__v.__begin_)),
1583 __1d_(move(__gs.__1d_))
1586 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1588 template <class> friend class valarray;
1591 template <class _Tp>
1592 template <class _Expr>
1593 inline _LIBCPP_INLINE_VISIBILITY
1596 __is_val_expr<_Expr>::value,
1599 gslice_array<_Tp>::operator=(const _Expr& __v) const
1601 typedef const size_t* _Ip;
1603 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1604 __vp_[*__i] = __v[__j];
1607 template <class _Tp>
1608 template <class _Expr>
1609 inline _LIBCPP_INLINE_VISIBILITY
1612 __is_val_expr<_Expr>::value,
1615 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1617 typedef const size_t* _Ip;
1619 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1620 __vp_[*__i] *= __v[__j];
1623 template <class _Tp>
1624 template <class _Expr>
1625 inline _LIBCPP_INLINE_VISIBILITY
1628 __is_val_expr<_Expr>::value,
1631 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1633 typedef const size_t* _Ip;
1635 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1636 __vp_[*__i] /= __v[__j];
1639 template <class _Tp>
1640 template <class _Expr>
1641 inline _LIBCPP_INLINE_VISIBILITY
1644 __is_val_expr<_Expr>::value,
1647 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1649 typedef const size_t* _Ip;
1651 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1652 __vp_[*__i] %= __v[__j];
1655 template <class _Tp>
1656 template <class _Expr>
1657 inline _LIBCPP_INLINE_VISIBILITY
1660 __is_val_expr<_Expr>::value,
1663 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1665 typedef const size_t* _Ip;
1667 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1668 __vp_[*__i] += __v[__j];
1671 template <class _Tp>
1672 template <class _Expr>
1673 inline _LIBCPP_INLINE_VISIBILITY
1676 __is_val_expr<_Expr>::value,
1679 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1681 typedef const size_t* _Ip;
1683 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1684 __vp_[*__i] -= __v[__j];
1687 template <class _Tp>
1688 template <class _Expr>
1689 inline _LIBCPP_INLINE_VISIBILITY
1692 __is_val_expr<_Expr>::value,
1695 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1697 typedef const size_t* _Ip;
1699 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1700 __vp_[*__i] ^= __v[__j];
1703 template <class _Tp>
1704 template <class _Expr>
1705 inline _LIBCPP_INLINE_VISIBILITY
1708 __is_val_expr<_Expr>::value,
1711 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1713 typedef const size_t* _Ip;
1715 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1716 __vp_[*__i] &= __v[__j];
1719 template <class _Tp>
1720 template <class _Expr>
1721 inline _LIBCPP_INLINE_VISIBILITY
1724 __is_val_expr<_Expr>::value,
1727 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1729 typedef const size_t* _Ip;
1731 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1732 __vp_[*__i] |= __v[__j];
1735 template <class _Tp>
1736 template <class _Expr>
1737 inline _LIBCPP_INLINE_VISIBILITY
1740 __is_val_expr<_Expr>::value,
1743 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1745 typedef const size_t* _Ip;
1747 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1748 __vp_[*__i] <<= __v[__j];
1751 template <class _Tp>
1752 template <class _Expr>
1753 inline _LIBCPP_INLINE_VISIBILITY
1756 __is_val_expr<_Expr>::value,
1759 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1761 typedef const size_t* _Ip;
1763 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1764 __vp_[*__i] >>= __v[__j];
1767 template <class _Tp>
1768 inline _LIBCPP_INLINE_VISIBILITY
1769 const gslice_array<_Tp>&
1770 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1772 typedef const size_t* _Ip;
1773 const value_type* __s = __ga.__vp_;
1774 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1775 __i != __e; ++__i, ++__j)
1776 __vp_[*__i] = __s[*__j];
1780 template <class _Tp>
1781 inline _LIBCPP_INLINE_VISIBILITY
1783 gslice_array<_Tp>::operator=(const value_type& __x) const
1785 typedef const size_t* _Ip;
1786 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1792 template <class _Tp>
1793 class _LIBCPP_TYPE_VIS mask_array
1796 typedef _Tp value_type;
1800 valarray<size_t> __1d_;
1803 template <class _Expr>
1806 __is_val_expr<_Expr>::value,
1809 operator=(const _Expr& __v) const;
1811 template <class _Expr>
1814 __is_val_expr<_Expr>::value,
1817 operator*=(const _Expr& __v) const;
1819 template <class _Expr>
1822 __is_val_expr<_Expr>::value,
1825 operator/=(const _Expr& __v) const;
1827 template <class _Expr>
1830 __is_val_expr<_Expr>::value,
1833 operator%=(const _Expr& __v) const;
1835 template <class _Expr>
1838 __is_val_expr<_Expr>::value,
1841 operator+=(const _Expr& __v) const;
1843 template <class _Expr>
1846 __is_val_expr<_Expr>::value,
1849 operator-=(const _Expr& __v) const;
1851 template <class _Expr>
1854 __is_val_expr<_Expr>::value,
1857 operator^=(const _Expr& __v) const;
1859 template <class _Expr>
1862 __is_val_expr<_Expr>::value,
1865 operator&=(const _Expr& __v) const;
1867 template <class _Expr>
1870 __is_val_expr<_Expr>::value,
1873 operator|=(const _Expr& __v) const;
1875 template <class _Expr>
1878 __is_val_expr<_Expr>::value,
1881 operator<<=(const _Expr& __v) const;
1883 template <class _Expr>
1886 __is_val_expr<_Expr>::value,
1889 operator>>=(const _Expr& __v) const;
1891 const mask_array& operator=(const mask_array& __ma) const;
1893 void operator=(const value_type& __x) const;
1895 // mask_array(const mask_array&) = default;
1896 // mask_array(mask_array&&) = default;
1897 // mask_array& operator=(const mask_array&) = default;
1898 // mask_array& operator=(mask_array&&) = default;
1901 _LIBCPP_INLINE_VISIBILITY
1902 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1903 : __vp_(const_cast<value_type*>(__v.__begin_)),
1904 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1907 for (size_t __i = 0; __i < __vb.size(); ++__i)
1912 template <class> friend class valarray;
1915 template <class _Tp>
1916 template <class _Expr>
1917 inline _LIBCPP_INLINE_VISIBILITY
1920 __is_val_expr<_Expr>::value,
1923 mask_array<_Tp>::operator=(const _Expr& __v) const
1925 size_t __n = __1d_.size();
1926 for (size_t __i = 0; __i < __n; ++__i)
1927 __vp_[__1d_[__i]] = __v[__i];
1930 template <class _Tp>
1931 template <class _Expr>
1932 inline _LIBCPP_INLINE_VISIBILITY
1935 __is_val_expr<_Expr>::value,
1938 mask_array<_Tp>::operator*=(const _Expr& __v) const
1940 size_t __n = __1d_.size();
1941 for (size_t __i = 0; __i < __n; ++__i)
1942 __vp_[__1d_[__i]] *= __v[__i];
1945 template <class _Tp>
1946 template <class _Expr>
1947 inline _LIBCPP_INLINE_VISIBILITY
1950 __is_val_expr<_Expr>::value,
1953 mask_array<_Tp>::operator/=(const _Expr& __v) const
1955 size_t __n = __1d_.size();
1956 for (size_t __i = 0; __i < __n; ++__i)
1957 __vp_[__1d_[__i]] /= __v[__i];
1960 template <class _Tp>
1961 template <class _Expr>
1962 inline _LIBCPP_INLINE_VISIBILITY
1965 __is_val_expr<_Expr>::value,
1968 mask_array<_Tp>::operator%=(const _Expr& __v) const
1970 size_t __n = __1d_.size();
1971 for (size_t __i = 0; __i < __n; ++__i)
1972 __vp_[__1d_[__i]] %= __v[__i];
1975 template <class _Tp>
1976 template <class _Expr>
1977 inline _LIBCPP_INLINE_VISIBILITY
1980 __is_val_expr<_Expr>::value,
1983 mask_array<_Tp>::operator+=(const _Expr& __v) const
1985 size_t __n = __1d_.size();
1986 for (size_t __i = 0; __i < __n; ++__i)
1987 __vp_[__1d_[__i]] += __v[__i];
1990 template <class _Tp>
1991 template <class _Expr>
1992 inline _LIBCPP_INLINE_VISIBILITY
1995 __is_val_expr<_Expr>::value,
1998 mask_array<_Tp>::operator-=(const _Expr& __v) const
2000 size_t __n = __1d_.size();
2001 for (size_t __i = 0; __i < __n; ++__i)
2002 __vp_[__1d_[__i]] -= __v[__i];
2005 template <class _Tp>
2006 template <class _Expr>
2007 inline _LIBCPP_INLINE_VISIBILITY
2010 __is_val_expr<_Expr>::value,
2013 mask_array<_Tp>::operator^=(const _Expr& __v) const
2015 size_t __n = __1d_.size();
2016 for (size_t __i = 0; __i < __n; ++__i)
2017 __vp_[__1d_[__i]] ^= __v[__i];
2020 template <class _Tp>
2021 template <class _Expr>
2022 inline _LIBCPP_INLINE_VISIBILITY
2025 __is_val_expr<_Expr>::value,
2028 mask_array<_Tp>::operator&=(const _Expr& __v) const
2030 size_t __n = __1d_.size();
2031 for (size_t __i = 0; __i < __n; ++__i)
2032 __vp_[__1d_[__i]] &= __v[__i];
2035 template <class _Tp>
2036 template <class _Expr>
2037 inline _LIBCPP_INLINE_VISIBILITY
2040 __is_val_expr<_Expr>::value,
2043 mask_array<_Tp>::operator|=(const _Expr& __v) const
2045 size_t __n = __1d_.size();
2046 for (size_t __i = 0; __i < __n; ++__i)
2047 __vp_[__1d_[__i]] |= __v[__i];
2050 template <class _Tp>
2051 template <class _Expr>
2052 inline _LIBCPP_INLINE_VISIBILITY
2055 __is_val_expr<_Expr>::value,
2058 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2060 size_t __n = __1d_.size();
2061 for (size_t __i = 0; __i < __n; ++__i)
2062 __vp_[__1d_[__i]] <<= __v[__i];
2065 template <class _Tp>
2066 template <class _Expr>
2067 inline _LIBCPP_INLINE_VISIBILITY
2070 __is_val_expr<_Expr>::value,
2073 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2075 size_t __n = __1d_.size();
2076 for (size_t __i = 0; __i < __n; ++__i)
2077 __vp_[__1d_[__i]] >>= __v[__i];
2080 template <class _Tp>
2081 inline _LIBCPP_INLINE_VISIBILITY
2082 const mask_array<_Tp>&
2083 mask_array<_Tp>::operator=(const mask_array& __ma) const
2085 size_t __n = __1d_.size();
2086 for (size_t __i = 0; __i < __n; ++__i)
2087 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2090 template <class _Tp>
2091 inline _LIBCPP_INLINE_VISIBILITY
2093 mask_array<_Tp>::operator=(const value_type& __x) const
2095 size_t __n = __1d_.size();
2096 for (size_t __i = 0; __i < __n; ++__i)
2097 __vp_[__1d_[__i]] = __x;
2100 template <class _ValExpr>
2103 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2105 typedef typename _RmExpr::value_type value_type;
2106 typedef value_type result_type;
2110 valarray<size_t> __1d_;
2112 _LIBCPP_INLINE_VISIBILITY
2113 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2115 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2118 for (size_t __i = 0; __i < __vb.size(); ++__i)
2124 _LIBCPP_INLINE_VISIBILITY
2125 result_type operator[](size_t __i) const
2126 {return __expr_[__1d_[__i]];}
2128 _LIBCPP_INLINE_VISIBILITY
2129 size_t size() const {return __1d_.size();}
2131 template <class> friend class valarray;
2136 template <class _Tp>
2137 class _LIBCPP_TYPE_VIS indirect_array
2140 typedef _Tp value_type;
2144 valarray<size_t> __1d_;
2147 template <class _Expr>
2150 __is_val_expr<_Expr>::value,
2153 operator=(const _Expr& __v) const;
2155 template <class _Expr>
2158 __is_val_expr<_Expr>::value,
2161 operator*=(const _Expr& __v) const;
2163 template <class _Expr>
2166 __is_val_expr<_Expr>::value,
2169 operator/=(const _Expr& __v) const;
2171 template <class _Expr>
2174 __is_val_expr<_Expr>::value,
2177 operator%=(const _Expr& __v) const;
2179 template <class _Expr>
2182 __is_val_expr<_Expr>::value,
2185 operator+=(const _Expr& __v) const;
2187 template <class _Expr>
2190 __is_val_expr<_Expr>::value,
2193 operator-=(const _Expr& __v) const;
2195 template <class _Expr>
2198 __is_val_expr<_Expr>::value,
2201 operator^=(const _Expr& __v) const;
2203 template <class _Expr>
2206 __is_val_expr<_Expr>::value,
2209 operator&=(const _Expr& __v) const;
2211 template <class _Expr>
2214 __is_val_expr<_Expr>::value,
2217 operator|=(const _Expr& __v) const;
2219 template <class _Expr>
2222 __is_val_expr<_Expr>::value,
2225 operator<<=(const _Expr& __v) const;
2227 template <class _Expr>
2230 __is_val_expr<_Expr>::value,
2233 operator>>=(const _Expr& __v) const;
2235 const indirect_array& operator=(const indirect_array& __ia) const;
2237 void operator=(const value_type& __x) const;
2239 // indirect_array(const indirect_array&) = default;
2240 // indirect_array(indirect_array&&) = default;
2241 // indirect_array& operator=(const indirect_array&) = default;
2242 // indirect_array& operator=(indirect_array&&) = default;
2245 _LIBCPP_INLINE_VISIBILITY
2246 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2247 : __vp_(const_cast<value_type*>(__v.__begin_)),
2251 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2253 _LIBCPP_INLINE_VISIBILITY
2254 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2255 : __vp_(const_cast<value_type*>(__v.__begin_)),
2259 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2261 template <class> friend class valarray;
2264 template <class _Tp>
2265 template <class _Expr>
2266 inline _LIBCPP_INLINE_VISIBILITY
2269 __is_val_expr<_Expr>::value,
2272 indirect_array<_Tp>::operator=(const _Expr& __v) const
2274 size_t __n = __1d_.size();
2275 for (size_t __i = 0; __i < __n; ++__i)
2276 __vp_[__1d_[__i]] = __v[__i];
2279 template <class _Tp>
2280 template <class _Expr>
2281 inline _LIBCPP_INLINE_VISIBILITY
2284 __is_val_expr<_Expr>::value,
2287 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2289 size_t __n = __1d_.size();
2290 for (size_t __i = 0; __i < __n; ++__i)
2291 __vp_[__1d_[__i]] *= __v[__i];
2294 template <class _Tp>
2295 template <class _Expr>
2296 inline _LIBCPP_INLINE_VISIBILITY
2299 __is_val_expr<_Expr>::value,
2302 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2304 size_t __n = __1d_.size();
2305 for (size_t __i = 0; __i < __n; ++__i)
2306 __vp_[__1d_[__i]] /= __v[__i];
2309 template <class _Tp>
2310 template <class _Expr>
2311 inline _LIBCPP_INLINE_VISIBILITY
2314 __is_val_expr<_Expr>::value,
2317 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2319 size_t __n = __1d_.size();
2320 for (size_t __i = 0; __i < __n; ++__i)
2321 __vp_[__1d_[__i]] %= __v[__i];
2324 template <class _Tp>
2325 template <class _Expr>
2326 inline _LIBCPP_INLINE_VISIBILITY
2329 __is_val_expr<_Expr>::value,
2332 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2334 size_t __n = __1d_.size();
2335 for (size_t __i = 0; __i < __n; ++__i)
2336 __vp_[__1d_[__i]] += __v[__i];
2339 template <class _Tp>
2340 template <class _Expr>
2341 inline _LIBCPP_INLINE_VISIBILITY
2344 __is_val_expr<_Expr>::value,
2347 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2349 size_t __n = __1d_.size();
2350 for (size_t __i = 0; __i < __n; ++__i)
2351 __vp_[__1d_[__i]] -= __v[__i];
2354 template <class _Tp>
2355 template <class _Expr>
2356 inline _LIBCPP_INLINE_VISIBILITY
2359 __is_val_expr<_Expr>::value,
2362 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2364 size_t __n = __1d_.size();
2365 for (size_t __i = 0; __i < __n; ++__i)
2366 __vp_[__1d_[__i]] ^= __v[__i];
2369 template <class _Tp>
2370 template <class _Expr>
2371 inline _LIBCPP_INLINE_VISIBILITY
2374 __is_val_expr<_Expr>::value,
2377 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2379 size_t __n = __1d_.size();
2380 for (size_t __i = 0; __i < __n; ++__i)
2381 __vp_[__1d_[__i]] &= __v[__i];
2384 template <class _Tp>
2385 template <class _Expr>
2386 inline _LIBCPP_INLINE_VISIBILITY
2389 __is_val_expr<_Expr>::value,
2392 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2394 size_t __n = __1d_.size();
2395 for (size_t __i = 0; __i < __n; ++__i)
2396 __vp_[__1d_[__i]] |= __v[__i];
2399 template <class _Tp>
2400 template <class _Expr>
2401 inline _LIBCPP_INLINE_VISIBILITY
2404 __is_val_expr<_Expr>::value,
2407 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2409 size_t __n = __1d_.size();
2410 for (size_t __i = 0; __i < __n; ++__i)
2411 __vp_[__1d_[__i]] <<= __v[__i];
2414 template <class _Tp>
2415 template <class _Expr>
2416 inline _LIBCPP_INLINE_VISIBILITY
2419 __is_val_expr<_Expr>::value,
2422 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2424 size_t __n = __1d_.size();
2425 for (size_t __i = 0; __i < __n; ++__i)
2426 __vp_[__1d_[__i]] >>= __v[__i];
2429 template <class _Tp>
2430 inline _LIBCPP_INLINE_VISIBILITY
2431 const indirect_array<_Tp>&
2432 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2434 typedef const size_t* _Ip;
2435 const value_type* __s = __ia.__vp_;
2436 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2437 __i != __e; ++__i, ++__j)
2438 __vp_[*__i] = __s[*__j];
2442 template <class _Tp>
2443 inline _LIBCPP_INLINE_VISIBILITY
2445 indirect_array<_Tp>::operator=(const value_type& __x) const
2447 typedef const size_t* _Ip;
2448 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2452 template <class _ValExpr>
2453 class __indirect_expr
2455 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2457 typedef typename _RmExpr::value_type value_type;
2458 typedef value_type result_type;
2462 valarray<size_t> __1d_;
2464 _LIBCPP_INLINE_VISIBILITY
2465 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2470 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2472 _LIBCPP_INLINE_VISIBILITY
2473 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2478 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2481 _LIBCPP_INLINE_VISIBILITY
2482 result_type operator[](size_t __i) const
2483 {return __expr_[__1d_[__i]];}
2485 _LIBCPP_INLINE_VISIBILITY
2486 size_t size() const {return __1d_.size();}
2488 template <class> friend class _LIBCPP_TYPE_VIS valarray;
2491 template<class _ValExpr>
2494 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2498 typedef typename _RmExpr::value_type value_type;
2499 typedef typename _RmExpr::result_type result_type;
2501 _LIBCPP_INLINE_VISIBILITY
2502 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2504 _LIBCPP_INLINE_VISIBILITY
2505 result_type operator[](size_t __i) const
2506 {return __expr_[__i];}
2508 _LIBCPP_INLINE_VISIBILITY
2509 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2510 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2512 _LIBCPP_INLINE_VISIBILITY
2513 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2514 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2516 _LIBCPP_INLINE_VISIBILITY
2517 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2518 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2520 _LIBCPP_INLINE_VISIBILITY
2521 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2522 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2524 _LIBCPP_INLINE_VISIBILITY
2525 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2528 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2529 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2532 _LIBCPP_INLINE_VISIBILITY
2533 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2536 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2537 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2540 _LIBCPP_INLINE_VISIBILITY
2541 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2544 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2545 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2548 _LIBCPP_INLINE_VISIBILITY
2549 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2552 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2553 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2556 operator valarray<result_type>() const;
2558 _LIBCPP_INLINE_VISIBILITY
2559 size_t size() const {return __expr_.size();}
2561 _LIBCPP_INLINE_VISIBILITY
2562 result_type sum() const
2564 size_t __n = __expr_.size();
2565 result_type __r = __n ? __expr_[0] : result_type();
2566 for (size_t __i = 1; __i < __n; ++__i)
2567 __r += __expr_[__i];
2571 _LIBCPP_INLINE_VISIBILITY
2572 result_type min() const
2574 size_t __n = size();
2575 result_type __r = __n ? (*this)[0] : result_type();
2576 for (size_t __i = 1; __i < __n; ++__i)
2578 result_type __x = __expr_[__i];
2585 _LIBCPP_INLINE_VISIBILITY
2586 result_type max() const
2588 size_t __n = size();
2589 result_type __r = __n ? (*this)[0] : result_type();
2590 for (size_t __i = 1; __i < __n; ++__i)
2592 result_type __x = __expr_[__i];
2599 _LIBCPP_INLINE_VISIBILITY
2600 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2601 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2603 _LIBCPP_INLINE_VISIBILITY
2604 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2605 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2607 _LIBCPP_INLINE_VISIBILITY
2608 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2609 apply(value_type __f(value_type)) const
2611 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2612 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2613 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2616 _LIBCPP_INLINE_VISIBILITY
2617 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2618 apply(value_type __f(const value_type&)) const
2620 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2621 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2622 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2626 template<class _ValExpr>
2627 __val_expr<_ValExpr>::operator valarray<result_type>() const
2629 valarray<result_type> __r;
2630 size_t __n = __expr_.size();
2635 static_cast<result_type*>(::operator new(__n * sizeof(result_type)));
2636 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2637 ::new (__r.__end_) result_type(__expr_[__i]);
2644 template <class _Tp>
2645 inline _LIBCPP_INLINE_VISIBILITY
2646 valarray<_Tp>::valarray(size_t __n)
2653 template <class _Tp>
2654 inline _LIBCPP_INLINE_VISIBILITY
2655 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2662 template <class _Tp>
2663 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2669 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2670 #ifndef _LIBCPP_NO_EXCEPTIONS
2673 #endif // _LIBCPP_NO_EXCEPTIONS
2674 for (; __n; ++__end_, ++__p, --__n)
2675 ::new (__end_) value_type(*__p);
2676 #ifndef _LIBCPP_NO_EXCEPTIONS
2683 #endif // _LIBCPP_NO_EXCEPTIONS
2687 template <class _Tp>
2688 valarray<_Tp>::valarray(const valarray& __v)
2694 __begin_ = __end_ = static_cast<value_type*>(::operator new(__v.size() * sizeof(value_type)));
2695 #ifndef _LIBCPP_NO_EXCEPTIONS
2698 #endif // _LIBCPP_NO_EXCEPTIONS
2699 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2700 ::new (__end_) value_type(*__p);
2701 #ifndef _LIBCPP_NO_EXCEPTIONS
2708 #endif // _LIBCPP_NO_EXCEPTIONS
2712 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2714 template <class _Tp>
2715 inline _LIBCPP_INLINE_VISIBILITY
2716 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2717 : __begin_(__v.__begin_),
2720 __v.__begin_ = __v.__end_ = nullptr;
2723 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2725 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2727 template <class _Tp>
2728 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2732 size_t __n = __il.size();
2735 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2736 #ifndef _LIBCPP_NO_EXCEPTIONS
2739 #endif // _LIBCPP_NO_EXCEPTIONS
2740 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2741 ::new (__end_) value_type(*__p);
2742 #ifndef _LIBCPP_NO_EXCEPTIONS
2749 #endif // _LIBCPP_NO_EXCEPTIONS
2753 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2755 template <class _Tp>
2756 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2760 size_t __n = __sa.__size_;
2763 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2764 #ifndef _LIBCPP_NO_EXCEPTIONS
2767 #endif // _LIBCPP_NO_EXCEPTIONS
2768 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2769 ::new (__end_) value_type(*__p);
2770 #ifndef _LIBCPP_NO_EXCEPTIONS
2777 #endif // _LIBCPP_NO_EXCEPTIONS
2781 template <class _Tp>
2782 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2786 size_t __n = __ga.__1d_.size();
2789 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2790 #ifndef _LIBCPP_NO_EXCEPTIONS
2793 #endif // _LIBCPP_NO_EXCEPTIONS
2794 typedef const size_t* _Ip;
2795 const value_type* __s = __ga.__vp_;
2796 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2797 __i != __e; ++__i, ++__end_)
2798 ::new (__end_) value_type(__s[*__i]);
2799 #ifndef _LIBCPP_NO_EXCEPTIONS
2806 #endif // _LIBCPP_NO_EXCEPTIONS
2810 template <class _Tp>
2811 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2815 size_t __n = __ma.__1d_.size();
2818 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2819 #ifndef _LIBCPP_NO_EXCEPTIONS
2822 #endif // _LIBCPP_NO_EXCEPTIONS
2823 typedef const size_t* _Ip;
2824 const value_type* __s = __ma.__vp_;
2825 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2826 __i != __e; ++__i, ++__end_)
2827 ::new (__end_) value_type(__s[*__i]);
2828 #ifndef _LIBCPP_NO_EXCEPTIONS
2835 #endif // _LIBCPP_NO_EXCEPTIONS
2839 template <class _Tp>
2840 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2844 size_t __n = __ia.__1d_.size();
2847 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2848 #ifndef _LIBCPP_NO_EXCEPTIONS
2851 #endif // _LIBCPP_NO_EXCEPTIONS
2852 typedef const size_t* _Ip;
2853 const value_type* __s = __ia.__vp_;
2854 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2855 __i != __e; ++__i, ++__end_)
2856 ::new (__end_) value_type(__s[*__i]);
2857 #ifndef _LIBCPP_NO_EXCEPTIONS
2864 #endif // _LIBCPP_NO_EXCEPTIONS
2868 template <class _Tp>
2869 inline _LIBCPP_INLINE_VISIBILITY
2870 valarray<_Tp>::~valarray()
2875 template <class _Tp>
2877 valarray<_Tp>::operator=(const valarray& __v)
2881 if (size() != __v.size())
2883 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
2888 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2890 template <class _Tp>
2891 inline _LIBCPP_INLINE_VISIBILITY
2893 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
2896 __begin_ = __v.__begin_;
2897 __end_ = __v.__end_;
2898 __v.__begin_ = nullptr;
2899 __v.__end_ = nullptr;
2903 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2905 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2907 template <class _Tp>
2908 inline _LIBCPP_INLINE_VISIBILITY
2910 valarray<_Tp>::operator=(initializer_list<value_type> __il)
2912 if (size() != __il.size())
2913 resize(__il.size());
2914 _VSTD::copy(__il.begin(), __il.end(), __begin_);
2918 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2920 template <class _Tp>
2921 inline _LIBCPP_INLINE_VISIBILITY
2923 valarray<_Tp>::operator=(const value_type& __x)
2925 _VSTD::fill(__begin_, __end_, __x);
2929 template <class _Tp>
2930 inline _LIBCPP_INLINE_VISIBILITY
2932 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
2934 value_type* __t = __begin_;
2935 const value_type* __s = __sa.__vp_;
2936 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2941 template <class _Tp>
2942 inline _LIBCPP_INLINE_VISIBILITY
2944 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
2946 typedef const size_t* _Ip;
2947 value_type* __t = __begin_;
2948 const value_type* __s = __ga.__vp_;
2949 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2950 __i != __e; ++__i, ++__t)
2955 template <class _Tp>
2956 inline _LIBCPP_INLINE_VISIBILITY
2958 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
2960 typedef const size_t* _Ip;
2961 value_type* __t = __begin_;
2962 const value_type* __s = __ma.__vp_;
2963 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2964 __i != __e; ++__i, ++__t)
2969 template <class _Tp>
2970 inline _LIBCPP_INLINE_VISIBILITY
2972 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
2974 typedef const size_t* _Ip;
2975 value_type* __t = __begin_;
2976 const value_type* __s = __ia.__vp_;
2977 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2978 __i != __e; ++__i, ++__t)
2983 template <class _Tp>
2984 template <class _ValExpr>
2985 inline _LIBCPP_INLINE_VISIBILITY
2987 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
2989 size_t __n = __v.size();
2992 value_type* __t = __begin_;
2993 for (size_t __i = 0; __i != __n; ++__t, ++__i)
2994 *__t = result_type(__v[__i]);
2998 template <class _Tp>
2999 inline _LIBCPP_INLINE_VISIBILITY
3000 __val_expr<__slice_expr<const valarray<_Tp>&> >
3001 valarray<_Tp>::operator[](slice __s) const
3003 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3006 template <class _Tp>
3007 inline _LIBCPP_INLINE_VISIBILITY
3009 valarray<_Tp>::operator[](slice __s)
3011 return slice_array<value_type>(__s, *this);
3014 template <class _Tp>
3015 inline _LIBCPP_INLINE_VISIBILITY
3016 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3017 valarray<_Tp>::operator[](const gslice& __gs) const
3019 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3022 template <class _Tp>
3023 inline _LIBCPP_INLINE_VISIBILITY
3025 valarray<_Tp>::operator[](const gslice& __gs)
3027 return gslice_array<value_type>(__gs, *this);
3030 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3032 template <class _Tp>
3033 inline _LIBCPP_INLINE_VISIBILITY
3034 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3035 valarray<_Tp>::operator[](gslice&& __gs) const
3037 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3040 template <class _Tp>
3041 inline _LIBCPP_INLINE_VISIBILITY
3043 valarray<_Tp>::operator[](gslice&& __gs)
3045 return gslice_array<value_type>(move(__gs), *this);
3048 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3050 template <class _Tp>
3051 inline _LIBCPP_INLINE_VISIBILITY
3052 __val_expr<__mask_expr<const valarray<_Tp>&> >
3053 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3055 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3058 template <class _Tp>
3059 inline _LIBCPP_INLINE_VISIBILITY
3061 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3063 return mask_array<value_type>(__vb, *this);
3066 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3068 template <class _Tp>
3069 inline _LIBCPP_INLINE_VISIBILITY
3070 __val_expr<__mask_expr<const valarray<_Tp>&> >
3071 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3073 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3076 template <class _Tp>
3077 inline _LIBCPP_INLINE_VISIBILITY
3079 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3081 return mask_array<value_type>(move(__vb), *this);
3084 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3086 template <class _Tp>
3087 inline _LIBCPP_INLINE_VISIBILITY
3088 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3089 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3091 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3094 template <class _Tp>
3095 inline _LIBCPP_INLINE_VISIBILITY
3097 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3099 return indirect_array<value_type>(__vs, *this);
3102 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3104 template <class _Tp>
3105 inline _LIBCPP_INLINE_VISIBILITY
3106 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3107 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3109 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3112 template <class _Tp>
3113 inline _LIBCPP_INLINE_VISIBILITY
3115 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3117 return indirect_array<value_type>(move(__vs), *this);
3120 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3122 template <class _Tp>
3124 valarray<_Tp>::operator+() const
3126 valarray<value_type> __r;
3127 size_t __n = size();
3132 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3133 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3134 ::new (__r.__end_) value_type(+*__p);
3139 template <class _Tp>
3141 valarray<_Tp>::operator-() const
3143 valarray<value_type> __r;
3144 size_t __n = size();
3149 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3150 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3151 ::new (__r.__end_) value_type(-*__p);
3156 template <class _Tp>
3158 valarray<_Tp>::operator~() const
3160 valarray<value_type> __r;
3161 size_t __n = size();
3166 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3167 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3168 ::new (__r.__end_) value_type(~*__p);
3173 template <class _Tp>
3175 valarray<_Tp>::operator!() const
3178 size_t __n = size();
3183 static_cast<bool*>(::operator new(__n * sizeof(bool)));
3184 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3185 ::new (__r.__end_) bool(!*__p);
3190 template <class _Tp>
3191 inline _LIBCPP_INLINE_VISIBILITY
3193 valarray<_Tp>::operator*=(const value_type& __x)
3195 for (value_type* __p = __begin_; __p != __end_; ++__p)
3200 template <class _Tp>
3201 inline _LIBCPP_INLINE_VISIBILITY
3203 valarray<_Tp>::operator/=(const value_type& __x)
3205 for (value_type* __p = __begin_; __p != __end_; ++__p)
3210 template <class _Tp>
3211 inline _LIBCPP_INLINE_VISIBILITY
3213 valarray<_Tp>::operator%=(const value_type& __x)
3215 for (value_type* __p = __begin_; __p != __end_; ++__p)
3220 template <class _Tp>
3221 inline _LIBCPP_INLINE_VISIBILITY
3223 valarray<_Tp>::operator+=(const value_type& __x)
3225 for (value_type* __p = __begin_; __p != __end_; ++__p)
3230 template <class _Tp>
3231 inline _LIBCPP_INLINE_VISIBILITY
3233 valarray<_Tp>::operator-=(const value_type& __x)
3235 for (value_type* __p = __begin_; __p != __end_; ++__p)
3240 template <class _Tp>
3241 inline _LIBCPP_INLINE_VISIBILITY
3243 valarray<_Tp>::operator^=(const value_type& __x)
3245 for (value_type* __p = __begin_; __p != __end_; ++__p)
3250 template <class _Tp>
3251 inline _LIBCPP_INLINE_VISIBILITY
3253 valarray<_Tp>::operator&=(const value_type& __x)
3255 for (value_type* __p = __begin_; __p != __end_; ++__p)
3260 template <class _Tp>
3261 inline _LIBCPP_INLINE_VISIBILITY
3263 valarray<_Tp>::operator|=(const value_type& __x)
3265 for (value_type* __p = __begin_; __p != __end_; ++__p)
3270 template <class _Tp>
3271 inline _LIBCPP_INLINE_VISIBILITY
3273 valarray<_Tp>::operator<<=(const value_type& __x)
3275 for (value_type* __p = __begin_; __p != __end_; ++__p)
3280 template <class _Tp>
3281 inline _LIBCPP_INLINE_VISIBILITY
3283 valarray<_Tp>::operator>>=(const value_type& __x)
3285 for (value_type* __p = __begin_; __p != __end_; ++__p)
3290 template <class _Tp>
3291 template <class _Expr>
3292 inline _LIBCPP_INLINE_VISIBILITY
3295 __is_val_expr<_Expr>::value,
3298 valarray<_Tp>::operator*=(const _Expr& __v)
3301 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3306 template <class _Tp>
3307 template <class _Expr>
3308 inline _LIBCPP_INLINE_VISIBILITY
3311 __is_val_expr<_Expr>::value,
3314 valarray<_Tp>::operator/=(const _Expr& __v)
3317 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3322 template <class _Tp>
3323 template <class _Expr>
3324 inline _LIBCPP_INLINE_VISIBILITY
3327 __is_val_expr<_Expr>::value,
3330 valarray<_Tp>::operator%=(const _Expr& __v)
3333 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3338 template <class _Tp>
3339 template <class _Expr>
3340 inline _LIBCPP_INLINE_VISIBILITY
3343 __is_val_expr<_Expr>::value,
3346 valarray<_Tp>::operator+=(const _Expr& __v)
3349 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3354 template <class _Tp>
3355 template <class _Expr>
3356 inline _LIBCPP_INLINE_VISIBILITY
3359 __is_val_expr<_Expr>::value,
3362 valarray<_Tp>::operator-=(const _Expr& __v)
3365 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3370 template <class _Tp>
3371 template <class _Expr>
3372 inline _LIBCPP_INLINE_VISIBILITY
3375 __is_val_expr<_Expr>::value,
3378 valarray<_Tp>::operator^=(const _Expr& __v)
3381 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3386 template <class _Tp>
3387 template <class _Expr>
3388 inline _LIBCPP_INLINE_VISIBILITY
3391 __is_val_expr<_Expr>::value,
3394 valarray<_Tp>::operator|=(const _Expr& __v)
3397 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3402 template <class _Tp>
3403 template <class _Expr>
3404 inline _LIBCPP_INLINE_VISIBILITY
3407 __is_val_expr<_Expr>::value,
3410 valarray<_Tp>::operator&=(const _Expr& __v)
3413 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3418 template <class _Tp>
3419 template <class _Expr>
3420 inline _LIBCPP_INLINE_VISIBILITY
3423 __is_val_expr<_Expr>::value,
3426 valarray<_Tp>::operator<<=(const _Expr& __v)
3429 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3434 template <class _Tp>
3435 template <class _Expr>
3436 inline _LIBCPP_INLINE_VISIBILITY
3439 __is_val_expr<_Expr>::value,
3442 valarray<_Tp>::operator>>=(const _Expr& __v)
3445 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3450 template <class _Tp>
3451 inline _LIBCPP_INLINE_VISIBILITY
3453 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3455 _VSTD::swap(__begin_, __v.__begin_);
3456 _VSTD::swap(__end_, __v.__end_);
3459 template <class _Tp>
3460 inline _LIBCPP_INLINE_VISIBILITY
3462 valarray<_Tp>::sum() const
3464 if (__begin_ == __end_)
3465 return value_type();
3466 const value_type* __p = __begin_;
3468 for (++__p; __p != __end_; ++__p)
3473 template <class _Tp>
3474 inline _LIBCPP_INLINE_VISIBILITY
3476 valarray<_Tp>::min() const
3478 if (__begin_ == __end_)
3479 return value_type();
3480 return *_VSTD::min_element(__begin_, __end_);
3483 template <class _Tp>
3484 inline _LIBCPP_INLINE_VISIBILITY
3486 valarray<_Tp>::max() const
3488 if (__begin_ == __end_)
3489 return value_type();
3490 return *_VSTD::max_element(__begin_, __end_);
3493 template <class _Tp>
3495 valarray<_Tp>::shift(int __i) const
3497 valarray<value_type> __r;
3498 size_t __n = size();
3503 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3504 const value_type* __sb;
3509 __i = _VSTD::min(__i, static_cast<int>(__n));
3510 __sb = __begin_ + __i;
3511 __tb = __r.__begin_;
3512 __te = __r.__begin_ + (__n - __i);
3516 __i = _VSTD::min(-__i, static_cast<int>(__n));
3518 __tb = __r.__begin_ + __i;
3519 __te = __r.__begin_ + __n;
3521 for (; __r.__end_ != __tb; ++__r.__end_)
3522 ::new (__r.__end_) value_type();
3523 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3524 ::new (__r.__end_) value_type(*__sb);
3525 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3526 ::new (__r.__end_) value_type();
3531 template <class _Tp>
3533 valarray<_Tp>::cshift(int __i) const
3535 valarray<value_type> __r;
3536 size_t __n = size();
3541 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3542 __i %= static_cast<int>(__n);
3543 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3544 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3545 ::new (__r.__end_) value_type(*__s);
3546 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3547 ::new (__r.__end_) value_type(*__s);
3552 template <class _Tp>
3554 valarray<_Tp>::apply(value_type __f(value_type)) const
3556 valarray<value_type> __r;
3557 size_t __n = size();
3562 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3563 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3564 ::new (__r.__end_) value_type(__f(*__p));
3569 template <class _Tp>
3571 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3573 valarray<value_type> __r;
3574 size_t __n = size();
3579 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3580 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3581 ::new (__r.__end_) value_type(__f(*__p));
3586 template <class _Tp>
3588 valarray<_Tp>::resize(size_t __n, value_type __x)
3590 if (__begin_ != nullptr)
3592 while (__end_ != __begin_)
3593 (--__end_)->~value_type();
3594 ::operator delete(__begin_);
3595 __begin_ = __end_ = nullptr;
3599 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3600 #ifndef _LIBCPP_NO_EXCEPTIONS
3603 #endif // _LIBCPP_NO_EXCEPTIONS
3604 for (; __n; --__n, ++__end_)
3605 ::new (__end_) value_type(__x);
3606 #ifndef _LIBCPP_NO_EXCEPTIONS
3613 #endif // _LIBCPP_NO_EXCEPTIONS
3618 inline _LIBCPP_INLINE_VISIBILITY
3620 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3625 template<class _Expr1, class _Expr2>
3626 inline _LIBCPP_INLINE_VISIBILITY
3629 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3630 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3632 operator*(const _Expr1& __x, const _Expr2& __y)
3634 typedef typename _Expr1::value_type value_type;
3635 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3636 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3639 template<class _Expr>
3640 inline _LIBCPP_INLINE_VISIBILITY
3643 __is_val_expr<_Expr>::value,
3644 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3645 _Expr, __scalar_expr<typename _Expr::value_type> > >
3647 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3649 typedef typename _Expr::value_type value_type;
3650 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3651 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3652 __x, __scalar_expr<value_type>(__y, __x.size())));
3655 template<class _Expr>
3656 inline _LIBCPP_INLINE_VISIBILITY
3659 __is_val_expr<_Expr>::value,
3660 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3661 __scalar_expr<typename _Expr::value_type>, _Expr> >
3663 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3665 typedef typename _Expr::value_type value_type;
3666 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3667 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3668 __scalar_expr<value_type>(__x, __y.size()), __y));
3671 template<class _Expr1, class _Expr2>
3672 inline _LIBCPP_INLINE_VISIBILITY
3675 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3676 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3678 operator/(const _Expr1& __x, const _Expr2& __y)
3680 typedef typename _Expr1::value_type value_type;
3681 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3682 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3685 template<class _Expr>
3686 inline _LIBCPP_INLINE_VISIBILITY
3689 __is_val_expr<_Expr>::value,
3690 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3691 _Expr, __scalar_expr<typename _Expr::value_type> > >
3693 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3695 typedef typename _Expr::value_type value_type;
3696 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3697 return __val_expr<_Op>(_Op(divides<value_type>(),
3698 __x, __scalar_expr<value_type>(__y, __x.size())));
3701 template<class _Expr>
3702 inline _LIBCPP_INLINE_VISIBILITY
3705 __is_val_expr<_Expr>::value,
3706 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3707 __scalar_expr<typename _Expr::value_type>, _Expr> >
3709 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3711 typedef typename _Expr::value_type value_type;
3712 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3713 return __val_expr<_Op>(_Op(divides<value_type>(),
3714 __scalar_expr<value_type>(__x, __y.size()), __y));
3717 template<class _Expr1, class _Expr2>
3718 inline _LIBCPP_INLINE_VISIBILITY
3721 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3722 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3724 operator%(const _Expr1& __x, const _Expr2& __y)
3726 typedef typename _Expr1::value_type value_type;
3727 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3728 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3731 template<class _Expr>
3732 inline _LIBCPP_INLINE_VISIBILITY
3735 __is_val_expr<_Expr>::value,
3736 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3737 _Expr, __scalar_expr<typename _Expr::value_type> > >
3739 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3741 typedef typename _Expr::value_type value_type;
3742 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3743 return __val_expr<_Op>(_Op(modulus<value_type>(),
3744 __x, __scalar_expr<value_type>(__y, __x.size())));
3747 template<class _Expr>
3748 inline _LIBCPP_INLINE_VISIBILITY
3751 __is_val_expr<_Expr>::value,
3752 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3753 __scalar_expr<typename _Expr::value_type>, _Expr> >
3755 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3757 typedef typename _Expr::value_type value_type;
3758 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3759 return __val_expr<_Op>(_Op(modulus<value_type>(),
3760 __scalar_expr<value_type>(__x, __y.size()), __y));
3763 template<class _Expr1, class _Expr2>
3764 inline _LIBCPP_INLINE_VISIBILITY
3767 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3768 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3770 operator+(const _Expr1& __x, const _Expr2& __y)
3772 typedef typename _Expr1::value_type value_type;
3773 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3774 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3777 template<class _Expr>
3778 inline _LIBCPP_INLINE_VISIBILITY
3781 __is_val_expr<_Expr>::value,
3782 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3783 _Expr, __scalar_expr<typename _Expr::value_type> > >
3785 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3787 typedef typename _Expr::value_type value_type;
3788 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3789 return __val_expr<_Op>(_Op(plus<value_type>(),
3790 __x, __scalar_expr<value_type>(__y, __x.size())));
3793 template<class _Expr>
3794 inline _LIBCPP_INLINE_VISIBILITY
3797 __is_val_expr<_Expr>::value,
3798 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3799 __scalar_expr<typename _Expr::value_type>, _Expr> >
3801 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3803 typedef typename _Expr::value_type value_type;
3804 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3805 return __val_expr<_Op>(_Op(plus<value_type>(),
3806 __scalar_expr<value_type>(__x, __y.size()), __y));
3809 template<class _Expr1, class _Expr2>
3810 inline _LIBCPP_INLINE_VISIBILITY
3813 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3814 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3816 operator-(const _Expr1& __x, const _Expr2& __y)
3818 typedef typename _Expr1::value_type value_type;
3819 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3820 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3823 template<class _Expr>
3824 inline _LIBCPP_INLINE_VISIBILITY
3827 __is_val_expr<_Expr>::value,
3828 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3829 _Expr, __scalar_expr<typename _Expr::value_type> > >
3831 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3833 typedef typename _Expr::value_type value_type;
3834 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3835 return __val_expr<_Op>(_Op(minus<value_type>(),
3836 __x, __scalar_expr<value_type>(__y, __x.size())));
3839 template<class _Expr>
3840 inline _LIBCPP_INLINE_VISIBILITY
3843 __is_val_expr<_Expr>::value,
3844 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3845 __scalar_expr<typename _Expr::value_type>, _Expr> >
3847 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3849 typedef typename _Expr::value_type value_type;
3850 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3851 return __val_expr<_Op>(_Op(minus<value_type>(),
3852 __scalar_expr<value_type>(__x, __y.size()), __y));
3855 template<class _Expr1, class _Expr2>
3856 inline _LIBCPP_INLINE_VISIBILITY
3859 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3860 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3862 operator^(const _Expr1& __x, const _Expr2& __y)
3864 typedef typename _Expr1::value_type value_type;
3865 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3866 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3869 template<class _Expr>
3870 inline _LIBCPP_INLINE_VISIBILITY
3873 __is_val_expr<_Expr>::value,
3874 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3875 _Expr, __scalar_expr<typename _Expr::value_type> > >
3877 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3879 typedef typename _Expr::value_type value_type;
3880 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3881 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3882 __x, __scalar_expr<value_type>(__y, __x.size())));
3885 template<class _Expr>
3886 inline _LIBCPP_INLINE_VISIBILITY
3889 __is_val_expr<_Expr>::value,
3890 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3891 __scalar_expr<typename _Expr::value_type>, _Expr> >
3893 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3895 typedef typename _Expr::value_type value_type;
3896 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3897 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3898 __scalar_expr<value_type>(__x, __y.size()), __y));
3901 template<class _Expr1, class _Expr2>
3902 inline _LIBCPP_INLINE_VISIBILITY
3905 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3906 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
3908 operator&(const _Expr1& __x, const _Expr2& __y)
3910 typedef typename _Expr1::value_type value_type;
3911 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
3912 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
3915 template<class _Expr>
3916 inline _LIBCPP_INLINE_VISIBILITY
3919 __is_val_expr<_Expr>::value,
3920 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3921 _Expr, __scalar_expr<typename _Expr::value_type> > >
3923 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
3925 typedef typename _Expr::value_type value_type;
3926 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3927 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3928 __x, __scalar_expr<value_type>(__y, __x.size())));
3931 template<class _Expr>
3932 inline _LIBCPP_INLINE_VISIBILITY
3935 __is_val_expr<_Expr>::value,
3936 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3937 __scalar_expr<typename _Expr::value_type>, _Expr> >
3939 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
3941 typedef typename _Expr::value_type value_type;
3942 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3943 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3944 __scalar_expr<value_type>(__x, __y.size()), __y));
3947 template<class _Expr1, class _Expr2>
3948 inline _LIBCPP_INLINE_VISIBILITY
3951 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3952 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
3954 operator|(const _Expr1& __x, const _Expr2& __y)
3956 typedef typename _Expr1::value_type value_type;
3957 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
3958 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
3961 template<class _Expr>
3962 inline _LIBCPP_INLINE_VISIBILITY
3965 __is_val_expr<_Expr>::value,
3966 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3967 _Expr, __scalar_expr<typename _Expr::value_type> > >
3969 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
3971 typedef typename _Expr::value_type value_type;
3972 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3973 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3974 __x, __scalar_expr<value_type>(__y, __x.size())));
3977 template<class _Expr>
3978 inline _LIBCPP_INLINE_VISIBILITY
3981 __is_val_expr<_Expr>::value,
3982 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3983 __scalar_expr<typename _Expr::value_type>, _Expr> >
3985 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
3987 typedef typename _Expr::value_type value_type;
3988 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3989 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3990 __scalar_expr<value_type>(__x, __y.size()), __y));
3993 template<class _Expr1, class _Expr2>
3994 inline _LIBCPP_INLINE_VISIBILITY
3997 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3998 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4000 operator<<(const _Expr1& __x, const _Expr2& __y)
4002 typedef typename _Expr1::value_type value_type;
4003 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4004 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4007 template<class _Expr>
4008 inline _LIBCPP_INLINE_VISIBILITY
4011 __is_val_expr<_Expr>::value,
4012 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4013 _Expr, __scalar_expr<typename _Expr::value_type> > >
4015 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4017 typedef typename _Expr::value_type value_type;
4018 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4019 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4020 __x, __scalar_expr<value_type>(__y, __x.size())));
4023 template<class _Expr>
4024 inline _LIBCPP_INLINE_VISIBILITY
4027 __is_val_expr<_Expr>::value,
4028 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4029 __scalar_expr<typename _Expr::value_type>, _Expr> >
4031 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4033 typedef typename _Expr::value_type value_type;
4034 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4035 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4036 __scalar_expr<value_type>(__x, __y.size()), __y));
4039 template<class _Expr1, class _Expr2>
4040 inline _LIBCPP_INLINE_VISIBILITY
4043 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4044 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4046 operator>>(const _Expr1& __x, const _Expr2& __y)
4048 typedef typename _Expr1::value_type value_type;
4049 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4050 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4053 template<class _Expr>
4054 inline _LIBCPP_INLINE_VISIBILITY
4057 __is_val_expr<_Expr>::value,
4058 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4059 _Expr, __scalar_expr<typename _Expr::value_type> > >
4061 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4063 typedef typename _Expr::value_type value_type;
4064 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4065 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4066 __x, __scalar_expr<value_type>(__y, __x.size())));
4069 template<class _Expr>
4070 inline _LIBCPP_INLINE_VISIBILITY
4073 __is_val_expr<_Expr>::value,
4074 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4075 __scalar_expr<typename _Expr::value_type>, _Expr> >
4077 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4079 typedef typename _Expr::value_type value_type;
4080 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4081 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4082 __scalar_expr<value_type>(__x, __y.size()), __y));
4085 template<class _Expr1, class _Expr2>
4086 inline _LIBCPP_INLINE_VISIBILITY
4089 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4090 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4092 operator&&(const _Expr1& __x, const _Expr2& __y)
4094 typedef typename _Expr1::value_type value_type;
4095 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4096 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4099 template<class _Expr>
4100 inline _LIBCPP_INLINE_VISIBILITY
4103 __is_val_expr<_Expr>::value,
4104 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4105 _Expr, __scalar_expr<typename _Expr::value_type> > >
4107 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4109 typedef typename _Expr::value_type value_type;
4110 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4111 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4112 __x, __scalar_expr<value_type>(__y, __x.size())));
4115 template<class _Expr>
4116 inline _LIBCPP_INLINE_VISIBILITY
4119 __is_val_expr<_Expr>::value,
4120 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4121 __scalar_expr<typename _Expr::value_type>, _Expr> >
4123 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4125 typedef typename _Expr::value_type value_type;
4126 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4127 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4128 __scalar_expr<value_type>(__x, __y.size()), __y));
4131 template<class _Expr1, class _Expr2>
4132 inline _LIBCPP_INLINE_VISIBILITY
4135 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4136 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4138 operator||(const _Expr1& __x, const _Expr2& __y)
4140 typedef typename _Expr1::value_type value_type;
4141 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4142 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4145 template<class _Expr>
4146 inline _LIBCPP_INLINE_VISIBILITY
4149 __is_val_expr<_Expr>::value,
4150 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4151 _Expr, __scalar_expr<typename _Expr::value_type> > >
4153 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4155 typedef typename _Expr::value_type value_type;
4156 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4157 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4158 __x, __scalar_expr<value_type>(__y, __x.size())));
4161 template<class _Expr>
4162 inline _LIBCPP_INLINE_VISIBILITY
4165 __is_val_expr<_Expr>::value,
4166 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4167 __scalar_expr<typename _Expr::value_type>, _Expr> >
4169 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4171 typedef typename _Expr::value_type value_type;
4172 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4173 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4174 __scalar_expr<value_type>(__x, __y.size()), __y));
4177 template<class _Expr1, class _Expr2>
4178 inline _LIBCPP_INLINE_VISIBILITY
4181 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4182 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4184 operator==(const _Expr1& __x, const _Expr2& __y)
4186 typedef typename _Expr1::value_type value_type;
4187 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4188 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4191 template<class _Expr>
4192 inline _LIBCPP_INLINE_VISIBILITY
4195 __is_val_expr<_Expr>::value,
4196 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4197 _Expr, __scalar_expr<typename _Expr::value_type> > >
4199 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4201 typedef typename _Expr::value_type value_type;
4202 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4203 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4204 __x, __scalar_expr<value_type>(__y, __x.size())));
4207 template<class _Expr>
4208 inline _LIBCPP_INLINE_VISIBILITY
4211 __is_val_expr<_Expr>::value,
4212 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4213 __scalar_expr<typename _Expr::value_type>, _Expr> >
4215 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4217 typedef typename _Expr::value_type value_type;
4218 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4219 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4220 __scalar_expr<value_type>(__x, __y.size()), __y));
4223 template<class _Expr1, class _Expr2>
4224 inline _LIBCPP_INLINE_VISIBILITY
4227 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4228 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4230 operator!=(const _Expr1& __x, const _Expr2& __y)
4232 typedef typename _Expr1::value_type value_type;
4233 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4234 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4237 template<class _Expr>
4238 inline _LIBCPP_INLINE_VISIBILITY
4241 __is_val_expr<_Expr>::value,
4242 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4243 _Expr, __scalar_expr<typename _Expr::value_type> > >
4245 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4247 typedef typename _Expr::value_type value_type;
4248 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4249 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4250 __x, __scalar_expr<value_type>(__y, __x.size())));
4253 template<class _Expr>
4254 inline _LIBCPP_INLINE_VISIBILITY
4257 __is_val_expr<_Expr>::value,
4258 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4259 __scalar_expr<typename _Expr::value_type>, _Expr> >
4261 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4263 typedef typename _Expr::value_type value_type;
4264 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4265 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4266 __scalar_expr<value_type>(__x, __y.size()), __y));
4269 template<class _Expr1, class _Expr2>
4270 inline _LIBCPP_INLINE_VISIBILITY
4273 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4274 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4276 operator<(const _Expr1& __x, const _Expr2& __y)
4278 typedef typename _Expr1::value_type value_type;
4279 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4280 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4283 template<class _Expr>
4284 inline _LIBCPP_INLINE_VISIBILITY
4287 __is_val_expr<_Expr>::value,
4288 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4289 _Expr, __scalar_expr<typename _Expr::value_type> > >
4291 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4293 typedef typename _Expr::value_type value_type;
4294 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4295 return __val_expr<_Op>(_Op(less<value_type>(),
4296 __x, __scalar_expr<value_type>(__y, __x.size())));
4299 template<class _Expr>
4300 inline _LIBCPP_INLINE_VISIBILITY
4303 __is_val_expr<_Expr>::value,
4304 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4305 __scalar_expr<typename _Expr::value_type>, _Expr> >
4307 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4309 typedef typename _Expr::value_type value_type;
4310 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4311 return __val_expr<_Op>(_Op(less<value_type>(),
4312 __scalar_expr<value_type>(__x, __y.size()), __y));
4315 template<class _Expr1, class _Expr2>
4316 inline _LIBCPP_INLINE_VISIBILITY
4319 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4320 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4322 operator>(const _Expr1& __x, const _Expr2& __y)
4324 typedef typename _Expr1::value_type value_type;
4325 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4326 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4329 template<class _Expr>
4330 inline _LIBCPP_INLINE_VISIBILITY
4333 __is_val_expr<_Expr>::value,
4334 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4335 _Expr, __scalar_expr<typename _Expr::value_type> > >
4337 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4339 typedef typename _Expr::value_type value_type;
4340 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4341 return __val_expr<_Op>(_Op(greater<value_type>(),
4342 __x, __scalar_expr<value_type>(__y, __x.size())));
4345 template<class _Expr>
4346 inline _LIBCPP_INLINE_VISIBILITY
4349 __is_val_expr<_Expr>::value,
4350 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4351 __scalar_expr<typename _Expr::value_type>, _Expr> >
4353 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4355 typedef typename _Expr::value_type value_type;
4356 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4357 return __val_expr<_Op>(_Op(greater<value_type>(),
4358 __scalar_expr<value_type>(__x, __y.size()), __y));
4361 template<class _Expr1, class _Expr2>
4362 inline _LIBCPP_INLINE_VISIBILITY
4365 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4366 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4368 operator<=(const _Expr1& __x, const _Expr2& __y)
4370 typedef typename _Expr1::value_type value_type;
4371 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4372 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4375 template<class _Expr>
4376 inline _LIBCPP_INLINE_VISIBILITY
4379 __is_val_expr<_Expr>::value,
4380 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4381 _Expr, __scalar_expr<typename _Expr::value_type> > >
4383 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4385 typedef typename _Expr::value_type value_type;
4386 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4387 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4388 __x, __scalar_expr<value_type>(__y, __x.size())));
4391 template<class _Expr>
4392 inline _LIBCPP_INLINE_VISIBILITY
4395 __is_val_expr<_Expr>::value,
4396 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4397 __scalar_expr<typename _Expr::value_type>, _Expr> >
4399 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4401 typedef typename _Expr::value_type value_type;
4402 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4403 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4404 __scalar_expr<value_type>(__x, __y.size()), __y));
4407 template<class _Expr1, class _Expr2>
4408 inline _LIBCPP_INLINE_VISIBILITY
4411 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4412 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4414 operator>=(const _Expr1& __x, const _Expr2& __y)
4416 typedef typename _Expr1::value_type value_type;
4417 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4418 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4421 template<class _Expr>
4422 inline _LIBCPP_INLINE_VISIBILITY
4425 __is_val_expr<_Expr>::value,
4426 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4427 _Expr, __scalar_expr<typename _Expr::value_type> > >
4429 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4431 typedef typename _Expr::value_type value_type;
4432 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4433 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4434 __x, __scalar_expr<value_type>(__y, __x.size())));
4437 template<class _Expr>
4438 inline _LIBCPP_INLINE_VISIBILITY
4441 __is_val_expr<_Expr>::value,
4442 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4443 __scalar_expr<typename _Expr::value_type>, _Expr> >
4445 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4447 typedef typename _Expr::value_type value_type;
4448 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4449 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4450 __scalar_expr<value_type>(__x, __y.size()), __y));
4453 template<class _Expr>
4454 inline _LIBCPP_INLINE_VISIBILITY
4457 __is_val_expr<_Expr>::value,
4458 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4460 abs(const _Expr& __x)
4462 typedef typename _Expr::value_type value_type;
4463 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4464 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4467 template<class _Expr>
4468 inline _LIBCPP_INLINE_VISIBILITY
4471 __is_val_expr<_Expr>::value,
4472 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4474 acos(const _Expr& __x)
4476 typedef typename _Expr::value_type value_type;
4477 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4478 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4481 template<class _Expr>
4482 inline _LIBCPP_INLINE_VISIBILITY
4485 __is_val_expr<_Expr>::value,
4486 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4488 asin(const _Expr& __x)
4490 typedef typename _Expr::value_type value_type;
4491 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4492 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4495 template<class _Expr>
4496 inline _LIBCPP_INLINE_VISIBILITY
4499 __is_val_expr<_Expr>::value,
4500 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4502 atan(const _Expr& __x)
4504 typedef typename _Expr::value_type value_type;
4505 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4506 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4509 template<class _Expr1, class _Expr2>
4510 inline _LIBCPP_INLINE_VISIBILITY
4513 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4514 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4516 atan2(const _Expr1& __x, const _Expr2& __y)
4518 typedef typename _Expr1::value_type value_type;
4519 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4520 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4523 template<class _Expr>
4524 inline _LIBCPP_INLINE_VISIBILITY
4527 __is_val_expr<_Expr>::value,
4528 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4529 _Expr, __scalar_expr<typename _Expr::value_type> > >
4531 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4533 typedef typename _Expr::value_type value_type;
4534 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4535 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4536 __x, __scalar_expr<value_type>(__y, __x.size())));
4539 template<class _Expr>
4540 inline _LIBCPP_INLINE_VISIBILITY
4543 __is_val_expr<_Expr>::value,
4544 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4545 __scalar_expr<typename _Expr::value_type>, _Expr> >
4547 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4549 typedef typename _Expr::value_type value_type;
4550 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4551 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4552 __scalar_expr<value_type>(__x, __y.size()), __y));
4555 template<class _Expr>
4556 inline _LIBCPP_INLINE_VISIBILITY
4559 __is_val_expr<_Expr>::value,
4560 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4562 cos(const _Expr& __x)
4564 typedef typename _Expr::value_type value_type;
4565 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4566 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4569 template<class _Expr>
4570 inline _LIBCPP_INLINE_VISIBILITY
4573 __is_val_expr<_Expr>::value,
4574 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4576 cosh(const _Expr& __x)
4578 typedef typename _Expr::value_type value_type;
4579 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4580 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4583 template<class _Expr>
4584 inline _LIBCPP_INLINE_VISIBILITY
4587 __is_val_expr<_Expr>::value,
4588 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4590 exp(const _Expr& __x)
4592 typedef typename _Expr::value_type value_type;
4593 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4594 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4597 template<class _Expr>
4598 inline _LIBCPP_INLINE_VISIBILITY
4601 __is_val_expr<_Expr>::value,
4602 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4604 log(const _Expr& __x)
4606 typedef typename _Expr::value_type value_type;
4607 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4608 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4611 template<class _Expr>
4612 inline _LIBCPP_INLINE_VISIBILITY
4615 __is_val_expr<_Expr>::value,
4616 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4618 log10(const _Expr& __x)
4620 typedef typename _Expr::value_type value_type;
4621 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4622 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4625 template<class _Expr1, class _Expr2>
4626 inline _LIBCPP_INLINE_VISIBILITY
4629 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4630 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4632 pow(const _Expr1& __x, const _Expr2& __y)
4634 typedef typename _Expr1::value_type value_type;
4635 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4636 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4639 template<class _Expr>
4640 inline _LIBCPP_INLINE_VISIBILITY
4643 __is_val_expr<_Expr>::value,
4644 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4645 _Expr, __scalar_expr<typename _Expr::value_type> > >
4647 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4649 typedef typename _Expr::value_type value_type;
4650 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4651 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4652 __x, __scalar_expr<value_type>(__y, __x.size())));
4655 template<class _Expr>
4656 inline _LIBCPP_INLINE_VISIBILITY
4659 __is_val_expr<_Expr>::value,
4660 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4661 __scalar_expr<typename _Expr::value_type>, _Expr> >
4663 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4665 typedef typename _Expr::value_type value_type;
4666 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4667 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4668 __scalar_expr<value_type>(__x, __y.size()), __y));
4671 template<class _Expr>
4672 inline _LIBCPP_INLINE_VISIBILITY
4675 __is_val_expr<_Expr>::value,
4676 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4678 sin(const _Expr& __x)
4680 typedef typename _Expr::value_type value_type;
4681 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4682 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4685 template<class _Expr>
4686 inline _LIBCPP_INLINE_VISIBILITY
4689 __is_val_expr<_Expr>::value,
4690 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4692 sinh(const _Expr& __x)
4694 typedef typename _Expr::value_type value_type;
4695 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4696 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4699 template<class _Expr>
4700 inline _LIBCPP_INLINE_VISIBILITY
4703 __is_val_expr<_Expr>::value,
4704 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4706 sqrt(const _Expr& __x)
4708 typedef typename _Expr::value_type value_type;
4709 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4710 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4713 template<class _Expr>
4714 inline _LIBCPP_INLINE_VISIBILITY
4717 __is_val_expr<_Expr>::value,
4718 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4720 tan(const _Expr& __x)
4722 typedef typename _Expr::value_type value_type;
4723 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4724 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4727 template<class _Expr>
4728 inline _LIBCPP_INLINE_VISIBILITY
4731 __is_val_expr<_Expr>::value,
4732 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4734 tanh(const _Expr& __x)
4736 typedef typename _Expr::value_type value_type;
4737 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4738 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4741 template <class _Tp>
4742 inline _LIBCPP_INLINE_VISIBILITY
4744 begin(valarray<_Tp>& __v)
4746 return __v.__begin_;
4749 template <class _Tp>
4750 inline _LIBCPP_INLINE_VISIBILITY
4752 begin(const valarray<_Tp>& __v)
4754 return __v.__begin_;
4757 template <class _Tp>
4758 inline _LIBCPP_INLINE_VISIBILITY
4760 end(valarray<_Tp>& __v)
4765 template <class _Tp>
4766 inline _LIBCPP_INLINE_VISIBILITY
4768 end(const valarray<_Tp>& __v)
4773 _LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::valarray(size_t))
4774 _LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::~valarray())
4775 _LIBCPP_EXTERN_TEMPLATE(void valarray<size_t>::resize(size_t, size_t))
4777 _LIBCPP_END_NAMESPACE_STD
4779 #endif // _LIBCPP_VALARRAY