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_ONLY valarray;
359 class _LIBCPP_TYPE_VIS_ONLY 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_ONLY slice_array;
385 class _LIBCPP_TYPE_VIS gslice;
386 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array;
387 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array;
388 template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY 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_ONLY 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_ONLY 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_ONLY valarray;
980 template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array;
981 template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array;
982 template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array;
983 template <class> friend class __mask_expr;
984 template <class> friend class _LIBCPP_TYPE_VIS_ONLY 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 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1010 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1011 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1013 template <class _Op, class _Tp>
1014 struct _UnaryOp<_Op, valarray<_Tp> >
1016 typedef typename _Op::result_type result_type;
1017 typedef _Tp value_type;
1020 const valarray<_Tp>& __a0_;
1022 _LIBCPP_INLINE_VISIBILITY
1023 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1025 _LIBCPP_INLINE_VISIBILITY
1026 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1028 _LIBCPP_INLINE_VISIBILITY
1029 size_t size() const {return __a0_.size();}
1032 template <class _Op, class _Tp, class _A1>
1033 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1035 typedef typename _Op::result_type result_type;
1036 typedef _Tp value_type;
1039 const valarray<_Tp>& __a0_;
1042 _LIBCPP_INLINE_VISIBILITY
1043 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1044 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1046 _LIBCPP_INLINE_VISIBILITY
1047 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1049 _LIBCPP_INLINE_VISIBILITY
1050 size_t size() const {return __a0_.size();}
1053 template <class _Op, class _A0, class _Tp>
1054 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1056 typedef typename _Op::result_type result_type;
1057 typedef _Tp value_type;
1061 const valarray<_Tp>& __a1_;
1063 _LIBCPP_INLINE_VISIBILITY
1064 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1065 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1067 _LIBCPP_INLINE_VISIBILITY
1068 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1070 _LIBCPP_INLINE_VISIBILITY
1071 size_t size() const {return __a0_.size();}
1074 template <class _Op, class _Tp>
1075 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1077 typedef typename _Op::result_type result_type;
1078 typedef _Tp value_type;
1081 const valarray<_Tp>& __a0_;
1082 const valarray<_Tp>& __a1_;
1084 _LIBCPP_INLINE_VISIBILITY
1085 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1086 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1088 _LIBCPP_INLINE_VISIBILITY
1089 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1091 _LIBCPP_INLINE_VISIBILITY
1092 size_t size() const {return __a0_.size();}
1097 template <class _Tp>
1098 class _LIBCPP_TYPE_VIS_ONLY slice_array
1101 typedef _Tp value_type;
1109 template <class _Expr>
1112 __is_val_expr<_Expr>::value,
1115 operator=(const _Expr& __v) const;
1117 template <class _Expr>
1120 __is_val_expr<_Expr>::value,
1123 operator*=(const _Expr& __v) const;
1125 template <class _Expr>
1128 __is_val_expr<_Expr>::value,
1131 operator/=(const _Expr& __v) const;
1133 template <class _Expr>
1136 __is_val_expr<_Expr>::value,
1139 operator%=(const _Expr& __v) const;
1141 template <class _Expr>
1144 __is_val_expr<_Expr>::value,
1147 operator+=(const _Expr& __v) const;
1149 template <class _Expr>
1152 __is_val_expr<_Expr>::value,
1155 operator-=(const _Expr& __v) const;
1157 template <class _Expr>
1160 __is_val_expr<_Expr>::value,
1163 operator^=(const _Expr& __v) const;
1165 template <class _Expr>
1168 __is_val_expr<_Expr>::value,
1171 operator&=(const _Expr& __v) const;
1173 template <class _Expr>
1176 __is_val_expr<_Expr>::value,
1179 operator|=(const _Expr& __v) const;
1181 template <class _Expr>
1184 __is_val_expr<_Expr>::value,
1187 operator<<=(const _Expr& __v) const;
1189 template <class _Expr>
1192 __is_val_expr<_Expr>::value,
1195 operator>>=(const _Expr& __v) const;
1197 const slice_array& operator=(const slice_array& __sa) const;
1199 void operator=(const value_type& __x) const;
1202 _LIBCPP_INLINE_VISIBILITY
1203 slice_array(const slice& __sl, const valarray<value_type>& __v)
1204 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1205 __size_(__sl.size()),
1206 __stride_(__sl.stride())
1209 template <class> friend class valarray;
1210 template <class> friend class sliceExpr;
1213 template <class _Tp>
1214 inline _LIBCPP_INLINE_VISIBILITY
1215 const slice_array<_Tp>&
1216 slice_array<_Tp>::operator=(const slice_array& __sa) const
1218 value_type* __t = __vp_;
1219 const value_type* __s = __sa.__vp_;
1220 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1224 template <class _Tp>
1225 template <class _Expr>
1226 inline _LIBCPP_INLINE_VISIBILITY
1229 __is_val_expr<_Expr>::value,
1232 slice_array<_Tp>::operator=(const _Expr& __v) const
1234 value_type* __t = __vp_;
1235 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1239 template <class _Tp>
1240 template <class _Expr>
1241 inline _LIBCPP_INLINE_VISIBILITY
1244 __is_val_expr<_Expr>::value,
1247 slice_array<_Tp>::operator*=(const _Expr& __v) const
1249 value_type* __t = __vp_;
1250 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1254 template <class _Tp>
1255 template <class _Expr>
1256 inline _LIBCPP_INLINE_VISIBILITY
1259 __is_val_expr<_Expr>::value,
1262 slice_array<_Tp>::operator/=(const _Expr& __v) const
1264 value_type* __t = __vp_;
1265 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1269 template <class _Tp>
1270 template <class _Expr>
1271 inline _LIBCPP_INLINE_VISIBILITY
1274 __is_val_expr<_Expr>::value,
1277 slice_array<_Tp>::operator%=(const _Expr& __v) const
1279 value_type* __t = __vp_;
1280 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1284 template <class _Tp>
1285 template <class _Expr>
1286 inline _LIBCPP_INLINE_VISIBILITY
1289 __is_val_expr<_Expr>::value,
1292 slice_array<_Tp>::operator+=(const _Expr& __v) const
1294 value_type* __t = __vp_;
1295 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1299 template <class _Tp>
1300 template <class _Expr>
1301 inline _LIBCPP_INLINE_VISIBILITY
1304 __is_val_expr<_Expr>::value,
1307 slice_array<_Tp>::operator-=(const _Expr& __v) const
1309 value_type* __t = __vp_;
1310 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1314 template <class _Tp>
1315 template <class _Expr>
1316 inline _LIBCPP_INLINE_VISIBILITY
1319 __is_val_expr<_Expr>::value,
1322 slice_array<_Tp>::operator^=(const _Expr& __v) const
1324 value_type* __t = __vp_;
1325 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1329 template <class _Tp>
1330 template <class _Expr>
1331 inline _LIBCPP_INLINE_VISIBILITY
1334 __is_val_expr<_Expr>::value,
1337 slice_array<_Tp>::operator&=(const _Expr& __v) const
1339 value_type* __t = __vp_;
1340 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1344 template <class _Tp>
1345 template <class _Expr>
1346 inline _LIBCPP_INLINE_VISIBILITY
1349 __is_val_expr<_Expr>::value,
1352 slice_array<_Tp>::operator|=(const _Expr& __v) const
1354 value_type* __t = __vp_;
1355 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1359 template <class _Tp>
1360 template <class _Expr>
1361 inline _LIBCPP_INLINE_VISIBILITY
1364 __is_val_expr<_Expr>::value,
1367 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1369 value_type* __t = __vp_;
1370 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1374 template <class _Tp>
1375 template <class _Expr>
1376 inline _LIBCPP_INLINE_VISIBILITY
1379 __is_val_expr<_Expr>::value,
1382 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1384 value_type* __t = __vp_;
1385 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1389 template <class _Tp>
1390 inline _LIBCPP_INLINE_VISIBILITY
1392 slice_array<_Tp>::operator=(const value_type& __x) const
1394 value_type* __t = __vp_;
1395 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1401 class _LIBCPP_TYPE_VIS gslice
1403 valarray<size_t> __size_;
1404 valarray<size_t> __stride_;
1405 valarray<size_t> __1d_;
1408 _LIBCPP_INLINE_VISIBILITY
1411 _LIBCPP_INLINE_VISIBILITY
1412 gslice(size_t __start, const valarray<size_t>& __size,
1413 const valarray<size_t>& __stride)
1418 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1420 _LIBCPP_INLINE_VISIBILITY
1421 gslice(size_t __start, const valarray<size_t>& __size,
1422 valarray<size_t>&& __stride)
1424 __stride_(move(__stride))
1427 _LIBCPP_INLINE_VISIBILITY
1428 gslice(size_t __start, valarray<size_t>&& __size,
1429 const valarray<size_t>& __stride)
1430 : __size_(move(__size)),
1434 _LIBCPP_INLINE_VISIBILITY
1435 gslice(size_t __start, valarray<size_t>&& __size,
1436 valarray<size_t>&& __stride)
1437 : __size_(move(__size)),
1438 __stride_(move(__stride))
1441 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1443 // gslice(const gslice&) = default;
1444 // gslice(gslice&&) = default;
1445 // gslice& operator=(const gslice&) = default;
1446 // gslice& operator=(gslice&&) = default;
1448 _LIBCPP_INLINE_VISIBILITY
1449 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1451 _LIBCPP_INLINE_VISIBILITY
1452 valarray<size_t> size() const {return __size_;}
1454 _LIBCPP_INLINE_VISIBILITY
1455 valarray<size_t> stride() const {return __stride_;}
1458 void __init(size_t __start);
1460 template <class> friend class gslice_array;
1461 template <class> friend class valarray;
1462 template <class> friend class __val_expr;
1467 template <class _Tp>
1468 class _LIBCPP_TYPE_VIS_ONLY gslice_array
1471 typedef _Tp value_type;
1475 valarray<size_t> __1d_;
1478 template <class _Expr>
1481 __is_val_expr<_Expr>::value,
1484 operator=(const _Expr& __v) const;
1486 template <class _Expr>
1489 __is_val_expr<_Expr>::value,
1492 operator*=(const _Expr& __v) const;
1494 template <class _Expr>
1497 __is_val_expr<_Expr>::value,
1500 operator/=(const _Expr& __v) const;
1502 template <class _Expr>
1505 __is_val_expr<_Expr>::value,
1508 operator%=(const _Expr& __v) const;
1510 template <class _Expr>
1513 __is_val_expr<_Expr>::value,
1516 operator+=(const _Expr& __v) const;
1518 template <class _Expr>
1521 __is_val_expr<_Expr>::value,
1524 operator-=(const _Expr& __v) const;
1526 template <class _Expr>
1529 __is_val_expr<_Expr>::value,
1532 operator^=(const _Expr& __v) const;
1534 template <class _Expr>
1537 __is_val_expr<_Expr>::value,
1540 operator&=(const _Expr& __v) const;
1542 template <class _Expr>
1545 __is_val_expr<_Expr>::value,
1548 operator|=(const _Expr& __v) const;
1550 template <class _Expr>
1553 __is_val_expr<_Expr>::value,
1556 operator<<=(const _Expr& __v) const;
1558 template <class _Expr>
1561 __is_val_expr<_Expr>::value,
1564 operator>>=(const _Expr& __v) const;
1566 const gslice_array& operator=(const gslice_array& __ga) const;
1568 void operator=(const value_type& __x) const;
1570 // gslice_array(const gslice_array&) = default;
1571 // gslice_array(gslice_array&&) = default;
1572 // gslice_array& operator=(const gslice_array&) = default;
1573 // gslice_array& operator=(gslice_array&&) = default;
1576 _LIBCPP_INLINE_VISIBILITY
1577 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1578 : __vp_(const_cast<value_type*>(__v.__begin_)),
1582 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1584 _LIBCPP_INLINE_VISIBILITY
1585 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1586 : __vp_(const_cast<value_type*>(__v.__begin_)),
1587 __1d_(move(__gs.__1d_))
1590 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1592 template <class> friend class valarray;
1595 template <class _Tp>
1596 template <class _Expr>
1597 inline _LIBCPP_INLINE_VISIBILITY
1600 __is_val_expr<_Expr>::value,
1603 gslice_array<_Tp>::operator=(const _Expr& __v) const
1605 typedef const size_t* _Ip;
1607 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1608 __vp_[*__i] = __v[__j];
1611 template <class _Tp>
1612 template <class _Expr>
1613 inline _LIBCPP_INLINE_VISIBILITY
1616 __is_val_expr<_Expr>::value,
1619 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1621 typedef const size_t* _Ip;
1623 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1624 __vp_[*__i] *= __v[__j];
1627 template <class _Tp>
1628 template <class _Expr>
1629 inline _LIBCPP_INLINE_VISIBILITY
1632 __is_val_expr<_Expr>::value,
1635 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1637 typedef const size_t* _Ip;
1639 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1640 __vp_[*__i] /= __v[__j];
1643 template <class _Tp>
1644 template <class _Expr>
1645 inline _LIBCPP_INLINE_VISIBILITY
1648 __is_val_expr<_Expr>::value,
1651 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1653 typedef const size_t* _Ip;
1655 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1656 __vp_[*__i] %= __v[__j];
1659 template <class _Tp>
1660 template <class _Expr>
1661 inline _LIBCPP_INLINE_VISIBILITY
1664 __is_val_expr<_Expr>::value,
1667 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1669 typedef const size_t* _Ip;
1671 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1672 __vp_[*__i] += __v[__j];
1675 template <class _Tp>
1676 template <class _Expr>
1677 inline _LIBCPP_INLINE_VISIBILITY
1680 __is_val_expr<_Expr>::value,
1683 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1685 typedef const size_t* _Ip;
1687 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1688 __vp_[*__i] -= __v[__j];
1691 template <class _Tp>
1692 template <class _Expr>
1693 inline _LIBCPP_INLINE_VISIBILITY
1696 __is_val_expr<_Expr>::value,
1699 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1701 typedef const size_t* _Ip;
1703 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1704 __vp_[*__i] ^= __v[__j];
1707 template <class _Tp>
1708 template <class _Expr>
1709 inline _LIBCPP_INLINE_VISIBILITY
1712 __is_val_expr<_Expr>::value,
1715 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1717 typedef const size_t* _Ip;
1719 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1720 __vp_[*__i] &= __v[__j];
1723 template <class _Tp>
1724 template <class _Expr>
1725 inline _LIBCPP_INLINE_VISIBILITY
1728 __is_val_expr<_Expr>::value,
1731 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1733 typedef const size_t* _Ip;
1735 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1736 __vp_[*__i] |= __v[__j];
1739 template <class _Tp>
1740 template <class _Expr>
1741 inline _LIBCPP_INLINE_VISIBILITY
1744 __is_val_expr<_Expr>::value,
1747 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1749 typedef const size_t* _Ip;
1751 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1752 __vp_[*__i] <<= __v[__j];
1755 template <class _Tp>
1756 template <class _Expr>
1757 inline _LIBCPP_INLINE_VISIBILITY
1760 __is_val_expr<_Expr>::value,
1763 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1765 typedef const size_t* _Ip;
1767 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1768 __vp_[*__i] >>= __v[__j];
1771 template <class _Tp>
1772 inline _LIBCPP_INLINE_VISIBILITY
1773 const gslice_array<_Tp>&
1774 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1776 typedef const size_t* _Ip;
1777 const value_type* __s = __ga.__vp_;
1778 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1779 __i != __e; ++__i, ++__j)
1780 __vp_[*__i] = __s[*__j];
1784 template <class _Tp>
1785 inline _LIBCPP_INLINE_VISIBILITY
1787 gslice_array<_Tp>::operator=(const value_type& __x) const
1789 typedef const size_t* _Ip;
1790 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1796 template <class _Tp>
1797 class _LIBCPP_TYPE_VIS_ONLY mask_array
1800 typedef _Tp value_type;
1804 valarray<size_t> __1d_;
1807 template <class _Expr>
1810 __is_val_expr<_Expr>::value,
1813 operator=(const _Expr& __v) const;
1815 template <class _Expr>
1818 __is_val_expr<_Expr>::value,
1821 operator*=(const _Expr& __v) const;
1823 template <class _Expr>
1826 __is_val_expr<_Expr>::value,
1829 operator/=(const _Expr& __v) const;
1831 template <class _Expr>
1834 __is_val_expr<_Expr>::value,
1837 operator%=(const _Expr& __v) const;
1839 template <class _Expr>
1842 __is_val_expr<_Expr>::value,
1845 operator+=(const _Expr& __v) const;
1847 template <class _Expr>
1850 __is_val_expr<_Expr>::value,
1853 operator-=(const _Expr& __v) const;
1855 template <class _Expr>
1858 __is_val_expr<_Expr>::value,
1861 operator^=(const _Expr& __v) const;
1863 template <class _Expr>
1866 __is_val_expr<_Expr>::value,
1869 operator&=(const _Expr& __v) const;
1871 template <class _Expr>
1874 __is_val_expr<_Expr>::value,
1877 operator|=(const _Expr& __v) const;
1879 template <class _Expr>
1882 __is_val_expr<_Expr>::value,
1885 operator<<=(const _Expr& __v) const;
1887 template <class _Expr>
1890 __is_val_expr<_Expr>::value,
1893 operator>>=(const _Expr& __v) const;
1895 const mask_array& operator=(const mask_array& __ma) const;
1897 void operator=(const value_type& __x) const;
1899 // mask_array(const mask_array&) = default;
1900 // mask_array(mask_array&&) = default;
1901 // mask_array& operator=(const mask_array&) = default;
1902 // mask_array& operator=(mask_array&&) = default;
1905 _LIBCPP_INLINE_VISIBILITY
1906 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1907 : __vp_(const_cast<value_type*>(__v.__begin_)),
1908 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1911 for (size_t __i = 0; __i < __vb.size(); ++__i)
1916 template <class> friend class valarray;
1919 template <class _Tp>
1920 template <class _Expr>
1921 inline _LIBCPP_INLINE_VISIBILITY
1924 __is_val_expr<_Expr>::value,
1927 mask_array<_Tp>::operator=(const _Expr& __v) const
1929 size_t __n = __1d_.size();
1930 for (size_t __i = 0; __i < __n; ++__i)
1931 __vp_[__1d_[__i]] = __v[__i];
1934 template <class _Tp>
1935 template <class _Expr>
1936 inline _LIBCPP_INLINE_VISIBILITY
1939 __is_val_expr<_Expr>::value,
1942 mask_array<_Tp>::operator*=(const _Expr& __v) const
1944 size_t __n = __1d_.size();
1945 for (size_t __i = 0; __i < __n; ++__i)
1946 __vp_[__1d_[__i]] *= __v[__i];
1949 template <class _Tp>
1950 template <class _Expr>
1951 inline _LIBCPP_INLINE_VISIBILITY
1954 __is_val_expr<_Expr>::value,
1957 mask_array<_Tp>::operator/=(const _Expr& __v) const
1959 size_t __n = __1d_.size();
1960 for (size_t __i = 0; __i < __n; ++__i)
1961 __vp_[__1d_[__i]] /= __v[__i];
1964 template <class _Tp>
1965 template <class _Expr>
1966 inline _LIBCPP_INLINE_VISIBILITY
1969 __is_val_expr<_Expr>::value,
1972 mask_array<_Tp>::operator%=(const _Expr& __v) const
1974 size_t __n = __1d_.size();
1975 for (size_t __i = 0; __i < __n; ++__i)
1976 __vp_[__1d_[__i]] %= __v[__i];
1979 template <class _Tp>
1980 template <class _Expr>
1981 inline _LIBCPP_INLINE_VISIBILITY
1984 __is_val_expr<_Expr>::value,
1987 mask_array<_Tp>::operator+=(const _Expr& __v) const
1989 size_t __n = __1d_.size();
1990 for (size_t __i = 0; __i < __n; ++__i)
1991 __vp_[__1d_[__i]] += __v[__i];
1994 template <class _Tp>
1995 template <class _Expr>
1996 inline _LIBCPP_INLINE_VISIBILITY
1999 __is_val_expr<_Expr>::value,
2002 mask_array<_Tp>::operator-=(const _Expr& __v) const
2004 size_t __n = __1d_.size();
2005 for (size_t __i = 0; __i < __n; ++__i)
2006 __vp_[__1d_[__i]] -= __v[__i];
2009 template <class _Tp>
2010 template <class _Expr>
2011 inline _LIBCPP_INLINE_VISIBILITY
2014 __is_val_expr<_Expr>::value,
2017 mask_array<_Tp>::operator^=(const _Expr& __v) const
2019 size_t __n = __1d_.size();
2020 for (size_t __i = 0; __i < __n; ++__i)
2021 __vp_[__1d_[__i]] ^= __v[__i];
2024 template <class _Tp>
2025 template <class _Expr>
2026 inline _LIBCPP_INLINE_VISIBILITY
2029 __is_val_expr<_Expr>::value,
2032 mask_array<_Tp>::operator&=(const _Expr& __v) const
2034 size_t __n = __1d_.size();
2035 for (size_t __i = 0; __i < __n; ++__i)
2036 __vp_[__1d_[__i]] &= __v[__i];
2039 template <class _Tp>
2040 template <class _Expr>
2041 inline _LIBCPP_INLINE_VISIBILITY
2044 __is_val_expr<_Expr>::value,
2047 mask_array<_Tp>::operator|=(const _Expr& __v) const
2049 size_t __n = __1d_.size();
2050 for (size_t __i = 0; __i < __n; ++__i)
2051 __vp_[__1d_[__i]] |= __v[__i];
2054 template <class _Tp>
2055 template <class _Expr>
2056 inline _LIBCPP_INLINE_VISIBILITY
2059 __is_val_expr<_Expr>::value,
2062 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2064 size_t __n = __1d_.size();
2065 for (size_t __i = 0; __i < __n; ++__i)
2066 __vp_[__1d_[__i]] <<= __v[__i];
2069 template <class _Tp>
2070 template <class _Expr>
2071 inline _LIBCPP_INLINE_VISIBILITY
2074 __is_val_expr<_Expr>::value,
2077 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2079 size_t __n = __1d_.size();
2080 for (size_t __i = 0; __i < __n; ++__i)
2081 __vp_[__1d_[__i]] >>= __v[__i];
2084 template <class _Tp>
2085 inline _LIBCPP_INLINE_VISIBILITY
2086 const mask_array<_Tp>&
2087 mask_array<_Tp>::operator=(const mask_array& __ma) const
2089 size_t __n = __1d_.size();
2090 for (size_t __i = 0; __i < __n; ++__i)
2091 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2094 template <class _Tp>
2095 inline _LIBCPP_INLINE_VISIBILITY
2097 mask_array<_Tp>::operator=(const value_type& __x) const
2099 size_t __n = __1d_.size();
2100 for (size_t __i = 0; __i < __n; ++__i)
2101 __vp_[__1d_[__i]] = __x;
2104 template <class _ValExpr>
2107 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2109 typedef typename _RmExpr::value_type value_type;
2110 typedef value_type result_type;
2114 valarray<size_t> __1d_;
2116 _LIBCPP_INLINE_VISIBILITY
2117 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2119 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2122 for (size_t __i = 0; __i < __vb.size(); ++__i)
2128 _LIBCPP_INLINE_VISIBILITY
2129 result_type operator[](size_t __i) const
2130 {return __expr_[__1d_[__i]];}
2132 _LIBCPP_INLINE_VISIBILITY
2133 size_t size() const {return __1d_.size();}
2135 template <class> friend class valarray;
2140 template <class _Tp>
2141 class _LIBCPP_TYPE_VIS_ONLY indirect_array
2144 typedef _Tp value_type;
2148 valarray<size_t> __1d_;
2151 template <class _Expr>
2154 __is_val_expr<_Expr>::value,
2157 operator=(const _Expr& __v) const;
2159 template <class _Expr>
2162 __is_val_expr<_Expr>::value,
2165 operator*=(const _Expr& __v) const;
2167 template <class _Expr>
2170 __is_val_expr<_Expr>::value,
2173 operator/=(const _Expr& __v) const;
2175 template <class _Expr>
2178 __is_val_expr<_Expr>::value,
2181 operator%=(const _Expr& __v) const;
2183 template <class _Expr>
2186 __is_val_expr<_Expr>::value,
2189 operator+=(const _Expr& __v) const;
2191 template <class _Expr>
2194 __is_val_expr<_Expr>::value,
2197 operator-=(const _Expr& __v) const;
2199 template <class _Expr>
2202 __is_val_expr<_Expr>::value,
2205 operator^=(const _Expr& __v) const;
2207 template <class _Expr>
2210 __is_val_expr<_Expr>::value,
2213 operator&=(const _Expr& __v) const;
2215 template <class _Expr>
2218 __is_val_expr<_Expr>::value,
2221 operator|=(const _Expr& __v) const;
2223 template <class _Expr>
2226 __is_val_expr<_Expr>::value,
2229 operator<<=(const _Expr& __v) const;
2231 template <class _Expr>
2234 __is_val_expr<_Expr>::value,
2237 operator>>=(const _Expr& __v) const;
2239 const indirect_array& operator=(const indirect_array& __ia) const;
2241 void operator=(const value_type& __x) const;
2243 // indirect_array(const indirect_array&) = default;
2244 // indirect_array(indirect_array&&) = default;
2245 // indirect_array& operator=(const indirect_array&) = default;
2246 // indirect_array& operator=(indirect_array&&) = default;
2249 _LIBCPP_INLINE_VISIBILITY
2250 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2251 : __vp_(const_cast<value_type*>(__v.__begin_)),
2255 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2257 _LIBCPP_INLINE_VISIBILITY
2258 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2259 : __vp_(const_cast<value_type*>(__v.__begin_)),
2263 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2265 template <class> friend class valarray;
2268 template <class _Tp>
2269 template <class _Expr>
2270 inline _LIBCPP_INLINE_VISIBILITY
2273 __is_val_expr<_Expr>::value,
2276 indirect_array<_Tp>::operator=(const _Expr& __v) const
2278 size_t __n = __1d_.size();
2279 for (size_t __i = 0; __i < __n; ++__i)
2280 __vp_[__1d_[__i]] = __v[__i];
2283 template <class _Tp>
2284 template <class _Expr>
2285 inline _LIBCPP_INLINE_VISIBILITY
2288 __is_val_expr<_Expr>::value,
2291 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2293 size_t __n = __1d_.size();
2294 for (size_t __i = 0; __i < __n; ++__i)
2295 __vp_[__1d_[__i]] *= __v[__i];
2298 template <class _Tp>
2299 template <class _Expr>
2300 inline _LIBCPP_INLINE_VISIBILITY
2303 __is_val_expr<_Expr>::value,
2306 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2308 size_t __n = __1d_.size();
2309 for (size_t __i = 0; __i < __n; ++__i)
2310 __vp_[__1d_[__i]] /= __v[__i];
2313 template <class _Tp>
2314 template <class _Expr>
2315 inline _LIBCPP_INLINE_VISIBILITY
2318 __is_val_expr<_Expr>::value,
2321 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2323 size_t __n = __1d_.size();
2324 for (size_t __i = 0; __i < __n; ++__i)
2325 __vp_[__1d_[__i]] %= __v[__i];
2328 template <class _Tp>
2329 template <class _Expr>
2330 inline _LIBCPP_INLINE_VISIBILITY
2333 __is_val_expr<_Expr>::value,
2336 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2338 size_t __n = __1d_.size();
2339 for (size_t __i = 0; __i < __n; ++__i)
2340 __vp_[__1d_[__i]] += __v[__i];
2343 template <class _Tp>
2344 template <class _Expr>
2345 inline _LIBCPP_INLINE_VISIBILITY
2348 __is_val_expr<_Expr>::value,
2351 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2353 size_t __n = __1d_.size();
2354 for (size_t __i = 0; __i < __n; ++__i)
2355 __vp_[__1d_[__i]] -= __v[__i];
2358 template <class _Tp>
2359 template <class _Expr>
2360 inline _LIBCPP_INLINE_VISIBILITY
2363 __is_val_expr<_Expr>::value,
2366 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2368 size_t __n = __1d_.size();
2369 for (size_t __i = 0; __i < __n; ++__i)
2370 __vp_[__1d_[__i]] ^= __v[__i];
2373 template <class _Tp>
2374 template <class _Expr>
2375 inline _LIBCPP_INLINE_VISIBILITY
2378 __is_val_expr<_Expr>::value,
2381 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2383 size_t __n = __1d_.size();
2384 for (size_t __i = 0; __i < __n; ++__i)
2385 __vp_[__1d_[__i]] &= __v[__i];
2388 template <class _Tp>
2389 template <class _Expr>
2390 inline _LIBCPP_INLINE_VISIBILITY
2393 __is_val_expr<_Expr>::value,
2396 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2398 size_t __n = __1d_.size();
2399 for (size_t __i = 0; __i < __n; ++__i)
2400 __vp_[__1d_[__i]] |= __v[__i];
2403 template <class _Tp>
2404 template <class _Expr>
2405 inline _LIBCPP_INLINE_VISIBILITY
2408 __is_val_expr<_Expr>::value,
2411 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2413 size_t __n = __1d_.size();
2414 for (size_t __i = 0; __i < __n; ++__i)
2415 __vp_[__1d_[__i]] <<= __v[__i];
2418 template <class _Tp>
2419 template <class _Expr>
2420 inline _LIBCPP_INLINE_VISIBILITY
2423 __is_val_expr<_Expr>::value,
2426 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2428 size_t __n = __1d_.size();
2429 for (size_t __i = 0; __i < __n; ++__i)
2430 __vp_[__1d_[__i]] >>= __v[__i];
2433 template <class _Tp>
2434 inline _LIBCPP_INLINE_VISIBILITY
2435 const indirect_array<_Tp>&
2436 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2438 typedef const size_t* _Ip;
2439 const value_type* __s = __ia.__vp_;
2440 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2441 __i != __e; ++__i, ++__j)
2442 __vp_[*__i] = __s[*__j];
2446 template <class _Tp>
2447 inline _LIBCPP_INLINE_VISIBILITY
2449 indirect_array<_Tp>::operator=(const value_type& __x) const
2451 typedef const size_t* _Ip;
2452 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2456 template <class _ValExpr>
2457 class __indirect_expr
2459 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2461 typedef typename _RmExpr::value_type value_type;
2462 typedef value_type result_type;
2466 valarray<size_t> __1d_;
2468 _LIBCPP_INLINE_VISIBILITY
2469 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2474 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2476 _LIBCPP_INLINE_VISIBILITY
2477 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2482 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2485 _LIBCPP_INLINE_VISIBILITY
2486 result_type operator[](size_t __i) const
2487 {return __expr_[__1d_[__i]];}
2489 _LIBCPP_INLINE_VISIBILITY
2490 size_t size() const {return __1d_.size();}
2492 template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray;
2495 template<class _ValExpr>
2498 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2502 typedef typename _RmExpr::value_type value_type;
2503 typedef typename _RmExpr::result_type result_type;
2505 _LIBCPP_INLINE_VISIBILITY
2506 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2508 _LIBCPP_INLINE_VISIBILITY
2509 result_type operator[](size_t __i) const
2510 {return __expr_[__i];}
2512 _LIBCPP_INLINE_VISIBILITY
2513 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2514 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2516 _LIBCPP_INLINE_VISIBILITY
2517 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2518 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2520 _LIBCPP_INLINE_VISIBILITY
2521 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2522 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2524 _LIBCPP_INLINE_VISIBILITY
2525 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2526 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2528 _LIBCPP_INLINE_VISIBILITY
2529 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2532 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2533 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2536 _LIBCPP_INLINE_VISIBILITY
2537 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2540 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2541 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2544 _LIBCPP_INLINE_VISIBILITY
2545 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2548 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2549 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2552 _LIBCPP_INLINE_VISIBILITY
2553 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2556 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2557 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2560 operator valarray<result_type>() const;
2562 _LIBCPP_INLINE_VISIBILITY
2563 size_t size() const {return __expr_.size();}
2565 _LIBCPP_INLINE_VISIBILITY
2566 result_type sum() const
2568 size_t __n = __expr_.size();
2569 result_type __r = __n ? __expr_[0] : result_type();
2570 for (size_t __i = 1; __i < __n; ++__i)
2571 __r += __expr_[__i];
2575 _LIBCPP_INLINE_VISIBILITY
2576 result_type min() const
2578 size_t __n = size();
2579 result_type __r = __n ? (*this)[0] : result_type();
2580 for (size_t __i = 1; __i < __n; ++__i)
2582 result_type __x = __expr_[__i];
2589 _LIBCPP_INLINE_VISIBILITY
2590 result_type max() const
2592 size_t __n = size();
2593 result_type __r = __n ? (*this)[0] : result_type();
2594 for (size_t __i = 1; __i < __n; ++__i)
2596 result_type __x = __expr_[__i];
2603 _LIBCPP_INLINE_VISIBILITY
2604 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2605 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2607 _LIBCPP_INLINE_VISIBILITY
2608 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2609 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2611 _LIBCPP_INLINE_VISIBILITY
2612 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2613 apply(value_type __f(value_type)) const
2615 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2616 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2617 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2620 _LIBCPP_INLINE_VISIBILITY
2621 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2622 apply(value_type __f(const value_type&)) const
2624 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2625 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2626 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2630 template<class _ValExpr>
2631 __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2633 valarray<result_type> __r;
2634 size_t __n = __expr_.size();
2639 static_cast<result_type*>(::operator new(__n * sizeof(result_type)));
2640 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2641 ::new (__r.__end_) result_type(__expr_[__i]);
2648 template <class _Tp>
2649 inline _LIBCPP_INLINE_VISIBILITY
2650 valarray<_Tp>::valarray(size_t __n)
2657 template <class _Tp>
2658 inline _LIBCPP_INLINE_VISIBILITY
2659 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2666 template <class _Tp>
2667 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2673 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2674 #ifndef _LIBCPP_NO_EXCEPTIONS
2677 #endif // _LIBCPP_NO_EXCEPTIONS
2678 for (; __n; ++__end_, ++__p, --__n)
2679 ::new (__end_) value_type(*__p);
2680 #ifndef _LIBCPP_NO_EXCEPTIONS
2687 #endif // _LIBCPP_NO_EXCEPTIONS
2691 template <class _Tp>
2692 valarray<_Tp>::valarray(const valarray& __v)
2698 __begin_ = __end_ = static_cast<value_type*>(::operator new(__v.size() * sizeof(value_type)));
2699 #ifndef _LIBCPP_NO_EXCEPTIONS
2702 #endif // _LIBCPP_NO_EXCEPTIONS
2703 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2704 ::new (__end_) value_type(*__p);
2705 #ifndef _LIBCPP_NO_EXCEPTIONS
2712 #endif // _LIBCPP_NO_EXCEPTIONS
2716 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2718 template <class _Tp>
2719 inline _LIBCPP_INLINE_VISIBILITY
2720 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2721 : __begin_(__v.__begin_),
2724 __v.__begin_ = __v.__end_ = nullptr;
2727 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2729 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2731 template <class _Tp>
2732 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2736 size_t __n = __il.size();
2739 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2740 #ifndef _LIBCPP_NO_EXCEPTIONS
2743 #endif // _LIBCPP_NO_EXCEPTIONS
2744 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2745 ::new (__end_) value_type(*__p);
2746 #ifndef _LIBCPP_NO_EXCEPTIONS
2753 #endif // _LIBCPP_NO_EXCEPTIONS
2757 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2759 template <class _Tp>
2760 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2764 size_t __n = __sa.__size_;
2767 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2768 #ifndef _LIBCPP_NO_EXCEPTIONS
2771 #endif // _LIBCPP_NO_EXCEPTIONS
2772 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2773 ::new (__end_) value_type(*__p);
2774 #ifndef _LIBCPP_NO_EXCEPTIONS
2781 #endif // _LIBCPP_NO_EXCEPTIONS
2785 template <class _Tp>
2786 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2790 size_t __n = __ga.__1d_.size();
2793 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2794 #ifndef _LIBCPP_NO_EXCEPTIONS
2797 #endif // _LIBCPP_NO_EXCEPTIONS
2798 typedef const size_t* _Ip;
2799 const value_type* __s = __ga.__vp_;
2800 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2801 __i != __e; ++__i, ++__end_)
2802 ::new (__end_) value_type(__s[*__i]);
2803 #ifndef _LIBCPP_NO_EXCEPTIONS
2810 #endif // _LIBCPP_NO_EXCEPTIONS
2814 template <class _Tp>
2815 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2819 size_t __n = __ma.__1d_.size();
2822 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2823 #ifndef _LIBCPP_NO_EXCEPTIONS
2826 #endif // _LIBCPP_NO_EXCEPTIONS
2827 typedef const size_t* _Ip;
2828 const value_type* __s = __ma.__vp_;
2829 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2830 __i != __e; ++__i, ++__end_)
2831 ::new (__end_) value_type(__s[*__i]);
2832 #ifndef _LIBCPP_NO_EXCEPTIONS
2839 #endif // _LIBCPP_NO_EXCEPTIONS
2843 template <class _Tp>
2844 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2848 size_t __n = __ia.__1d_.size();
2851 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
2852 #ifndef _LIBCPP_NO_EXCEPTIONS
2855 #endif // _LIBCPP_NO_EXCEPTIONS
2856 typedef const size_t* _Ip;
2857 const value_type* __s = __ia.__vp_;
2858 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2859 __i != __e; ++__i, ++__end_)
2860 ::new (__end_) value_type(__s[*__i]);
2861 #ifndef _LIBCPP_NO_EXCEPTIONS
2868 #endif // _LIBCPP_NO_EXCEPTIONS
2872 template <class _Tp>
2873 inline _LIBCPP_INLINE_VISIBILITY
2874 valarray<_Tp>::~valarray()
2879 template <class _Tp>
2881 valarray<_Tp>::operator=(const valarray& __v)
2885 if (size() != __v.size())
2887 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
2892 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2894 template <class _Tp>
2895 inline _LIBCPP_INLINE_VISIBILITY
2897 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
2900 __begin_ = __v.__begin_;
2901 __end_ = __v.__end_;
2902 __v.__begin_ = nullptr;
2903 __v.__end_ = nullptr;
2907 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2909 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2911 template <class _Tp>
2912 inline _LIBCPP_INLINE_VISIBILITY
2914 valarray<_Tp>::operator=(initializer_list<value_type> __il)
2916 if (size() != __il.size())
2917 resize(__il.size());
2918 _VSTD::copy(__il.begin(), __il.end(), __begin_);
2922 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2924 template <class _Tp>
2925 inline _LIBCPP_INLINE_VISIBILITY
2927 valarray<_Tp>::operator=(const value_type& __x)
2929 _VSTD::fill(__begin_, __end_, __x);
2933 template <class _Tp>
2934 inline _LIBCPP_INLINE_VISIBILITY
2936 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
2938 value_type* __t = __begin_;
2939 const value_type* __s = __sa.__vp_;
2940 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
2945 template <class _Tp>
2946 inline _LIBCPP_INLINE_VISIBILITY
2948 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
2950 typedef const size_t* _Ip;
2951 value_type* __t = __begin_;
2952 const value_type* __s = __ga.__vp_;
2953 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2954 __i != __e; ++__i, ++__t)
2959 template <class _Tp>
2960 inline _LIBCPP_INLINE_VISIBILITY
2962 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
2964 typedef const size_t* _Ip;
2965 value_type* __t = __begin_;
2966 const value_type* __s = __ma.__vp_;
2967 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2968 __i != __e; ++__i, ++__t)
2973 template <class _Tp>
2974 inline _LIBCPP_INLINE_VISIBILITY
2976 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
2978 typedef const size_t* _Ip;
2979 value_type* __t = __begin_;
2980 const value_type* __s = __ia.__vp_;
2981 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2982 __i != __e; ++__i, ++__t)
2987 template <class _Tp>
2988 template <class _ValExpr>
2989 inline _LIBCPP_INLINE_VISIBILITY
2991 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
2993 size_t __n = __v.size();
2996 value_type* __t = __begin_;
2997 for (size_t __i = 0; __i != __n; ++__t, ++__i)
2998 *__t = result_type(__v[__i]);
3002 template <class _Tp>
3003 inline _LIBCPP_INLINE_VISIBILITY
3004 __val_expr<__slice_expr<const valarray<_Tp>&> >
3005 valarray<_Tp>::operator[](slice __s) const
3007 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3010 template <class _Tp>
3011 inline _LIBCPP_INLINE_VISIBILITY
3013 valarray<_Tp>::operator[](slice __s)
3015 return slice_array<value_type>(__s, *this);
3018 template <class _Tp>
3019 inline _LIBCPP_INLINE_VISIBILITY
3020 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3021 valarray<_Tp>::operator[](const gslice& __gs) const
3023 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3026 template <class _Tp>
3027 inline _LIBCPP_INLINE_VISIBILITY
3029 valarray<_Tp>::operator[](const gslice& __gs)
3031 return gslice_array<value_type>(__gs, *this);
3034 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3036 template <class _Tp>
3037 inline _LIBCPP_INLINE_VISIBILITY
3038 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3039 valarray<_Tp>::operator[](gslice&& __gs) const
3041 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3044 template <class _Tp>
3045 inline _LIBCPP_INLINE_VISIBILITY
3047 valarray<_Tp>::operator[](gslice&& __gs)
3049 return gslice_array<value_type>(move(__gs), *this);
3052 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3054 template <class _Tp>
3055 inline _LIBCPP_INLINE_VISIBILITY
3056 __val_expr<__mask_expr<const valarray<_Tp>&> >
3057 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3059 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3062 template <class _Tp>
3063 inline _LIBCPP_INLINE_VISIBILITY
3065 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3067 return mask_array<value_type>(__vb, *this);
3070 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3072 template <class _Tp>
3073 inline _LIBCPP_INLINE_VISIBILITY
3074 __val_expr<__mask_expr<const valarray<_Tp>&> >
3075 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3077 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3080 template <class _Tp>
3081 inline _LIBCPP_INLINE_VISIBILITY
3083 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3085 return mask_array<value_type>(move(__vb), *this);
3088 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3090 template <class _Tp>
3091 inline _LIBCPP_INLINE_VISIBILITY
3092 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3093 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3095 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3098 template <class _Tp>
3099 inline _LIBCPP_INLINE_VISIBILITY
3101 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3103 return indirect_array<value_type>(__vs, *this);
3106 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3108 template <class _Tp>
3109 inline _LIBCPP_INLINE_VISIBILITY
3110 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3111 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3113 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3116 template <class _Tp>
3117 inline _LIBCPP_INLINE_VISIBILITY
3119 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3121 return indirect_array<value_type>(move(__vs), *this);
3124 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3126 template <class _Tp>
3128 valarray<_Tp>::operator+() const
3130 valarray<value_type> __r;
3131 size_t __n = size();
3136 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3137 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3138 ::new (__r.__end_) value_type(+*__p);
3143 template <class _Tp>
3145 valarray<_Tp>::operator-() const
3147 valarray<value_type> __r;
3148 size_t __n = size();
3153 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3154 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3155 ::new (__r.__end_) value_type(-*__p);
3160 template <class _Tp>
3162 valarray<_Tp>::operator~() const
3164 valarray<value_type> __r;
3165 size_t __n = size();
3170 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3171 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3172 ::new (__r.__end_) value_type(~*__p);
3177 template <class _Tp>
3179 valarray<_Tp>::operator!() const
3182 size_t __n = size();
3187 static_cast<bool*>(::operator new(__n * sizeof(bool)));
3188 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3189 ::new (__r.__end_) bool(!*__p);
3194 template <class _Tp>
3195 inline _LIBCPP_INLINE_VISIBILITY
3197 valarray<_Tp>::operator*=(const value_type& __x)
3199 for (value_type* __p = __begin_; __p != __end_; ++__p)
3204 template <class _Tp>
3205 inline _LIBCPP_INLINE_VISIBILITY
3207 valarray<_Tp>::operator/=(const value_type& __x)
3209 for (value_type* __p = __begin_; __p != __end_; ++__p)
3214 template <class _Tp>
3215 inline _LIBCPP_INLINE_VISIBILITY
3217 valarray<_Tp>::operator%=(const value_type& __x)
3219 for (value_type* __p = __begin_; __p != __end_; ++__p)
3224 template <class _Tp>
3225 inline _LIBCPP_INLINE_VISIBILITY
3227 valarray<_Tp>::operator+=(const value_type& __x)
3229 for (value_type* __p = __begin_; __p != __end_; ++__p)
3234 template <class _Tp>
3235 inline _LIBCPP_INLINE_VISIBILITY
3237 valarray<_Tp>::operator-=(const value_type& __x)
3239 for (value_type* __p = __begin_; __p != __end_; ++__p)
3244 template <class _Tp>
3245 inline _LIBCPP_INLINE_VISIBILITY
3247 valarray<_Tp>::operator^=(const value_type& __x)
3249 for (value_type* __p = __begin_; __p != __end_; ++__p)
3254 template <class _Tp>
3255 inline _LIBCPP_INLINE_VISIBILITY
3257 valarray<_Tp>::operator&=(const value_type& __x)
3259 for (value_type* __p = __begin_; __p != __end_; ++__p)
3264 template <class _Tp>
3265 inline _LIBCPP_INLINE_VISIBILITY
3267 valarray<_Tp>::operator|=(const value_type& __x)
3269 for (value_type* __p = __begin_; __p != __end_; ++__p)
3274 template <class _Tp>
3275 inline _LIBCPP_INLINE_VISIBILITY
3277 valarray<_Tp>::operator<<=(const value_type& __x)
3279 for (value_type* __p = __begin_; __p != __end_; ++__p)
3284 template <class _Tp>
3285 inline _LIBCPP_INLINE_VISIBILITY
3287 valarray<_Tp>::operator>>=(const value_type& __x)
3289 for (value_type* __p = __begin_; __p != __end_; ++__p)
3294 template <class _Tp>
3295 template <class _Expr>
3296 inline _LIBCPP_INLINE_VISIBILITY
3299 __is_val_expr<_Expr>::value,
3302 valarray<_Tp>::operator*=(const _Expr& __v)
3305 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3310 template <class _Tp>
3311 template <class _Expr>
3312 inline _LIBCPP_INLINE_VISIBILITY
3315 __is_val_expr<_Expr>::value,
3318 valarray<_Tp>::operator/=(const _Expr& __v)
3321 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3326 template <class _Tp>
3327 template <class _Expr>
3328 inline _LIBCPP_INLINE_VISIBILITY
3331 __is_val_expr<_Expr>::value,
3334 valarray<_Tp>::operator%=(const _Expr& __v)
3337 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3342 template <class _Tp>
3343 template <class _Expr>
3344 inline _LIBCPP_INLINE_VISIBILITY
3347 __is_val_expr<_Expr>::value,
3350 valarray<_Tp>::operator+=(const _Expr& __v)
3353 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3358 template <class _Tp>
3359 template <class _Expr>
3360 inline _LIBCPP_INLINE_VISIBILITY
3363 __is_val_expr<_Expr>::value,
3366 valarray<_Tp>::operator-=(const _Expr& __v)
3369 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3374 template <class _Tp>
3375 template <class _Expr>
3376 inline _LIBCPP_INLINE_VISIBILITY
3379 __is_val_expr<_Expr>::value,
3382 valarray<_Tp>::operator^=(const _Expr& __v)
3385 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3390 template <class _Tp>
3391 template <class _Expr>
3392 inline _LIBCPP_INLINE_VISIBILITY
3395 __is_val_expr<_Expr>::value,
3398 valarray<_Tp>::operator|=(const _Expr& __v)
3401 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3406 template <class _Tp>
3407 template <class _Expr>
3408 inline _LIBCPP_INLINE_VISIBILITY
3411 __is_val_expr<_Expr>::value,
3414 valarray<_Tp>::operator&=(const _Expr& __v)
3417 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3422 template <class _Tp>
3423 template <class _Expr>
3424 inline _LIBCPP_INLINE_VISIBILITY
3427 __is_val_expr<_Expr>::value,
3430 valarray<_Tp>::operator<<=(const _Expr& __v)
3433 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3438 template <class _Tp>
3439 template <class _Expr>
3440 inline _LIBCPP_INLINE_VISIBILITY
3443 __is_val_expr<_Expr>::value,
3446 valarray<_Tp>::operator>>=(const _Expr& __v)
3449 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3454 template <class _Tp>
3455 inline _LIBCPP_INLINE_VISIBILITY
3457 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3459 _VSTD::swap(__begin_, __v.__begin_);
3460 _VSTD::swap(__end_, __v.__end_);
3463 template <class _Tp>
3464 inline _LIBCPP_INLINE_VISIBILITY
3466 valarray<_Tp>::sum() const
3468 if (__begin_ == __end_)
3469 return value_type();
3470 const value_type* __p = __begin_;
3472 for (++__p; __p != __end_; ++__p)
3477 template <class _Tp>
3478 inline _LIBCPP_INLINE_VISIBILITY
3480 valarray<_Tp>::min() const
3482 if (__begin_ == __end_)
3483 return value_type();
3484 return *_VSTD::min_element(__begin_, __end_);
3487 template <class _Tp>
3488 inline _LIBCPP_INLINE_VISIBILITY
3490 valarray<_Tp>::max() const
3492 if (__begin_ == __end_)
3493 return value_type();
3494 return *_VSTD::max_element(__begin_, __end_);
3497 template <class _Tp>
3499 valarray<_Tp>::shift(int __i) const
3501 valarray<value_type> __r;
3502 size_t __n = size();
3507 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3508 const value_type* __sb;
3513 __i = _VSTD::min(__i, static_cast<int>(__n));
3514 __sb = __begin_ + __i;
3515 __tb = __r.__begin_;
3516 __te = __r.__begin_ + (__n - __i);
3520 __i = _VSTD::min(-__i, static_cast<int>(__n));
3522 __tb = __r.__begin_ + __i;
3523 __te = __r.__begin_ + __n;
3525 for (; __r.__end_ != __tb; ++__r.__end_)
3526 ::new (__r.__end_) value_type();
3527 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3528 ::new (__r.__end_) value_type(*__sb);
3529 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3530 ::new (__r.__end_) value_type();
3535 template <class _Tp>
3537 valarray<_Tp>::cshift(int __i) const
3539 valarray<value_type> __r;
3540 size_t __n = size();
3545 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3546 __i %= static_cast<int>(__n);
3547 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3548 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3549 ::new (__r.__end_) value_type(*__s);
3550 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3551 ::new (__r.__end_) value_type(*__s);
3556 template <class _Tp>
3558 valarray<_Tp>::apply(value_type __f(value_type)) const
3560 valarray<value_type> __r;
3561 size_t __n = size();
3566 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3567 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3568 ::new (__r.__end_) value_type(__f(*__p));
3573 template <class _Tp>
3575 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3577 valarray<value_type> __r;
3578 size_t __n = size();
3583 static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3584 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3585 ::new (__r.__end_) value_type(__f(*__p));
3590 template <class _Tp>
3592 valarray<_Tp>::resize(size_t __n, value_type __x)
3594 if (__begin_ != nullptr)
3596 while (__end_ != __begin_)
3597 (--__end_)->~value_type();
3598 ::operator delete(__begin_);
3599 __begin_ = __end_ = nullptr;
3603 __begin_ = __end_ = static_cast<value_type*>(::operator new(__n * sizeof(value_type)));
3604 #ifndef _LIBCPP_NO_EXCEPTIONS
3607 #endif // _LIBCPP_NO_EXCEPTIONS
3608 for (; __n; --__n, ++__end_)
3609 ::new (__end_) value_type(__x);
3610 #ifndef _LIBCPP_NO_EXCEPTIONS
3617 #endif // _LIBCPP_NO_EXCEPTIONS
3622 inline _LIBCPP_INLINE_VISIBILITY
3624 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3629 template<class _Expr1, class _Expr2>
3630 inline _LIBCPP_INLINE_VISIBILITY
3633 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3634 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3636 operator*(const _Expr1& __x, const _Expr2& __y)
3638 typedef typename _Expr1::value_type value_type;
3639 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3640 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3643 template<class _Expr>
3644 inline _LIBCPP_INLINE_VISIBILITY
3647 __is_val_expr<_Expr>::value,
3648 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3649 _Expr, __scalar_expr<typename _Expr::value_type> > >
3651 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3653 typedef typename _Expr::value_type value_type;
3654 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3655 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3656 __x, __scalar_expr<value_type>(__y, __x.size())));
3659 template<class _Expr>
3660 inline _LIBCPP_INLINE_VISIBILITY
3663 __is_val_expr<_Expr>::value,
3664 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3665 __scalar_expr<typename _Expr::value_type>, _Expr> >
3667 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3669 typedef typename _Expr::value_type value_type;
3670 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3671 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3672 __scalar_expr<value_type>(__x, __y.size()), __y));
3675 template<class _Expr1, class _Expr2>
3676 inline _LIBCPP_INLINE_VISIBILITY
3679 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3680 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3682 operator/(const _Expr1& __x, const _Expr2& __y)
3684 typedef typename _Expr1::value_type value_type;
3685 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3686 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3689 template<class _Expr>
3690 inline _LIBCPP_INLINE_VISIBILITY
3693 __is_val_expr<_Expr>::value,
3694 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3695 _Expr, __scalar_expr<typename _Expr::value_type> > >
3697 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3699 typedef typename _Expr::value_type value_type;
3700 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3701 return __val_expr<_Op>(_Op(divides<value_type>(),
3702 __x, __scalar_expr<value_type>(__y, __x.size())));
3705 template<class _Expr>
3706 inline _LIBCPP_INLINE_VISIBILITY
3709 __is_val_expr<_Expr>::value,
3710 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3711 __scalar_expr<typename _Expr::value_type>, _Expr> >
3713 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3715 typedef typename _Expr::value_type value_type;
3716 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3717 return __val_expr<_Op>(_Op(divides<value_type>(),
3718 __scalar_expr<value_type>(__x, __y.size()), __y));
3721 template<class _Expr1, class _Expr2>
3722 inline _LIBCPP_INLINE_VISIBILITY
3725 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3726 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3728 operator%(const _Expr1& __x, const _Expr2& __y)
3730 typedef typename _Expr1::value_type value_type;
3731 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3732 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3735 template<class _Expr>
3736 inline _LIBCPP_INLINE_VISIBILITY
3739 __is_val_expr<_Expr>::value,
3740 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3741 _Expr, __scalar_expr<typename _Expr::value_type> > >
3743 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3745 typedef typename _Expr::value_type value_type;
3746 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3747 return __val_expr<_Op>(_Op(modulus<value_type>(),
3748 __x, __scalar_expr<value_type>(__y, __x.size())));
3751 template<class _Expr>
3752 inline _LIBCPP_INLINE_VISIBILITY
3755 __is_val_expr<_Expr>::value,
3756 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3757 __scalar_expr<typename _Expr::value_type>, _Expr> >
3759 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3761 typedef typename _Expr::value_type value_type;
3762 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3763 return __val_expr<_Op>(_Op(modulus<value_type>(),
3764 __scalar_expr<value_type>(__x, __y.size()), __y));
3767 template<class _Expr1, class _Expr2>
3768 inline _LIBCPP_INLINE_VISIBILITY
3771 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3772 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3774 operator+(const _Expr1& __x, const _Expr2& __y)
3776 typedef typename _Expr1::value_type value_type;
3777 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3778 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3781 template<class _Expr>
3782 inline _LIBCPP_INLINE_VISIBILITY
3785 __is_val_expr<_Expr>::value,
3786 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3787 _Expr, __scalar_expr<typename _Expr::value_type> > >
3789 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3791 typedef typename _Expr::value_type value_type;
3792 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3793 return __val_expr<_Op>(_Op(plus<value_type>(),
3794 __x, __scalar_expr<value_type>(__y, __x.size())));
3797 template<class _Expr>
3798 inline _LIBCPP_INLINE_VISIBILITY
3801 __is_val_expr<_Expr>::value,
3802 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3803 __scalar_expr<typename _Expr::value_type>, _Expr> >
3805 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3807 typedef typename _Expr::value_type value_type;
3808 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3809 return __val_expr<_Op>(_Op(plus<value_type>(),
3810 __scalar_expr<value_type>(__x, __y.size()), __y));
3813 template<class _Expr1, class _Expr2>
3814 inline _LIBCPP_INLINE_VISIBILITY
3817 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3818 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3820 operator-(const _Expr1& __x, const _Expr2& __y)
3822 typedef typename _Expr1::value_type value_type;
3823 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3824 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3827 template<class _Expr>
3828 inline _LIBCPP_INLINE_VISIBILITY
3831 __is_val_expr<_Expr>::value,
3832 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3833 _Expr, __scalar_expr<typename _Expr::value_type> > >
3835 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3837 typedef typename _Expr::value_type value_type;
3838 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3839 return __val_expr<_Op>(_Op(minus<value_type>(),
3840 __x, __scalar_expr<value_type>(__y, __x.size())));
3843 template<class _Expr>
3844 inline _LIBCPP_INLINE_VISIBILITY
3847 __is_val_expr<_Expr>::value,
3848 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3849 __scalar_expr<typename _Expr::value_type>, _Expr> >
3851 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3853 typedef typename _Expr::value_type value_type;
3854 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3855 return __val_expr<_Op>(_Op(minus<value_type>(),
3856 __scalar_expr<value_type>(__x, __y.size()), __y));
3859 template<class _Expr1, class _Expr2>
3860 inline _LIBCPP_INLINE_VISIBILITY
3863 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3864 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3866 operator^(const _Expr1& __x, const _Expr2& __y)
3868 typedef typename _Expr1::value_type value_type;
3869 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3870 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3873 template<class _Expr>
3874 inline _LIBCPP_INLINE_VISIBILITY
3877 __is_val_expr<_Expr>::value,
3878 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3879 _Expr, __scalar_expr<typename _Expr::value_type> > >
3881 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3883 typedef typename _Expr::value_type value_type;
3884 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3885 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3886 __x, __scalar_expr<value_type>(__y, __x.size())));
3889 template<class _Expr>
3890 inline _LIBCPP_INLINE_VISIBILITY
3893 __is_val_expr<_Expr>::value,
3894 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3895 __scalar_expr<typename _Expr::value_type>, _Expr> >
3897 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
3899 typedef typename _Expr::value_type value_type;
3900 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3901 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3902 __scalar_expr<value_type>(__x, __y.size()), __y));
3905 template<class _Expr1, class _Expr2>
3906 inline _LIBCPP_INLINE_VISIBILITY
3909 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3910 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
3912 operator&(const _Expr1& __x, const _Expr2& __y)
3914 typedef typename _Expr1::value_type value_type;
3915 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
3916 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
3919 template<class _Expr>
3920 inline _LIBCPP_INLINE_VISIBILITY
3923 __is_val_expr<_Expr>::value,
3924 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3925 _Expr, __scalar_expr<typename _Expr::value_type> > >
3927 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
3929 typedef typename _Expr::value_type value_type;
3930 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3931 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3932 __x, __scalar_expr<value_type>(__y, __x.size())));
3935 template<class _Expr>
3936 inline _LIBCPP_INLINE_VISIBILITY
3939 __is_val_expr<_Expr>::value,
3940 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
3941 __scalar_expr<typename _Expr::value_type>, _Expr> >
3943 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
3945 typedef typename _Expr::value_type value_type;
3946 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3947 return __val_expr<_Op>(_Op(bit_and<value_type>(),
3948 __scalar_expr<value_type>(__x, __y.size()), __y));
3951 template<class _Expr1, class _Expr2>
3952 inline _LIBCPP_INLINE_VISIBILITY
3955 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3956 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
3958 operator|(const _Expr1& __x, const _Expr2& __y)
3960 typedef typename _Expr1::value_type value_type;
3961 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
3962 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
3965 template<class _Expr>
3966 inline _LIBCPP_INLINE_VISIBILITY
3969 __is_val_expr<_Expr>::value,
3970 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3971 _Expr, __scalar_expr<typename _Expr::value_type> > >
3973 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
3975 typedef typename _Expr::value_type value_type;
3976 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3977 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3978 __x, __scalar_expr<value_type>(__y, __x.size())));
3981 template<class _Expr>
3982 inline _LIBCPP_INLINE_VISIBILITY
3985 __is_val_expr<_Expr>::value,
3986 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
3987 __scalar_expr<typename _Expr::value_type>, _Expr> >
3989 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
3991 typedef typename _Expr::value_type value_type;
3992 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3993 return __val_expr<_Op>(_Op(bit_or<value_type>(),
3994 __scalar_expr<value_type>(__x, __y.size()), __y));
3997 template<class _Expr1, class _Expr2>
3998 inline _LIBCPP_INLINE_VISIBILITY
4001 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4002 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4004 operator<<(const _Expr1& __x, const _Expr2& __y)
4006 typedef typename _Expr1::value_type value_type;
4007 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4008 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4011 template<class _Expr>
4012 inline _LIBCPP_INLINE_VISIBILITY
4015 __is_val_expr<_Expr>::value,
4016 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4017 _Expr, __scalar_expr<typename _Expr::value_type> > >
4019 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4021 typedef typename _Expr::value_type value_type;
4022 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4023 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4024 __x, __scalar_expr<value_type>(__y, __x.size())));
4027 template<class _Expr>
4028 inline _LIBCPP_INLINE_VISIBILITY
4031 __is_val_expr<_Expr>::value,
4032 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4033 __scalar_expr<typename _Expr::value_type>, _Expr> >
4035 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4037 typedef typename _Expr::value_type value_type;
4038 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4039 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4040 __scalar_expr<value_type>(__x, __y.size()), __y));
4043 template<class _Expr1, class _Expr2>
4044 inline _LIBCPP_INLINE_VISIBILITY
4047 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4048 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4050 operator>>(const _Expr1& __x, const _Expr2& __y)
4052 typedef typename _Expr1::value_type value_type;
4053 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4054 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4057 template<class _Expr>
4058 inline _LIBCPP_INLINE_VISIBILITY
4061 __is_val_expr<_Expr>::value,
4062 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4063 _Expr, __scalar_expr<typename _Expr::value_type> > >
4065 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4067 typedef typename _Expr::value_type value_type;
4068 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4069 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4070 __x, __scalar_expr<value_type>(__y, __x.size())));
4073 template<class _Expr>
4074 inline _LIBCPP_INLINE_VISIBILITY
4077 __is_val_expr<_Expr>::value,
4078 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4079 __scalar_expr<typename _Expr::value_type>, _Expr> >
4081 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4083 typedef typename _Expr::value_type value_type;
4084 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4085 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4086 __scalar_expr<value_type>(__x, __y.size()), __y));
4089 template<class _Expr1, class _Expr2>
4090 inline _LIBCPP_INLINE_VISIBILITY
4093 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4094 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4096 operator&&(const _Expr1& __x, const _Expr2& __y)
4098 typedef typename _Expr1::value_type value_type;
4099 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4100 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4103 template<class _Expr>
4104 inline _LIBCPP_INLINE_VISIBILITY
4107 __is_val_expr<_Expr>::value,
4108 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4109 _Expr, __scalar_expr<typename _Expr::value_type> > >
4111 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4113 typedef typename _Expr::value_type value_type;
4114 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4115 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4116 __x, __scalar_expr<value_type>(__y, __x.size())));
4119 template<class _Expr>
4120 inline _LIBCPP_INLINE_VISIBILITY
4123 __is_val_expr<_Expr>::value,
4124 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4125 __scalar_expr<typename _Expr::value_type>, _Expr> >
4127 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4129 typedef typename _Expr::value_type value_type;
4130 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4131 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4132 __scalar_expr<value_type>(__x, __y.size()), __y));
4135 template<class _Expr1, class _Expr2>
4136 inline _LIBCPP_INLINE_VISIBILITY
4139 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4140 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4142 operator||(const _Expr1& __x, const _Expr2& __y)
4144 typedef typename _Expr1::value_type value_type;
4145 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4146 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4149 template<class _Expr>
4150 inline _LIBCPP_INLINE_VISIBILITY
4153 __is_val_expr<_Expr>::value,
4154 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4155 _Expr, __scalar_expr<typename _Expr::value_type> > >
4157 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4159 typedef typename _Expr::value_type value_type;
4160 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4161 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4162 __x, __scalar_expr<value_type>(__y, __x.size())));
4165 template<class _Expr>
4166 inline _LIBCPP_INLINE_VISIBILITY
4169 __is_val_expr<_Expr>::value,
4170 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4171 __scalar_expr<typename _Expr::value_type>, _Expr> >
4173 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4175 typedef typename _Expr::value_type value_type;
4176 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4177 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4178 __scalar_expr<value_type>(__x, __y.size()), __y));
4181 template<class _Expr1, class _Expr2>
4182 inline _LIBCPP_INLINE_VISIBILITY
4185 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4186 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4188 operator==(const _Expr1& __x, const _Expr2& __y)
4190 typedef typename _Expr1::value_type value_type;
4191 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4192 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4195 template<class _Expr>
4196 inline _LIBCPP_INLINE_VISIBILITY
4199 __is_val_expr<_Expr>::value,
4200 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4201 _Expr, __scalar_expr<typename _Expr::value_type> > >
4203 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4205 typedef typename _Expr::value_type value_type;
4206 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4207 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4208 __x, __scalar_expr<value_type>(__y, __x.size())));
4211 template<class _Expr>
4212 inline _LIBCPP_INLINE_VISIBILITY
4215 __is_val_expr<_Expr>::value,
4216 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4217 __scalar_expr<typename _Expr::value_type>, _Expr> >
4219 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4221 typedef typename _Expr::value_type value_type;
4222 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4223 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4224 __scalar_expr<value_type>(__x, __y.size()), __y));
4227 template<class _Expr1, class _Expr2>
4228 inline _LIBCPP_INLINE_VISIBILITY
4231 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4232 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4234 operator!=(const _Expr1& __x, const _Expr2& __y)
4236 typedef typename _Expr1::value_type value_type;
4237 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4238 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4241 template<class _Expr>
4242 inline _LIBCPP_INLINE_VISIBILITY
4245 __is_val_expr<_Expr>::value,
4246 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4247 _Expr, __scalar_expr<typename _Expr::value_type> > >
4249 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4251 typedef typename _Expr::value_type value_type;
4252 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4253 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4254 __x, __scalar_expr<value_type>(__y, __x.size())));
4257 template<class _Expr>
4258 inline _LIBCPP_INLINE_VISIBILITY
4261 __is_val_expr<_Expr>::value,
4262 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4263 __scalar_expr<typename _Expr::value_type>, _Expr> >
4265 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4267 typedef typename _Expr::value_type value_type;
4268 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4269 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4270 __scalar_expr<value_type>(__x, __y.size()), __y));
4273 template<class _Expr1, class _Expr2>
4274 inline _LIBCPP_INLINE_VISIBILITY
4277 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4278 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4280 operator<(const _Expr1& __x, const _Expr2& __y)
4282 typedef typename _Expr1::value_type value_type;
4283 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4284 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4287 template<class _Expr>
4288 inline _LIBCPP_INLINE_VISIBILITY
4291 __is_val_expr<_Expr>::value,
4292 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4293 _Expr, __scalar_expr<typename _Expr::value_type> > >
4295 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4297 typedef typename _Expr::value_type value_type;
4298 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4299 return __val_expr<_Op>(_Op(less<value_type>(),
4300 __x, __scalar_expr<value_type>(__y, __x.size())));
4303 template<class _Expr>
4304 inline _LIBCPP_INLINE_VISIBILITY
4307 __is_val_expr<_Expr>::value,
4308 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4309 __scalar_expr<typename _Expr::value_type>, _Expr> >
4311 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4313 typedef typename _Expr::value_type value_type;
4314 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4315 return __val_expr<_Op>(_Op(less<value_type>(),
4316 __scalar_expr<value_type>(__x, __y.size()), __y));
4319 template<class _Expr1, class _Expr2>
4320 inline _LIBCPP_INLINE_VISIBILITY
4323 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4324 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4326 operator>(const _Expr1& __x, const _Expr2& __y)
4328 typedef typename _Expr1::value_type value_type;
4329 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4330 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4333 template<class _Expr>
4334 inline _LIBCPP_INLINE_VISIBILITY
4337 __is_val_expr<_Expr>::value,
4338 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4339 _Expr, __scalar_expr<typename _Expr::value_type> > >
4341 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4343 typedef typename _Expr::value_type value_type;
4344 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4345 return __val_expr<_Op>(_Op(greater<value_type>(),
4346 __x, __scalar_expr<value_type>(__y, __x.size())));
4349 template<class _Expr>
4350 inline _LIBCPP_INLINE_VISIBILITY
4353 __is_val_expr<_Expr>::value,
4354 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4355 __scalar_expr<typename _Expr::value_type>, _Expr> >
4357 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4359 typedef typename _Expr::value_type value_type;
4360 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4361 return __val_expr<_Op>(_Op(greater<value_type>(),
4362 __scalar_expr<value_type>(__x, __y.size()), __y));
4365 template<class _Expr1, class _Expr2>
4366 inline _LIBCPP_INLINE_VISIBILITY
4369 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4370 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4372 operator<=(const _Expr1& __x, const _Expr2& __y)
4374 typedef typename _Expr1::value_type value_type;
4375 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4376 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4379 template<class _Expr>
4380 inline _LIBCPP_INLINE_VISIBILITY
4383 __is_val_expr<_Expr>::value,
4384 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4385 _Expr, __scalar_expr<typename _Expr::value_type> > >
4387 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4389 typedef typename _Expr::value_type value_type;
4390 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4391 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4392 __x, __scalar_expr<value_type>(__y, __x.size())));
4395 template<class _Expr>
4396 inline _LIBCPP_INLINE_VISIBILITY
4399 __is_val_expr<_Expr>::value,
4400 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4401 __scalar_expr<typename _Expr::value_type>, _Expr> >
4403 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4405 typedef typename _Expr::value_type value_type;
4406 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4407 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4408 __scalar_expr<value_type>(__x, __y.size()), __y));
4411 template<class _Expr1, class _Expr2>
4412 inline _LIBCPP_INLINE_VISIBILITY
4415 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4416 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4418 operator>=(const _Expr1& __x, const _Expr2& __y)
4420 typedef typename _Expr1::value_type value_type;
4421 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4422 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4425 template<class _Expr>
4426 inline _LIBCPP_INLINE_VISIBILITY
4429 __is_val_expr<_Expr>::value,
4430 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4431 _Expr, __scalar_expr<typename _Expr::value_type> > >
4433 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4435 typedef typename _Expr::value_type value_type;
4436 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4437 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4438 __x, __scalar_expr<value_type>(__y, __x.size())));
4441 template<class _Expr>
4442 inline _LIBCPP_INLINE_VISIBILITY
4445 __is_val_expr<_Expr>::value,
4446 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4447 __scalar_expr<typename _Expr::value_type>, _Expr> >
4449 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4451 typedef typename _Expr::value_type value_type;
4452 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4453 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4454 __scalar_expr<value_type>(__x, __y.size()), __y));
4457 template<class _Expr>
4458 inline _LIBCPP_INLINE_VISIBILITY
4461 __is_val_expr<_Expr>::value,
4462 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4464 abs(const _Expr& __x)
4466 typedef typename _Expr::value_type value_type;
4467 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4468 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4471 template<class _Expr>
4472 inline _LIBCPP_INLINE_VISIBILITY
4475 __is_val_expr<_Expr>::value,
4476 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4478 acos(const _Expr& __x)
4480 typedef typename _Expr::value_type value_type;
4481 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4482 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4485 template<class _Expr>
4486 inline _LIBCPP_INLINE_VISIBILITY
4489 __is_val_expr<_Expr>::value,
4490 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4492 asin(const _Expr& __x)
4494 typedef typename _Expr::value_type value_type;
4495 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4496 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4499 template<class _Expr>
4500 inline _LIBCPP_INLINE_VISIBILITY
4503 __is_val_expr<_Expr>::value,
4504 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4506 atan(const _Expr& __x)
4508 typedef typename _Expr::value_type value_type;
4509 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4510 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4513 template<class _Expr1, class _Expr2>
4514 inline _LIBCPP_INLINE_VISIBILITY
4517 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4518 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4520 atan2(const _Expr1& __x, const _Expr2& __y)
4522 typedef typename _Expr1::value_type value_type;
4523 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4524 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4527 template<class _Expr>
4528 inline _LIBCPP_INLINE_VISIBILITY
4531 __is_val_expr<_Expr>::value,
4532 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4533 _Expr, __scalar_expr<typename _Expr::value_type> > >
4535 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4537 typedef typename _Expr::value_type value_type;
4538 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4539 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4540 __x, __scalar_expr<value_type>(__y, __x.size())));
4543 template<class _Expr>
4544 inline _LIBCPP_INLINE_VISIBILITY
4547 __is_val_expr<_Expr>::value,
4548 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4549 __scalar_expr<typename _Expr::value_type>, _Expr> >
4551 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4553 typedef typename _Expr::value_type value_type;
4554 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4555 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4556 __scalar_expr<value_type>(__x, __y.size()), __y));
4559 template<class _Expr>
4560 inline _LIBCPP_INLINE_VISIBILITY
4563 __is_val_expr<_Expr>::value,
4564 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4566 cos(const _Expr& __x)
4568 typedef typename _Expr::value_type value_type;
4569 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4570 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4573 template<class _Expr>
4574 inline _LIBCPP_INLINE_VISIBILITY
4577 __is_val_expr<_Expr>::value,
4578 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4580 cosh(const _Expr& __x)
4582 typedef typename _Expr::value_type value_type;
4583 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4584 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4587 template<class _Expr>
4588 inline _LIBCPP_INLINE_VISIBILITY
4591 __is_val_expr<_Expr>::value,
4592 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4594 exp(const _Expr& __x)
4596 typedef typename _Expr::value_type value_type;
4597 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4598 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4601 template<class _Expr>
4602 inline _LIBCPP_INLINE_VISIBILITY
4605 __is_val_expr<_Expr>::value,
4606 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4608 log(const _Expr& __x)
4610 typedef typename _Expr::value_type value_type;
4611 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4612 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4615 template<class _Expr>
4616 inline _LIBCPP_INLINE_VISIBILITY
4619 __is_val_expr<_Expr>::value,
4620 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4622 log10(const _Expr& __x)
4624 typedef typename _Expr::value_type value_type;
4625 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4626 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4629 template<class _Expr1, class _Expr2>
4630 inline _LIBCPP_INLINE_VISIBILITY
4633 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4634 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4636 pow(const _Expr1& __x, const _Expr2& __y)
4638 typedef typename _Expr1::value_type value_type;
4639 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4640 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4643 template<class _Expr>
4644 inline _LIBCPP_INLINE_VISIBILITY
4647 __is_val_expr<_Expr>::value,
4648 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4649 _Expr, __scalar_expr<typename _Expr::value_type> > >
4651 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4653 typedef typename _Expr::value_type value_type;
4654 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4655 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4656 __x, __scalar_expr<value_type>(__y, __x.size())));
4659 template<class _Expr>
4660 inline _LIBCPP_INLINE_VISIBILITY
4663 __is_val_expr<_Expr>::value,
4664 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4665 __scalar_expr<typename _Expr::value_type>, _Expr> >
4667 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4669 typedef typename _Expr::value_type value_type;
4670 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4671 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4672 __scalar_expr<value_type>(__x, __y.size()), __y));
4675 template<class _Expr>
4676 inline _LIBCPP_INLINE_VISIBILITY
4679 __is_val_expr<_Expr>::value,
4680 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4682 sin(const _Expr& __x)
4684 typedef typename _Expr::value_type value_type;
4685 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4686 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4689 template<class _Expr>
4690 inline _LIBCPP_INLINE_VISIBILITY
4693 __is_val_expr<_Expr>::value,
4694 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4696 sinh(const _Expr& __x)
4698 typedef typename _Expr::value_type value_type;
4699 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4700 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4703 template<class _Expr>
4704 inline _LIBCPP_INLINE_VISIBILITY
4707 __is_val_expr<_Expr>::value,
4708 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4710 sqrt(const _Expr& __x)
4712 typedef typename _Expr::value_type value_type;
4713 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4714 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4717 template<class _Expr>
4718 inline _LIBCPP_INLINE_VISIBILITY
4721 __is_val_expr<_Expr>::value,
4722 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4724 tan(const _Expr& __x)
4726 typedef typename _Expr::value_type value_type;
4727 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4728 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4731 template<class _Expr>
4732 inline _LIBCPP_INLINE_VISIBILITY
4735 __is_val_expr<_Expr>::value,
4736 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4738 tanh(const _Expr& __x)
4740 typedef typename _Expr::value_type value_type;
4741 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4742 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4745 template <class _Tp>
4746 inline _LIBCPP_INLINE_VISIBILITY
4748 begin(valarray<_Tp>& __v)
4750 return __v.__begin_;
4753 template <class _Tp>
4754 inline _LIBCPP_INLINE_VISIBILITY
4756 begin(const valarray<_Tp>& __v)
4758 return __v.__begin_;
4761 template <class _Tp>
4762 inline _LIBCPP_INLINE_VISIBILITY
4764 end(valarray<_Tp>& __v)
4769 template <class _Tp>
4770 inline _LIBCPP_INLINE_VISIBILITY
4772 end(const valarray<_Tp>& __v)
4777 _LIBCPP_END_NAMESPACE_STD
4779 #endif // _LIBCPP_VALARRAY