2 //===-------------------------- valarray ----------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_VALARRAY
12 #define _LIBCPP_VALARRAY
28 explicit valarray(size_t n);
29 valarray(const value_type& x, size_t n);
30 valarray(const value_type* px, size_t n);
31 valarray(const valarray& v);
32 valarray(valarray&& v) noexcept;
33 valarray(const slice_array<value_type>& sa);
34 valarray(const gslice_array<value_type>& ga);
35 valarray(const mask_array<value_type>& ma);
36 valarray(const indirect_array<value_type>& ia);
37 valarray(initializer_list<value_type> il);
41 valarray& operator=(const valarray& v);
42 valarray& operator=(valarray&& v) noexcept;
43 valarray& operator=(initializer_list<value_type> il);
44 valarray& operator=(const value_type& x);
45 valarray& operator=(const slice_array<value_type>& sa);
46 valarray& operator=(const gslice_array<value_type>& ga);
47 valarray& operator=(const mask_array<value_type>& ma);
48 valarray& operator=(const indirect_array<value_type>& ia);
51 const value_type& operator[](size_t i) const;
52 value_type& operator[](size_t i);
55 valarray operator[](slice s) const;
56 slice_array<value_type> operator[](slice s);
57 valarray operator[](const gslice& gs) const;
58 gslice_array<value_type> operator[](const gslice& gs);
59 valarray operator[](const valarray<bool>& vb) const;
60 mask_array<value_type> operator[](const valarray<bool>& vb);
61 valarray operator[](const valarray<size_t>& vs) const;
62 indirect_array<value_type> operator[](const valarray<size_t>& vs);
65 valarray operator+() const;
66 valarray operator-() const;
67 valarray operator~() const;
68 valarray<bool> operator!() const;
70 // computed assignment:
71 valarray& operator*= (const value_type& x);
72 valarray& operator/= (const value_type& x);
73 valarray& operator%= (const value_type& x);
74 valarray& operator+= (const value_type& x);
75 valarray& operator-= (const value_type& x);
76 valarray& operator^= (const value_type& x);
77 valarray& operator&= (const value_type& x);
78 valarray& operator|= (const value_type& x);
79 valarray& operator<<=(const value_type& x);
80 valarray& operator>>=(const value_type& x);
82 valarray& operator*= (const valarray& v);
83 valarray& operator/= (const valarray& v);
84 valarray& operator%= (const valarray& v);
85 valarray& operator+= (const valarray& v);
86 valarray& operator-= (const valarray& v);
87 valarray& operator^= (const valarray& v);
88 valarray& operator|= (const valarray& v);
89 valarray& operator&= (const valarray& v);
90 valarray& operator<<=(const valarray& v);
91 valarray& operator>>=(const valarray& v);
94 void swap(valarray& v) noexcept;
98 value_type sum() const;
99 value_type min() const;
100 value_type max() const;
102 valarray shift (int i) const;
103 valarray cshift(int i) const;
104 valarray apply(value_type f(value_type)) const;
105 valarray apply(value_type f(const value_type&)) const;
106 void resize(size_t n, value_type x = value_type());
113 slice(size_t start, size_t size, size_t stride);
115 size_t start() const;
117 size_t stride() const;
124 typedef T value_type;
126 const slice_array& operator=(const slice_array& sa) const;
127 void operator= (const valarray<value_type>& v) const;
128 void operator*= (const valarray<value_type>& v) const;
129 void operator/= (const valarray<value_type>& v) const;
130 void operator%= (const valarray<value_type>& v) const;
131 void operator+= (const valarray<value_type>& v) const;
132 void operator-= (const valarray<value_type>& v) const;
133 void operator^= (const valarray<value_type>& v) const;
134 void operator&= (const valarray<value_type>& v) const;
135 void operator|= (const valarray<value_type>& v) const;
136 void operator<<=(const valarray<value_type>& v) const;
137 void operator>>=(const valarray<value_type>& v) const;
139 void operator=(const value_type& x) const;
141 slice_array() = delete;
148 gslice(size_t start, const valarray<size_t>& size,
149 const valarray<size_t>& stride);
151 size_t start() const;
152 valarray<size_t> size() const;
153 valarray<size_t> stride() const;
160 typedef T value_type;
162 void operator= (const valarray<value_type>& v) const;
163 void operator*= (const valarray<value_type>& v) const;
164 void operator/= (const valarray<value_type>& v) const;
165 void operator%= (const valarray<value_type>& v) const;
166 void operator+= (const valarray<value_type>& v) const;
167 void operator-= (const valarray<value_type>& v) const;
168 void operator^= (const valarray<value_type>& v) const;
169 void operator&= (const valarray<value_type>& v) const;
170 void operator|= (const valarray<value_type>& v) const;
171 void operator<<=(const valarray<value_type>& v) const;
172 void operator>>=(const valarray<value_type>& v) const;
174 gslice_array(const gslice_array& ga);
176 const gslice_array& operator=(const gslice_array& ga) const;
177 void operator=(const value_type& x) const;
179 gslice_array() = delete;
186 typedef T value_type;
188 void operator= (const valarray<value_type>& v) const;
189 void operator*= (const valarray<value_type>& v) const;
190 void operator/= (const valarray<value_type>& v) const;
191 void operator%= (const valarray<value_type>& v) const;
192 void operator+= (const valarray<value_type>& v) const;
193 void operator-= (const valarray<value_type>& v) const;
194 void operator^= (const valarray<value_type>& v) const;
195 void operator&= (const valarray<value_type>& v) const;
196 void operator|= (const valarray<value_type>& v) const;
197 void operator<<=(const valarray<value_type>& v) const;
198 void operator>>=(const valarray<value_type>& v) const;
200 mask_array(const mask_array& ma);
202 const mask_array& operator=(const mask_array& ma) const;
203 void operator=(const value_type& x) const;
205 mask_array() = delete;
212 typedef T value_type;
214 void operator= (const valarray<value_type>& v) const;
215 void operator*= (const valarray<value_type>& v) const;
216 void operator/= (const valarray<value_type>& v) const;
217 void operator%= (const valarray<value_type>& v) const;
218 void operator+= (const valarray<value_type>& v) const;
219 void operator-= (const valarray<value_type>& v) const;
220 void operator^= (const valarray<value_type>& v) const;
221 void operator&= (const valarray<value_type>& v) const;
222 void operator|= (const valarray<value_type>& v) const;
223 void operator<<=(const valarray<value_type>& v) const;
224 void operator>>=(const valarray<value_type>& v) const;
226 indirect_array(const indirect_array& ia);
228 const indirect_array& operator=(const indirect_array& ia) const;
229 void operator=(const value_type& x) const;
231 indirect_array() = delete;
234 template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept;
236 template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y);
237 template<class T> valarray<T> operator* (const valarray<T>& x, const T& y);
238 template<class T> valarray<T> operator* (const T& x, const valarray<T>& y);
240 template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y);
241 template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y);
242 template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y);
244 template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y);
245 template<class T> valarray<T> operator% (const valarray<T>& x, const T& y);
246 template<class T> valarray<T> operator% (const T& x, const valarray<T>& y);
248 template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y);
249 template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y);
250 template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y);
252 template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y);
253 template<class T> valarray<T> operator- (const valarray<T>& x, const T& y);
254 template<class T> valarray<T> operator- (const T& x, const valarray<T>& y);
256 template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y);
257 template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y);
258 template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y);
260 template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y);
261 template<class T> valarray<T> operator& (const valarray<T>& x, const T& y);
262 template<class T> valarray<T> operator& (const T& x, const valarray<T>& y);
264 template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y);
265 template<class T> valarray<T> operator| (const valarray<T>& x, const T& y);
266 template<class T> valarray<T> operator| (const T& x, const valarray<T>& y);
268 template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y);
269 template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y);
270 template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y);
272 template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y);
273 template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y);
274 template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y);
276 template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y);
277 template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y);
278 template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y);
280 template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y);
281 template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y);
282 template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y);
284 template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y);
285 template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y);
286 template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y);
288 template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y);
289 template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y);
290 template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y);
292 template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y);
293 template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y);
294 template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y);
296 template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y);
297 template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y);
298 template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y);
300 template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y);
301 template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y);
302 template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y);
304 template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y);
305 template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y);
306 template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y);
308 template<class T> valarray<T> abs (const valarray<T>& x);
309 template<class T> valarray<T> acos (const valarray<T>& x);
310 template<class T> valarray<T> asin (const valarray<T>& x);
311 template<class T> valarray<T> atan (const valarray<T>& x);
313 template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y);
314 template<class T> valarray<T> atan2(const valarray<T>& x, const T& y);
315 template<class T> valarray<T> atan2(const T& x, const valarray<T>& y);
317 template<class T> valarray<T> cos (const valarray<T>& x);
318 template<class T> valarray<T> cosh (const valarray<T>& x);
319 template<class T> valarray<T> exp (const valarray<T>& x);
320 template<class T> valarray<T> log (const valarray<T>& x);
321 template<class T> valarray<T> log10(const valarray<T>& x);
323 template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y);
324 template<class T> valarray<T> pow(const valarray<T>& x, const T& y);
325 template<class T> valarray<T> pow(const T& x, const valarray<T>& y);
327 template<class T> valarray<T> sin (const valarray<T>& x);
328 template<class T> valarray<T> sinh (const valarray<T>& x);
329 template<class T> valarray<T> sqrt (const valarray<T>& x);
330 template<class T> valarray<T> tan (const valarray<T>& x);
331 template<class T> valarray<T> tanh (const valarray<T>& x);
333 template <class T> unspecified1 begin(valarray<T>& v);
334 template <class T> unspecified2 begin(const valarray<T>& v);
335 template <class T> unspecified1 end(valarray<T>& v);
336 template <class T> unspecified2 end(const valarray<T>& v);
345 #include <initializer_list>
347 #include <functional>
350 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
351 #pragma GCC system_header
355 #include <__undef_macros>
358 _LIBCPP_BEGIN_NAMESPACE_STD
360 template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
362 class _LIBCPP_TEMPLATE_VIS slice
368 _LIBCPP_INLINE_VISIBILITY
375 _LIBCPP_INLINE_VISIBILITY
376 slice(size_t __start, size_t __size, size_t __stride)
382 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
383 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
384 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
387 template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
388 class _LIBCPP_TYPE_VIS gslice;
389 template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
390 template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
391 template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
394 _LIBCPP_INLINE_VISIBILITY
396 begin(valarray<_Tp>& __v);
399 _LIBCPP_INLINE_VISIBILITY
401 begin(const valarray<_Tp>& __v);
404 _LIBCPP_INLINE_VISIBILITY
406 end(valarray<_Tp>& __v);
409 _LIBCPP_INLINE_VISIBILITY
411 end(const valarray<_Tp>& __v);
413 template <class _Op, class _A0>
416 typedef typename _Op::result_type result_type;
417 typedef typename _A0::value_type value_type;
422 _LIBCPP_INLINE_VISIBILITY
423 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
425 _LIBCPP_INLINE_VISIBILITY
426 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
428 _LIBCPP_INLINE_VISIBILITY
429 size_t size() const {return __a0_.size();}
432 template <class _Op, class _A0, class _A1>
435 typedef typename _Op::result_type result_type;
436 typedef typename _A0::value_type value_type;
442 _LIBCPP_INLINE_VISIBILITY
443 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
444 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
446 _LIBCPP_INLINE_VISIBILITY
447 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
449 _LIBCPP_INLINE_VISIBILITY
450 size_t size() const {return __a0_.size();}
457 typedef _Tp value_type;
458 typedef const _Tp& result_type;
460 const value_type& __t_;
463 _LIBCPP_INLINE_VISIBILITY
464 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
466 _LIBCPP_INLINE_VISIBILITY
467 result_type operator[](size_t) const {return __t_;}
469 _LIBCPP_INLINE_VISIBILITY
470 size_t size() const {return __s_;}
474 struct __unary_plus : unary_function<_Tp, _Tp>
476 _LIBCPP_INLINE_VISIBILITY
477 _Tp operator()(const _Tp& __x) const
482 struct __bit_not : unary_function<_Tp, _Tp>
484 _LIBCPP_INLINE_VISIBILITY
485 _Tp operator()(const _Tp& __x) const
490 struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
492 _LIBCPP_INLINE_VISIBILITY
493 _Tp operator()(const _Tp& __x, const _Tp& __y) const
498 struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
500 _LIBCPP_INLINE_VISIBILITY
501 _Tp operator()(const _Tp& __x, const _Tp& __y) const
505 template <class _Tp, class _Fp>
506 struct __apply_expr : unary_function<_Tp, _Tp>
511 _LIBCPP_INLINE_VISIBILITY
512 explicit __apply_expr(_Fp __f) : __f_(__f) {}
514 _LIBCPP_INLINE_VISIBILITY
515 _Tp operator()(const _Tp& __x) const
520 struct __abs_expr : unary_function<_Tp, _Tp>
522 _LIBCPP_INLINE_VISIBILITY
523 _Tp operator()(const _Tp& __x) const
528 struct __acos_expr : unary_function<_Tp, _Tp>
530 _LIBCPP_INLINE_VISIBILITY
531 _Tp operator()(const _Tp& __x) const
536 struct __asin_expr : unary_function<_Tp, _Tp>
538 _LIBCPP_INLINE_VISIBILITY
539 _Tp operator()(const _Tp& __x) const
544 struct __atan_expr : unary_function<_Tp, _Tp>
546 _LIBCPP_INLINE_VISIBILITY
547 _Tp operator()(const _Tp& __x) const
552 struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
554 _LIBCPP_INLINE_VISIBILITY
555 _Tp operator()(const _Tp& __x, const _Tp& __y) const
556 {return atan2(__x, __y);}
560 struct __cos_expr : unary_function<_Tp, _Tp>
562 _LIBCPP_INLINE_VISIBILITY
563 _Tp operator()(const _Tp& __x) const
568 struct __cosh_expr : unary_function<_Tp, _Tp>
570 _LIBCPP_INLINE_VISIBILITY
571 _Tp operator()(const _Tp& __x) const
576 struct __exp_expr : unary_function<_Tp, _Tp>
578 _LIBCPP_INLINE_VISIBILITY
579 _Tp operator()(const _Tp& __x) const
584 struct __log_expr : unary_function<_Tp, _Tp>
586 _LIBCPP_INLINE_VISIBILITY
587 _Tp operator()(const _Tp& __x) const
592 struct __log10_expr : unary_function<_Tp, _Tp>
594 _LIBCPP_INLINE_VISIBILITY
595 _Tp operator()(const _Tp& __x) const
600 struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
602 _LIBCPP_INLINE_VISIBILITY
603 _Tp operator()(const _Tp& __x, const _Tp& __y) const
604 {return pow(__x, __y);}
608 struct __sin_expr : unary_function<_Tp, _Tp>
610 _LIBCPP_INLINE_VISIBILITY
611 _Tp operator()(const _Tp& __x) const
616 struct __sinh_expr : unary_function<_Tp, _Tp>
618 _LIBCPP_INLINE_VISIBILITY
619 _Tp operator()(const _Tp& __x) const
624 struct __sqrt_expr : unary_function<_Tp, _Tp>
626 _LIBCPP_INLINE_VISIBILITY
627 _Tp operator()(const _Tp& __x) const
632 struct __tan_expr : unary_function<_Tp, _Tp>
634 _LIBCPP_INLINE_VISIBILITY
635 _Tp operator()(const _Tp& __x) const
640 struct __tanh_expr : unary_function<_Tp, _Tp>
642 _LIBCPP_INLINE_VISIBILITY
643 _Tp operator()(const _Tp& __x) const
647 template <class _ValExpr>
650 typedef typename remove_reference<_ValExpr>::type _RmExpr;
652 typedef typename _RmExpr::value_type value_type;
653 typedef value_type result_type;
661 _LIBCPP_INLINE_VISIBILITY
662 __slice_expr(const slice& __sl, const _RmExpr& __e)
664 __start_(__sl.start()),
665 __size_(__sl.size()),
666 __stride_(__sl.stride())
670 _LIBCPP_INLINE_VISIBILITY
671 result_type operator[](size_t __i) const
672 {return __expr_[__start_ + __i * __stride_];}
674 _LIBCPP_INLINE_VISIBILITY
675 size_t size() const {return __size_;}
677 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
680 template <class _ValExpr>
683 template <class _ValExpr>
684 class __indirect_expr;
686 template <class _ValExpr>
689 typedef typename remove_reference<_ValExpr>::type _RmExpr;
691 typedef typename _RmExpr::value_type value_type;
692 typedef value_type result_type;
700 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
701 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
703 _LIBCPP_INLINE_VISIBILITY
704 __shift_expr(int __n, const _RmExpr& __e)
709 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
710 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
711 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
715 _LIBCPP_INLINE_VISIBILITY
716 result_type operator[](size_t __j) const
718 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
719 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
720 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
723 _LIBCPP_INLINE_VISIBILITY
724 size_t size() const {return __size_;}
726 template <class> friend class __val_expr;
729 template <class _ValExpr>
732 typedef typename remove_reference<_ValExpr>::type _RmExpr;
734 typedef typename _RmExpr::value_type value_type;
735 typedef value_type result_type;
744 _LIBCPP_INLINE_VISIBILITY
745 __cshift_expr(int __n, const _RmExpr& __e)
749 __n %= static_cast<int>(__size_);
752 __m_ = __size_ - __n;
754 __o2_ = __n - __size_;
759 __o1_ = __n + __size_;
765 _LIBCPP_INLINE_VISIBILITY
766 result_type operator[](size_t __i) const
769 return __expr_[__i + __o1_];
770 return __expr_[__i + __o2_];
773 _LIBCPP_INLINE_VISIBILITY
774 size_t size() const {return __size_;}
776 template <class> friend class __val_expr;
779 template<class _ValExpr>
782 template<class _ValExpr>
783 struct __is_val_expr : false_type {};
785 template<class _ValExpr>
786 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
789 struct __is_val_expr<valarray<_Tp> > : true_type {};
792 class _LIBCPP_TEMPLATE_VIS valarray
795 typedef _Tp value_type;
796 typedef _Tp result_type;
799 value_type* __begin_;
803 // construct/destroy:
804 _LIBCPP_INLINE_VISIBILITY
805 valarray() : __begin_(0), __end_(0) {}
806 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
807 explicit valarray(size_t __n);
808 _LIBCPP_INLINE_VISIBILITY
809 valarray(const value_type& __x, size_t __n);
810 valarray(const value_type* __p, size_t __n);
811 valarray(const valarray& __v);
812 #ifndef _LIBCPP_CXX03_LANG
813 _LIBCPP_INLINE_VISIBILITY
814 valarray(valarray&& __v) _NOEXCEPT;
815 valarray(initializer_list<value_type> __il);
816 #endif // _LIBCPP_CXX03_LANG
817 valarray(const slice_array<value_type>& __sa);
818 valarray(const gslice_array<value_type>& __ga);
819 valarray(const mask_array<value_type>& __ma);
820 valarray(const indirect_array<value_type>& __ia);
821 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
825 valarray& operator=(const valarray& __v);
826 #ifndef _LIBCPP_CXX03_LANG
827 _LIBCPP_INLINE_VISIBILITY
828 valarray& operator=(valarray&& __v) _NOEXCEPT;
829 _LIBCPP_INLINE_VISIBILITY
830 valarray& operator=(initializer_list<value_type>);
831 #endif // _LIBCPP_CXX03_LANG
832 _LIBCPP_INLINE_VISIBILITY
833 valarray& operator=(const value_type& __x);
834 _LIBCPP_INLINE_VISIBILITY
835 valarray& operator=(const slice_array<value_type>& __sa);
836 _LIBCPP_INLINE_VISIBILITY
837 valarray& operator=(const gslice_array<value_type>& __ga);
838 _LIBCPP_INLINE_VISIBILITY
839 valarray& operator=(const mask_array<value_type>& __ma);
840 _LIBCPP_INLINE_VISIBILITY
841 valarray& operator=(const indirect_array<value_type>& __ia);
842 template <class _ValExpr>
843 _LIBCPP_INLINE_VISIBILITY
844 valarray& operator=(const __val_expr<_ValExpr>& __v);
847 _LIBCPP_INLINE_VISIBILITY
848 const value_type& operator[](size_t __i) const {return __begin_[__i];}
850 _LIBCPP_INLINE_VISIBILITY
851 value_type& operator[](size_t __i) {return __begin_[__i];}
853 // subset operations:
854 _LIBCPP_INLINE_VISIBILITY
855 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
856 _LIBCPP_INLINE_VISIBILITY
857 slice_array<value_type> operator[](slice __s);
858 _LIBCPP_INLINE_VISIBILITY
859 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
860 _LIBCPP_INLINE_VISIBILITY
861 gslice_array<value_type> operator[](const gslice& __gs);
862 #ifndef _LIBCPP_CXX03_LANG
863 _LIBCPP_INLINE_VISIBILITY
864 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
865 _LIBCPP_INLINE_VISIBILITY
866 gslice_array<value_type> operator[](gslice&& __gs);
867 #endif // _LIBCPP_CXX03_LANG
868 _LIBCPP_INLINE_VISIBILITY
869 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
870 _LIBCPP_INLINE_VISIBILITY
871 mask_array<value_type> operator[](const valarray<bool>& __vb);
872 #ifndef _LIBCPP_CXX03_LANG
873 _LIBCPP_INLINE_VISIBILITY
874 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
875 _LIBCPP_INLINE_VISIBILITY
876 mask_array<value_type> operator[](valarray<bool>&& __vb);
877 #endif // _LIBCPP_CXX03_LANG
878 _LIBCPP_INLINE_VISIBILITY
879 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
880 _LIBCPP_INLINE_VISIBILITY
881 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
882 #ifndef _LIBCPP_CXX03_LANG
883 _LIBCPP_INLINE_VISIBILITY
884 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
885 _LIBCPP_INLINE_VISIBILITY
886 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
887 #endif // _LIBCPP_CXX03_LANG
890 valarray operator+() const;
891 valarray operator-() const;
892 valarray operator~() const;
893 valarray<bool> operator!() const;
895 // computed assignment:
896 _LIBCPP_INLINE_VISIBILITY
897 valarray& operator*= (const value_type& __x);
898 _LIBCPP_INLINE_VISIBILITY
899 valarray& operator/= (const value_type& __x);
900 _LIBCPP_INLINE_VISIBILITY
901 valarray& operator%= (const value_type& __x);
902 _LIBCPP_INLINE_VISIBILITY
903 valarray& operator+= (const value_type& __x);
904 _LIBCPP_INLINE_VISIBILITY
905 valarray& operator-= (const value_type& __x);
906 _LIBCPP_INLINE_VISIBILITY
907 valarray& operator^= (const value_type& __x);
908 _LIBCPP_INLINE_VISIBILITY
909 valarray& operator&= (const value_type& __x);
910 _LIBCPP_INLINE_VISIBILITY
911 valarray& operator|= (const value_type& __x);
912 _LIBCPP_INLINE_VISIBILITY
913 valarray& operator<<=(const value_type& __x);
914 _LIBCPP_INLINE_VISIBILITY
915 valarray& operator>>=(const value_type& __x);
917 template <class _Expr>
920 __is_val_expr<_Expr>::value,
923 _LIBCPP_INLINE_VISIBILITY
924 operator*= (const _Expr& __v);
926 template <class _Expr>
929 __is_val_expr<_Expr>::value,
932 _LIBCPP_INLINE_VISIBILITY
933 operator/= (const _Expr& __v);
935 template <class _Expr>
938 __is_val_expr<_Expr>::value,
941 _LIBCPP_INLINE_VISIBILITY
942 operator%= (const _Expr& __v);
944 template <class _Expr>
947 __is_val_expr<_Expr>::value,
950 _LIBCPP_INLINE_VISIBILITY
951 operator+= (const _Expr& __v);
953 template <class _Expr>
956 __is_val_expr<_Expr>::value,
959 _LIBCPP_INLINE_VISIBILITY
960 operator-= (const _Expr& __v);
962 template <class _Expr>
965 __is_val_expr<_Expr>::value,
968 _LIBCPP_INLINE_VISIBILITY
969 operator^= (const _Expr& __v);
971 template <class _Expr>
974 __is_val_expr<_Expr>::value,
977 _LIBCPP_INLINE_VISIBILITY
978 operator|= (const _Expr& __v);
980 template <class _Expr>
983 __is_val_expr<_Expr>::value,
986 _LIBCPP_INLINE_VISIBILITY
987 operator&= (const _Expr& __v);
989 template <class _Expr>
992 __is_val_expr<_Expr>::value,
995 _LIBCPP_INLINE_VISIBILITY
996 operator<<= (const _Expr& __v);
998 template <class _Expr>
1001 __is_val_expr<_Expr>::value,
1004 _LIBCPP_INLINE_VISIBILITY
1005 operator>>= (const _Expr& __v);
1007 // member functions:
1008 _LIBCPP_INLINE_VISIBILITY
1009 void swap(valarray& __v) _NOEXCEPT;
1011 _LIBCPP_INLINE_VISIBILITY
1012 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
1014 _LIBCPP_INLINE_VISIBILITY
1015 value_type sum() const;
1016 _LIBCPP_INLINE_VISIBILITY
1017 value_type min() const;
1018 _LIBCPP_INLINE_VISIBILITY
1019 value_type max() const;
1021 valarray shift (int __i) const;
1022 valarray cshift(int __i) const;
1023 valarray apply(value_type __f(value_type)) const;
1024 valarray apply(value_type __f(const value_type&)) const;
1025 void resize(size_t __n, value_type __x = value_type());
1028 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1029 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1030 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1031 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
1032 template <class> friend class __mask_expr;
1033 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
1034 template <class> friend class __indirect_expr;
1035 template <class> friend class __val_expr;
1037 template <class _Up>
1040 begin(valarray<_Up>& __v);
1042 template <class _Up>
1045 begin(const valarray<_Up>& __v);
1047 template <class _Up>
1050 end(valarray<_Up>& __v);
1052 template <class _Up>
1055 end(const valarray<_Up>& __v);
1058 valarray& __assign_range(const value_type* __f, const value_type* __l);
1061 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1062 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1063 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1065 template <class _Op, class _Tp>
1066 struct _UnaryOp<_Op, valarray<_Tp> >
1068 typedef typename _Op::result_type result_type;
1069 typedef _Tp value_type;
1072 const valarray<_Tp>& __a0_;
1074 _LIBCPP_INLINE_VISIBILITY
1075 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1077 _LIBCPP_INLINE_VISIBILITY
1078 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1080 _LIBCPP_INLINE_VISIBILITY
1081 size_t size() const {return __a0_.size();}
1084 template <class _Op, class _Tp, class _A1>
1085 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1087 typedef typename _Op::result_type result_type;
1088 typedef _Tp value_type;
1091 const valarray<_Tp>& __a0_;
1094 _LIBCPP_INLINE_VISIBILITY
1095 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1096 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1098 _LIBCPP_INLINE_VISIBILITY
1099 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1101 _LIBCPP_INLINE_VISIBILITY
1102 size_t size() const {return __a0_.size();}
1105 template <class _Op, class _A0, class _Tp>
1106 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1108 typedef typename _Op::result_type result_type;
1109 typedef _Tp value_type;
1113 const valarray<_Tp>& __a1_;
1115 _LIBCPP_INLINE_VISIBILITY
1116 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1117 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1119 _LIBCPP_INLINE_VISIBILITY
1120 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1122 _LIBCPP_INLINE_VISIBILITY
1123 size_t size() const {return __a0_.size();}
1126 template <class _Op, class _Tp>
1127 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1129 typedef typename _Op::result_type result_type;
1130 typedef _Tp value_type;
1133 const valarray<_Tp>& __a0_;
1134 const valarray<_Tp>& __a1_;
1136 _LIBCPP_INLINE_VISIBILITY
1137 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1138 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1140 _LIBCPP_INLINE_VISIBILITY
1141 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1143 _LIBCPP_INLINE_VISIBILITY
1144 size_t size() const {return __a0_.size();}
1149 template <class _Tp>
1150 class _LIBCPP_TEMPLATE_VIS slice_array
1153 typedef _Tp value_type;
1161 template <class _Expr>
1164 __is_val_expr<_Expr>::value,
1167 _LIBCPP_INLINE_VISIBILITY
1168 operator=(const _Expr& __v) const;
1170 template <class _Expr>
1173 __is_val_expr<_Expr>::value,
1176 _LIBCPP_INLINE_VISIBILITY
1177 operator*=(const _Expr& __v) const;
1179 template <class _Expr>
1182 __is_val_expr<_Expr>::value,
1185 _LIBCPP_INLINE_VISIBILITY
1186 operator/=(const _Expr& __v) const;
1188 template <class _Expr>
1191 __is_val_expr<_Expr>::value,
1194 _LIBCPP_INLINE_VISIBILITY
1195 operator%=(const _Expr& __v) const;
1197 template <class _Expr>
1200 __is_val_expr<_Expr>::value,
1203 _LIBCPP_INLINE_VISIBILITY
1204 operator+=(const _Expr& __v) const;
1206 template <class _Expr>
1209 __is_val_expr<_Expr>::value,
1212 _LIBCPP_INLINE_VISIBILITY
1213 operator-=(const _Expr& __v) const;
1215 template <class _Expr>
1218 __is_val_expr<_Expr>::value,
1221 _LIBCPP_INLINE_VISIBILITY
1222 operator^=(const _Expr& __v) const;
1224 template <class _Expr>
1227 __is_val_expr<_Expr>::value,
1230 _LIBCPP_INLINE_VISIBILITY
1231 operator&=(const _Expr& __v) const;
1233 template <class _Expr>
1236 __is_val_expr<_Expr>::value,
1239 _LIBCPP_INLINE_VISIBILITY
1240 operator|=(const _Expr& __v) const;
1242 template <class _Expr>
1245 __is_val_expr<_Expr>::value,
1248 _LIBCPP_INLINE_VISIBILITY
1249 operator<<=(const _Expr& __v) const;
1251 template <class _Expr>
1254 __is_val_expr<_Expr>::value,
1257 _LIBCPP_INLINE_VISIBILITY
1258 operator>>=(const _Expr& __v) const;
1260 _LIBCPP_INLINE_VISIBILITY
1261 const slice_array& operator=(const slice_array& __sa) const;
1263 _LIBCPP_INLINE_VISIBILITY
1264 void operator=(const value_type& __x) const;
1267 _LIBCPP_INLINE_VISIBILITY
1268 slice_array(const slice& __sl, const valarray<value_type>& __v)
1269 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1270 __size_(__sl.size()),
1271 __stride_(__sl.stride())
1274 template <class> friend class valarray;
1275 template <class> friend class sliceExpr;
1278 template <class _Tp>
1280 const slice_array<_Tp>&
1281 slice_array<_Tp>::operator=(const slice_array& __sa) const
1283 value_type* __t = __vp_;
1284 const value_type* __s = __sa.__vp_;
1285 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1290 template <class _Tp>
1291 template <class _Expr>
1295 __is_val_expr<_Expr>::value,
1298 slice_array<_Tp>::operator=(const _Expr& __v) const
1300 value_type* __t = __vp_;
1301 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1305 template <class _Tp>
1306 template <class _Expr>
1310 __is_val_expr<_Expr>::value,
1313 slice_array<_Tp>::operator*=(const _Expr& __v) const
1315 value_type* __t = __vp_;
1316 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1320 template <class _Tp>
1321 template <class _Expr>
1325 __is_val_expr<_Expr>::value,
1328 slice_array<_Tp>::operator/=(const _Expr& __v) const
1330 value_type* __t = __vp_;
1331 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1335 template <class _Tp>
1336 template <class _Expr>
1340 __is_val_expr<_Expr>::value,
1343 slice_array<_Tp>::operator%=(const _Expr& __v) const
1345 value_type* __t = __vp_;
1346 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1350 template <class _Tp>
1351 template <class _Expr>
1355 __is_val_expr<_Expr>::value,
1358 slice_array<_Tp>::operator+=(const _Expr& __v) const
1360 value_type* __t = __vp_;
1361 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1365 template <class _Tp>
1366 template <class _Expr>
1370 __is_val_expr<_Expr>::value,
1373 slice_array<_Tp>::operator-=(const _Expr& __v) const
1375 value_type* __t = __vp_;
1376 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1380 template <class _Tp>
1381 template <class _Expr>
1385 __is_val_expr<_Expr>::value,
1388 slice_array<_Tp>::operator^=(const _Expr& __v) const
1390 value_type* __t = __vp_;
1391 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1395 template <class _Tp>
1396 template <class _Expr>
1400 __is_val_expr<_Expr>::value,
1403 slice_array<_Tp>::operator&=(const _Expr& __v) const
1405 value_type* __t = __vp_;
1406 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1410 template <class _Tp>
1411 template <class _Expr>
1415 __is_val_expr<_Expr>::value,
1418 slice_array<_Tp>::operator|=(const _Expr& __v) const
1420 value_type* __t = __vp_;
1421 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1425 template <class _Tp>
1426 template <class _Expr>
1430 __is_val_expr<_Expr>::value,
1433 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1435 value_type* __t = __vp_;
1436 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1440 template <class _Tp>
1441 template <class _Expr>
1445 __is_val_expr<_Expr>::value,
1448 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1450 value_type* __t = __vp_;
1451 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1455 template <class _Tp>
1458 slice_array<_Tp>::operator=(const value_type& __x) const
1460 value_type* __t = __vp_;
1461 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1467 class _LIBCPP_TYPE_VIS gslice
1469 valarray<size_t> __size_;
1470 valarray<size_t> __stride_;
1471 valarray<size_t> __1d_;
1474 _LIBCPP_INLINE_VISIBILITY
1477 _LIBCPP_INLINE_VISIBILITY
1478 gslice(size_t __start, const valarray<size_t>& __size,
1479 const valarray<size_t>& __stride)
1484 #ifndef _LIBCPP_CXX03_LANG
1486 _LIBCPP_INLINE_VISIBILITY
1487 gslice(size_t __start, const valarray<size_t>& __size,
1488 valarray<size_t>&& __stride)
1490 __stride_(move(__stride))
1493 _LIBCPP_INLINE_VISIBILITY
1494 gslice(size_t __start, valarray<size_t>&& __size,
1495 const valarray<size_t>& __stride)
1496 : __size_(move(__size)),
1500 _LIBCPP_INLINE_VISIBILITY
1501 gslice(size_t __start, valarray<size_t>&& __size,
1502 valarray<size_t>&& __stride)
1503 : __size_(move(__size)),
1504 __stride_(move(__stride))
1507 #endif // _LIBCPP_CXX03_LANG
1509 // gslice(const gslice&) = default;
1510 // gslice(gslice&&) = default;
1511 // gslice& operator=(const gslice&) = default;
1512 // gslice& operator=(gslice&&) = default;
1514 _LIBCPP_INLINE_VISIBILITY
1515 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1517 _LIBCPP_INLINE_VISIBILITY
1518 valarray<size_t> size() const {return __size_;}
1520 _LIBCPP_INLINE_VISIBILITY
1521 valarray<size_t> stride() const {return __stride_;}
1524 void __init(size_t __start);
1526 template <class> friend class gslice_array;
1527 template <class> friend class valarray;
1528 template <class> friend class __val_expr;
1533 template <class _Tp>
1534 class _LIBCPP_TEMPLATE_VIS gslice_array
1537 typedef _Tp value_type;
1541 valarray<size_t> __1d_;
1544 template <class _Expr>
1547 __is_val_expr<_Expr>::value,
1550 _LIBCPP_INLINE_VISIBILITY
1551 operator=(const _Expr& __v) const;
1553 template <class _Expr>
1556 __is_val_expr<_Expr>::value,
1559 _LIBCPP_INLINE_VISIBILITY
1560 operator*=(const _Expr& __v) const;
1562 template <class _Expr>
1565 __is_val_expr<_Expr>::value,
1568 _LIBCPP_INLINE_VISIBILITY
1569 operator/=(const _Expr& __v) const;
1571 template <class _Expr>
1574 __is_val_expr<_Expr>::value,
1577 _LIBCPP_INLINE_VISIBILITY
1578 operator%=(const _Expr& __v) const;
1580 template <class _Expr>
1583 __is_val_expr<_Expr>::value,
1586 _LIBCPP_INLINE_VISIBILITY
1587 operator+=(const _Expr& __v) const;
1589 template <class _Expr>
1592 __is_val_expr<_Expr>::value,
1595 _LIBCPP_INLINE_VISIBILITY
1596 operator-=(const _Expr& __v) const;
1598 template <class _Expr>
1601 __is_val_expr<_Expr>::value,
1604 _LIBCPP_INLINE_VISIBILITY
1605 operator^=(const _Expr& __v) const;
1607 template <class _Expr>
1610 __is_val_expr<_Expr>::value,
1613 _LIBCPP_INLINE_VISIBILITY
1614 operator&=(const _Expr& __v) const;
1616 template <class _Expr>
1619 __is_val_expr<_Expr>::value,
1622 _LIBCPP_INLINE_VISIBILITY
1623 operator|=(const _Expr& __v) const;
1625 template <class _Expr>
1628 __is_val_expr<_Expr>::value,
1631 _LIBCPP_INLINE_VISIBILITY
1632 operator<<=(const _Expr& __v) const;
1634 template <class _Expr>
1637 __is_val_expr<_Expr>::value,
1640 _LIBCPP_INLINE_VISIBILITY
1641 operator>>=(const _Expr& __v) const;
1643 _LIBCPP_INLINE_VISIBILITY
1644 const gslice_array& operator=(const gslice_array& __ga) const;
1646 _LIBCPP_INLINE_VISIBILITY
1647 void operator=(const value_type& __x) const;
1649 // gslice_array(const gslice_array&) = default;
1650 // gslice_array(gslice_array&&) = default;
1651 // gslice_array& operator=(const gslice_array&) = default;
1652 // gslice_array& operator=(gslice_array&&) = default;
1655 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1656 : __vp_(const_cast<value_type*>(__v.__begin_)),
1660 #ifndef _LIBCPP_CXX03_LANG
1661 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1662 : __vp_(const_cast<value_type*>(__v.__begin_)),
1663 __1d_(move(__gs.__1d_))
1665 #endif // _LIBCPP_CXX03_LANG
1667 template <class> friend class valarray;
1670 template <class _Tp>
1671 template <class _Expr>
1675 __is_val_expr<_Expr>::value,
1678 gslice_array<_Tp>::operator=(const _Expr& __v) const
1680 typedef const size_t* _Ip;
1682 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1683 __vp_[*__i] = __v[__j];
1686 template <class _Tp>
1687 template <class _Expr>
1691 __is_val_expr<_Expr>::value,
1694 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1696 typedef const size_t* _Ip;
1698 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1699 __vp_[*__i] *= __v[__j];
1702 template <class _Tp>
1703 template <class _Expr>
1707 __is_val_expr<_Expr>::value,
1710 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1712 typedef const size_t* _Ip;
1714 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1715 __vp_[*__i] /= __v[__j];
1718 template <class _Tp>
1719 template <class _Expr>
1723 __is_val_expr<_Expr>::value,
1726 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1728 typedef const size_t* _Ip;
1730 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1731 __vp_[*__i] %= __v[__j];
1734 template <class _Tp>
1735 template <class _Expr>
1739 __is_val_expr<_Expr>::value,
1742 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1744 typedef const size_t* _Ip;
1746 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1747 __vp_[*__i] += __v[__j];
1750 template <class _Tp>
1751 template <class _Expr>
1755 __is_val_expr<_Expr>::value,
1758 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1760 typedef const size_t* _Ip;
1762 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1763 __vp_[*__i] -= __v[__j];
1766 template <class _Tp>
1767 template <class _Expr>
1771 __is_val_expr<_Expr>::value,
1774 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1776 typedef const size_t* _Ip;
1778 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1779 __vp_[*__i] ^= __v[__j];
1782 template <class _Tp>
1783 template <class _Expr>
1787 __is_val_expr<_Expr>::value,
1790 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1792 typedef const size_t* _Ip;
1794 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1795 __vp_[*__i] &= __v[__j];
1798 template <class _Tp>
1799 template <class _Expr>
1803 __is_val_expr<_Expr>::value,
1806 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1808 typedef const size_t* _Ip;
1810 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1811 __vp_[*__i] |= __v[__j];
1814 template <class _Tp>
1815 template <class _Expr>
1819 __is_val_expr<_Expr>::value,
1822 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1824 typedef const size_t* _Ip;
1826 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1827 __vp_[*__i] <<= __v[__j];
1830 template <class _Tp>
1831 template <class _Expr>
1835 __is_val_expr<_Expr>::value,
1838 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1840 typedef const size_t* _Ip;
1842 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1843 __vp_[*__i] >>= __v[__j];
1846 template <class _Tp>
1848 const gslice_array<_Tp>&
1849 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1851 typedef const size_t* _Ip;
1852 const value_type* __s = __ga.__vp_;
1853 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1854 __i != __e; ++__i, ++__j)
1855 __vp_[*__i] = __s[*__j];
1859 template <class _Tp>
1862 gslice_array<_Tp>::operator=(const value_type& __x) const
1864 typedef const size_t* _Ip;
1865 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1871 template <class _Tp>
1872 class _LIBCPP_TEMPLATE_VIS mask_array
1875 typedef _Tp value_type;
1879 valarray<size_t> __1d_;
1882 template <class _Expr>
1885 __is_val_expr<_Expr>::value,
1888 _LIBCPP_INLINE_VISIBILITY
1889 operator=(const _Expr& __v) const;
1891 template <class _Expr>
1894 __is_val_expr<_Expr>::value,
1897 _LIBCPP_INLINE_VISIBILITY
1898 operator*=(const _Expr& __v) const;
1900 template <class _Expr>
1903 __is_val_expr<_Expr>::value,
1906 _LIBCPP_INLINE_VISIBILITY
1907 operator/=(const _Expr& __v) const;
1909 template <class _Expr>
1912 __is_val_expr<_Expr>::value,
1915 _LIBCPP_INLINE_VISIBILITY
1916 operator%=(const _Expr& __v) const;
1918 template <class _Expr>
1921 __is_val_expr<_Expr>::value,
1924 _LIBCPP_INLINE_VISIBILITY
1925 operator+=(const _Expr& __v) const;
1927 template <class _Expr>
1930 __is_val_expr<_Expr>::value,
1933 _LIBCPP_INLINE_VISIBILITY
1934 operator-=(const _Expr& __v) const;
1936 template <class _Expr>
1939 __is_val_expr<_Expr>::value,
1942 _LIBCPP_INLINE_VISIBILITY
1943 operator^=(const _Expr& __v) const;
1945 template <class _Expr>
1948 __is_val_expr<_Expr>::value,
1951 _LIBCPP_INLINE_VISIBILITY
1952 operator&=(const _Expr& __v) const;
1954 template <class _Expr>
1957 __is_val_expr<_Expr>::value,
1960 _LIBCPP_INLINE_VISIBILITY
1961 operator|=(const _Expr& __v) const;
1963 template <class _Expr>
1966 __is_val_expr<_Expr>::value,
1969 _LIBCPP_INLINE_VISIBILITY
1970 operator<<=(const _Expr& __v) const;
1972 template <class _Expr>
1975 __is_val_expr<_Expr>::value,
1978 _LIBCPP_INLINE_VISIBILITY
1979 operator>>=(const _Expr& __v) const;
1981 _LIBCPP_INLINE_VISIBILITY
1982 const mask_array& operator=(const mask_array& __ma) const;
1984 _LIBCPP_INLINE_VISIBILITY
1985 void operator=(const value_type& __x) const;
1987 // mask_array(const mask_array&) = default;
1988 // mask_array(mask_array&&) = default;
1989 // mask_array& operator=(const mask_array&) = default;
1990 // mask_array& operator=(mask_array&&) = default;
1993 _LIBCPP_INLINE_VISIBILITY
1994 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1995 : __vp_(const_cast<value_type*>(__v.__begin_)),
1996 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1999 for (size_t __i = 0; __i < __vb.size(); ++__i)
2004 template <class> friend class valarray;
2007 template <class _Tp>
2008 template <class _Expr>
2012 __is_val_expr<_Expr>::value,
2015 mask_array<_Tp>::operator=(const _Expr& __v) const
2017 size_t __n = __1d_.size();
2018 for (size_t __i = 0; __i < __n; ++__i)
2019 __vp_[__1d_[__i]] = __v[__i];
2022 template <class _Tp>
2023 template <class _Expr>
2027 __is_val_expr<_Expr>::value,
2030 mask_array<_Tp>::operator*=(const _Expr& __v) const
2032 size_t __n = __1d_.size();
2033 for (size_t __i = 0; __i < __n; ++__i)
2034 __vp_[__1d_[__i]] *= __v[__i];
2037 template <class _Tp>
2038 template <class _Expr>
2042 __is_val_expr<_Expr>::value,
2045 mask_array<_Tp>::operator/=(const _Expr& __v) const
2047 size_t __n = __1d_.size();
2048 for (size_t __i = 0; __i < __n; ++__i)
2049 __vp_[__1d_[__i]] /= __v[__i];
2052 template <class _Tp>
2053 template <class _Expr>
2057 __is_val_expr<_Expr>::value,
2060 mask_array<_Tp>::operator%=(const _Expr& __v) const
2062 size_t __n = __1d_.size();
2063 for (size_t __i = 0; __i < __n; ++__i)
2064 __vp_[__1d_[__i]] %= __v[__i];
2067 template <class _Tp>
2068 template <class _Expr>
2072 __is_val_expr<_Expr>::value,
2075 mask_array<_Tp>::operator+=(const _Expr& __v) const
2077 size_t __n = __1d_.size();
2078 for (size_t __i = 0; __i < __n; ++__i)
2079 __vp_[__1d_[__i]] += __v[__i];
2082 template <class _Tp>
2083 template <class _Expr>
2087 __is_val_expr<_Expr>::value,
2090 mask_array<_Tp>::operator-=(const _Expr& __v) const
2092 size_t __n = __1d_.size();
2093 for (size_t __i = 0; __i < __n; ++__i)
2094 __vp_[__1d_[__i]] -= __v[__i];
2097 template <class _Tp>
2098 template <class _Expr>
2102 __is_val_expr<_Expr>::value,
2105 mask_array<_Tp>::operator^=(const _Expr& __v) const
2107 size_t __n = __1d_.size();
2108 for (size_t __i = 0; __i < __n; ++__i)
2109 __vp_[__1d_[__i]] ^= __v[__i];
2112 template <class _Tp>
2113 template <class _Expr>
2117 __is_val_expr<_Expr>::value,
2120 mask_array<_Tp>::operator&=(const _Expr& __v) const
2122 size_t __n = __1d_.size();
2123 for (size_t __i = 0; __i < __n; ++__i)
2124 __vp_[__1d_[__i]] &= __v[__i];
2127 template <class _Tp>
2128 template <class _Expr>
2132 __is_val_expr<_Expr>::value,
2135 mask_array<_Tp>::operator|=(const _Expr& __v) const
2137 size_t __n = __1d_.size();
2138 for (size_t __i = 0; __i < __n; ++__i)
2139 __vp_[__1d_[__i]] |= __v[__i];
2142 template <class _Tp>
2143 template <class _Expr>
2147 __is_val_expr<_Expr>::value,
2150 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2152 size_t __n = __1d_.size();
2153 for (size_t __i = 0; __i < __n; ++__i)
2154 __vp_[__1d_[__i]] <<= __v[__i];
2157 template <class _Tp>
2158 template <class _Expr>
2162 __is_val_expr<_Expr>::value,
2165 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2167 size_t __n = __1d_.size();
2168 for (size_t __i = 0; __i < __n; ++__i)
2169 __vp_[__1d_[__i]] >>= __v[__i];
2172 template <class _Tp>
2174 const mask_array<_Tp>&
2175 mask_array<_Tp>::operator=(const mask_array& __ma) const
2177 size_t __n = __1d_.size();
2178 for (size_t __i = 0; __i < __n; ++__i)
2179 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2183 template <class _Tp>
2186 mask_array<_Tp>::operator=(const value_type& __x) const
2188 size_t __n = __1d_.size();
2189 for (size_t __i = 0; __i < __n; ++__i)
2190 __vp_[__1d_[__i]] = __x;
2193 template <class _ValExpr>
2196 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2198 typedef typename _RmExpr::value_type value_type;
2199 typedef value_type result_type;
2203 valarray<size_t> __1d_;
2205 _LIBCPP_INLINE_VISIBILITY
2206 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2208 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2211 for (size_t __i = 0; __i < __vb.size(); ++__i)
2217 _LIBCPP_INLINE_VISIBILITY
2218 result_type operator[](size_t __i) const
2219 {return __expr_[__1d_[__i]];}
2221 _LIBCPP_INLINE_VISIBILITY
2222 size_t size() const {return __1d_.size();}
2224 template <class> friend class valarray;
2229 template <class _Tp>
2230 class _LIBCPP_TEMPLATE_VIS indirect_array
2233 typedef _Tp value_type;
2237 valarray<size_t> __1d_;
2240 template <class _Expr>
2243 __is_val_expr<_Expr>::value,
2246 _LIBCPP_INLINE_VISIBILITY
2247 operator=(const _Expr& __v) const;
2249 template <class _Expr>
2252 __is_val_expr<_Expr>::value,
2255 _LIBCPP_INLINE_VISIBILITY
2256 operator*=(const _Expr& __v) const;
2258 template <class _Expr>
2261 __is_val_expr<_Expr>::value,
2264 _LIBCPP_INLINE_VISIBILITY
2265 operator/=(const _Expr& __v) const;
2267 template <class _Expr>
2270 __is_val_expr<_Expr>::value,
2273 _LIBCPP_INLINE_VISIBILITY
2274 operator%=(const _Expr& __v) const;
2276 template <class _Expr>
2279 __is_val_expr<_Expr>::value,
2282 _LIBCPP_INLINE_VISIBILITY
2283 operator+=(const _Expr& __v) const;
2285 template <class _Expr>
2288 __is_val_expr<_Expr>::value,
2291 _LIBCPP_INLINE_VISIBILITY
2292 operator-=(const _Expr& __v) const;
2294 template <class _Expr>
2297 __is_val_expr<_Expr>::value,
2300 _LIBCPP_INLINE_VISIBILITY
2301 operator^=(const _Expr& __v) const;
2303 template <class _Expr>
2306 __is_val_expr<_Expr>::value,
2309 _LIBCPP_INLINE_VISIBILITY
2310 operator&=(const _Expr& __v) const;
2312 template <class _Expr>
2315 __is_val_expr<_Expr>::value,
2318 _LIBCPP_INLINE_VISIBILITY
2319 operator|=(const _Expr& __v) const;
2321 template <class _Expr>
2324 __is_val_expr<_Expr>::value,
2327 _LIBCPP_INLINE_VISIBILITY
2328 operator<<=(const _Expr& __v) const;
2330 template <class _Expr>
2333 __is_val_expr<_Expr>::value,
2336 _LIBCPP_INLINE_VISIBILITY
2337 operator>>=(const _Expr& __v) const;
2339 _LIBCPP_INLINE_VISIBILITY
2340 const indirect_array& operator=(const indirect_array& __ia) const;
2342 _LIBCPP_INLINE_VISIBILITY
2343 void operator=(const value_type& __x) const;
2345 // indirect_array(const indirect_array&) = default;
2346 // indirect_array(indirect_array&&) = default;
2347 // indirect_array& operator=(const indirect_array&) = default;
2348 // indirect_array& operator=(indirect_array&&) = default;
2351 _LIBCPP_INLINE_VISIBILITY
2352 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2353 : __vp_(const_cast<value_type*>(__v.__begin_)),
2357 #ifndef _LIBCPP_CXX03_LANG
2359 _LIBCPP_INLINE_VISIBILITY
2360 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2361 : __vp_(const_cast<value_type*>(__v.__begin_)),
2365 #endif // _LIBCPP_CXX03_LANG
2367 template <class> friend class valarray;
2370 template <class _Tp>
2371 template <class _Expr>
2375 __is_val_expr<_Expr>::value,
2378 indirect_array<_Tp>::operator=(const _Expr& __v) const
2380 size_t __n = __1d_.size();
2381 for (size_t __i = 0; __i < __n; ++__i)
2382 __vp_[__1d_[__i]] = __v[__i];
2385 template <class _Tp>
2386 template <class _Expr>
2390 __is_val_expr<_Expr>::value,
2393 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2395 size_t __n = __1d_.size();
2396 for (size_t __i = 0; __i < __n; ++__i)
2397 __vp_[__1d_[__i]] *= __v[__i];
2400 template <class _Tp>
2401 template <class _Expr>
2405 __is_val_expr<_Expr>::value,
2408 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2410 size_t __n = __1d_.size();
2411 for (size_t __i = 0; __i < __n; ++__i)
2412 __vp_[__1d_[__i]] /= __v[__i];
2415 template <class _Tp>
2416 template <class _Expr>
2420 __is_val_expr<_Expr>::value,
2423 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2425 size_t __n = __1d_.size();
2426 for (size_t __i = 0; __i < __n; ++__i)
2427 __vp_[__1d_[__i]] %= __v[__i];
2430 template <class _Tp>
2431 template <class _Expr>
2435 __is_val_expr<_Expr>::value,
2438 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2440 size_t __n = __1d_.size();
2441 for (size_t __i = 0; __i < __n; ++__i)
2442 __vp_[__1d_[__i]] += __v[__i];
2445 template <class _Tp>
2446 template <class _Expr>
2450 __is_val_expr<_Expr>::value,
2453 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2455 size_t __n = __1d_.size();
2456 for (size_t __i = 0; __i < __n; ++__i)
2457 __vp_[__1d_[__i]] -= __v[__i];
2460 template <class _Tp>
2461 template <class _Expr>
2465 __is_val_expr<_Expr>::value,
2468 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2470 size_t __n = __1d_.size();
2471 for (size_t __i = 0; __i < __n; ++__i)
2472 __vp_[__1d_[__i]] ^= __v[__i];
2475 template <class _Tp>
2476 template <class _Expr>
2480 __is_val_expr<_Expr>::value,
2483 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2485 size_t __n = __1d_.size();
2486 for (size_t __i = 0; __i < __n; ++__i)
2487 __vp_[__1d_[__i]] &= __v[__i];
2490 template <class _Tp>
2491 template <class _Expr>
2495 __is_val_expr<_Expr>::value,
2498 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2500 size_t __n = __1d_.size();
2501 for (size_t __i = 0; __i < __n; ++__i)
2502 __vp_[__1d_[__i]] |= __v[__i];
2505 template <class _Tp>
2506 template <class _Expr>
2510 __is_val_expr<_Expr>::value,
2513 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2515 size_t __n = __1d_.size();
2516 for (size_t __i = 0; __i < __n; ++__i)
2517 __vp_[__1d_[__i]] <<= __v[__i];
2520 template <class _Tp>
2521 template <class _Expr>
2525 __is_val_expr<_Expr>::value,
2528 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2530 size_t __n = __1d_.size();
2531 for (size_t __i = 0; __i < __n; ++__i)
2532 __vp_[__1d_[__i]] >>= __v[__i];
2535 template <class _Tp>
2537 const indirect_array<_Tp>&
2538 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2540 typedef const size_t* _Ip;
2541 const value_type* __s = __ia.__vp_;
2542 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2543 __i != __e; ++__i, ++__j)
2544 __vp_[*__i] = __s[*__j];
2548 template <class _Tp>
2551 indirect_array<_Tp>::operator=(const value_type& __x) const
2553 typedef const size_t* _Ip;
2554 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2558 template <class _ValExpr>
2559 class __indirect_expr
2561 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2563 typedef typename _RmExpr::value_type value_type;
2564 typedef value_type result_type;
2568 valarray<size_t> __1d_;
2570 _LIBCPP_INLINE_VISIBILITY
2571 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2576 #ifndef _LIBCPP_CXX03_LANG
2578 _LIBCPP_INLINE_VISIBILITY
2579 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2584 #endif // _LIBCPP_CXX03_LANG
2587 _LIBCPP_INLINE_VISIBILITY
2588 result_type operator[](size_t __i) const
2589 {return __expr_[__1d_[__i]];}
2591 _LIBCPP_INLINE_VISIBILITY
2592 size_t size() const {return __1d_.size();}
2594 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
2597 template<class _ValExpr>
2600 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2604 typedef typename _RmExpr::value_type value_type;
2605 typedef typename _RmExpr::result_type result_type;
2607 _LIBCPP_INLINE_VISIBILITY
2608 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2610 _LIBCPP_INLINE_VISIBILITY
2611 result_type operator[](size_t __i) const
2612 {return __expr_[__i];}
2614 _LIBCPP_INLINE_VISIBILITY
2615 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2616 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2618 _LIBCPP_INLINE_VISIBILITY
2619 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2620 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2622 _LIBCPP_INLINE_VISIBILITY
2623 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2624 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2626 _LIBCPP_INLINE_VISIBILITY
2627 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2628 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2630 _LIBCPP_INLINE_VISIBILITY
2631 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2634 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2635 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2638 _LIBCPP_INLINE_VISIBILITY
2639 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2642 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2643 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2646 _LIBCPP_INLINE_VISIBILITY
2647 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2650 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2651 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2654 _LIBCPP_INLINE_VISIBILITY
2655 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2658 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2659 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2662 operator valarray<result_type>() const;
2664 _LIBCPP_INLINE_VISIBILITY
2665 size_t size() const {return __expr_.size();}
2667 _LIBCPP_INLINE_VISIBILITY
2668 result_type sum() const
2670 size_t __n = __expr_.size();
2671 result_type __r = __n ? __expr_[0] : result_type();
2672 for (size_t __i = 1; __i < __n; ++__i)
2673 __r += __expr_[__i];
2677 _LIBCPP_INLINE_VISIBILITY
2678 result_type min() const
2680 size_t __n = size();
2681 result_type __r = __n ? (*this)[0] : result_type();
2682 for (size_t __i = 1; __i < __n; ++__i)
2684 result_type __x = __expr_[__i];
2691 _LIBCPP_INLINE_VISIBILITY
2692 result_type max() const
2694 size_t __n = size();
2695 result_type __r = __n ? (*this)[0] : result_type();
2696 for (size_t __i = 1; __i < __n; ++__i)
2698 result_type __x = __expr_[__i];
2705 _LIBCPP_INLINE_VISIBILITY
2706 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2707 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2709 _LIBCPP_INLINE_VISIBILITY
2710 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2711 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2713 _LIBCPP_INLINE_VISIBILITY
2714 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2715 apply(value_type __f(value_type)) const
2717 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2718 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2719 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2722 _LIBCPP_INLINE_VISIBILITY
2723 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2724 apply(value_type __f(const value_type&)) const
2726 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2727 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2728 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2732 template<class _ValExpr>
2733 __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2735 valarray<result_type> __r;
2736 size_t __n = __expr_.size();
2741 static_cast<result_type*>(
2742 _VSTD::__libcpp_allocate(__n * sizeof(result_type), __alignof(result_type)));
2743 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2744 ::new (__r.__end_) result_type(__expr_[__i]);
2751 template <class _Tp>
2753 valarray<_Tp>::valarray(size_t __n)
2759 __begin_ = __end_ = static_cast<value_type*>(
2760 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2761 #ifndef _LIBCPP_NO_EXCEPTIONS
2764 #endif // _LIBCPP_NO_EXCEPTIONS
2765 for (; __n; --__n, ++__end_)
2766 ::new (__end_) value_type();
2767 #ifndef _LIBCPP_NO_EXCEPTIONS
2774 #endif // _LIBCPP_NO_EXCEPTIONS
2778 template <class _Tp>
2780 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2787 template <class _Tp>
2788 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2794 __begin_ = __end_ = static_cast<value_type*>(
2795 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2796 #ifndef _LIBCPP_NO_EXCEPTIONS
2799 #endif // _LIBCPP_NO_EXCEPTIONS
2800 for (; __n; ++__end_, ++__p, --__n)
2801 ::new (__end_) value_type(*__p);
2802 #ifndef _LIBCPP_NO_EXCEPTIONS
2809 #endif // _LIBCPP_NO_EXCEPTIONS
2813 template <class _Tp>
2814 valarray<_Tp>::valarray(const valarray& __v)
2820 __begin_ = __end_ = static_cast<value_type*>(
2821 _VSTD::__libcpp_allocate(__v.size() * sizeof(value_type), __alignof(value_type)));
2822 #ifndef _LIBCPP_NO_EXCEPTIONS
2825 #endif // _LIBCPP_NO_EXCEPTIONS
2826 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2827 ::new (__end_) value_type(*__p);
2828 #ifndef _LIBCPP_NO_EXCEPTIONS
2835 #endif // _LIBCPP_NO_EXCEPTIONS
2839 #ifndef _LIBCPP_CXX03_LANG
2841 template <class _Tp>
2843 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2844 : __begin_(__v.__begin_),
2847 __v.__begin_ = __v.__end_ = nullptr;
2850 template <class _Tp>
2851 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2855 size_t __n = __il.size();
2858 __begin_ = __end_ = static_cast<value_type*>(
2859 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2860 #ifndef _LIBCPP_NO_EXCEPTIONS
2863 #endif // _LIBCPP_NO_EXCEPTIONS
2864 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2865 ::new (__end_) value_type(*__p);
2866 #ifndef _LIBCPP_NO_EXCEPTIONS
2873 #endif // _LIBCPP_NO_EXCEPTIONS
2877 #endif // _LIBCPP_CXX03_LANG
2879 template <class _Tp>
2880 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2884 size_t __n = __sa.__size_;
2887 __begin_ = __end_ = static_cast<value_type*>(
2888 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2889 #ifndef _LIBCPP_NO_EXCEPTIONS
2892 #endif // _LIBCPP_NO_EXCEPTIONS
2893 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2894 ::new (__end_) value_type(*__p);
2895 #ifndef _LIBCPP_NO_EXCEPTIONS
2902 #endif // _LIBCPP_NO_EXCEPTIONS
2906 template <class _Tp>
2907 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2911 size_t __n = __ga.__1d_.size();
2914 __begin_ = __end_ = static_cast<value_type*>(
2915 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2916 #ifndef _LIBCPP_NO_EXCEPTIONS
2919 #endif // _LIBCPP_NO_EXCEPTIONS
2920 typedef const size_t* _Ip;
2921 const value_type* __s = __ga.__vp_;
2922 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2923 __i != __e; ++__i, ++__end_)
2924 ::new (__end_) value_type(__s[*__i]);
2925 #ifndef _LIBCPP_NO_EXCEPTIONS
2932 #endif // _LIBCPP_NO_EXCEPTIONS
2936 template <class _Tp>
2937 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2941 size_t __n = __ma.__1d_.size();
2944 __begin_ = __end_ = static_cast<value_type*>(
2945 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2946 #ifndef _LIBCPP_NO_EXCEPTIONS
2949 #endif // _LIBCPP_NO_EXCEPTIONS
2950 typedef const size_t* _Ip;
2951 const value_type* __s = __ma.__vp_;
2952 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2953 __i != __e; ++__i, ++__end_)
2954 ::new (__end_) value_type(__s[*__i]);
2955 #ifndef _LIBCPP_NO_EXCEPTIONS
2962 #endif // _LIBCPP_NO_EXCEPTIONS
2966 template <class _Tp>
2967 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2971 size_t __n = __ia.__1d_.size();
2974 __begin_ = __end_ = static_cast<value_type*>(
2975 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
2976 #ifndef _LIBCPP_NO_EXCEPTIONS
2979 #endif // _LIBCPP_NO_EXCEPTIONS
2980 typedef const size_t* _Ip;
2981 const value_type* __s = __ia.__vp_;
2982 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2983 __i != __e; ++__i, ++__end_)
2984 ::new (__end_) value_type(__s[*__i]);
2985 #ifndef _LIBCPP_NO_EXCEPTIONS
2992 #endif // _LIBCPP_NO_EXCEPTIONS
2996 template <class _Tp>
2998 valarray<_Tp>::~valarray()
3003 template <class _Tp>
3005 valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l)
3007 size_t __n = __l - __f;
3011 __begin_ = static_cast<value_type*>(
3012 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3013 __end_ = __begin_ + __n;
3014 _VSTD::uninitialized_copy(__f, __l, __begin_);
3016 _VSTD::copy(__f, __l, __begin_);
3021 template <class _Tp>
3023 valarray<_Tp>::operator=(const valarray& __v)
3026 return __assign_range(__v.__begin_, __v.__end_);
3030 #ifndef _LIBCPP_CXX03_LANG
3032 template <class _Tp>
3035 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
3038 __begin_ = __v.__begin_;
3039 __end_ = __v.__end_;
3040 __v.__begin_ = nullptr;
3041 __v.__end_ = nullptr;
3045 template <class _Tp>
3048 valarray<_Tp>::operator=(initializer_list<value_type> __il)
3050 return __assign_range(__il.begin(), __il.end());
3053 #endif // _LIBCPP_CXX03_LANG
3055 template <class _Tp>
3058 valarray<_Tp>::operator=(const value_type& __x)
3060 _VSTD::fill(__begin_, __end_, __x);
3064 template <class _Tp>
3067 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3069 value_type* __t = __begin_;
3070 const value_type* __s = __sa.__vp_;
3071 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3076 template <class _Tp>
3079 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3081 typedef const size_t* _Ip;
3082 value_type* __t = __begin_;
3083 const value_type* __s = __ga.__vp_;
3084 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3085 __i != __e; ++__i, ++__t)
3090 template <class _Tp>
3093 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3095 typedef const size_t* _Ip;
3096 value_type* __t = __begin_;
3097 const value_type* __s = __ma.__vp_;
3098 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3099 __i != __e; ++__i, ++__t)
3104 template <class _Tp>
3107 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3109 typedef const size_t* _Ip;
3110 value_type* __t = __begin_;
3111 const value_type* __s = __ia.__vp_;
3112 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3113 __i != __e; ++__i, ++__t)
3118 template <class _Tp>
3119 template <class _ValExpr>
3122 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3124 size_t __n = __v.size();
3127 value_type* __t = __begin_;
3128 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3129 *__t = result_type(__v[__i]);
3133 template <class _Tp>
3135 __val_expr<__slice_expr<const valarray<_Tp>&> >
3136 valarray<_Tp>::operator[](slice __s) const
3138 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3141 template <class _Tp>
3144 valarray<_Tp>::operator[](slice __s)
3146 return slice_array<value_type>(__s, *this);
3149 template <class _Tp>
3151 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3152 valarray<_Tp>::operator[](const gslice& __gs) const
3154 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3157 template <class _Tp>
3160 valarray<_Tp>::operator[](const gslice& __gs)
3162 return gslice_array<value_type>(__gs, *this);
3165 #ifndef _LIBCPP_CXX03_LANG
3167 template <class _Tp>
3169 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3170 valarray<_Tp>::operator[](gslice&& __gs) const
3172 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3175 template <class _Tp>
3178 valarray<_Tp>::operator[](gslice&& __gs)
3180 return gslice_array<value_type>(move(__gs), *this);
3183 #endif // _LIBCPP_CXX03_LANG
3185 template <class _Tp>
3187 __val_expr<__mask_expr<const valarray<_Tp>&> >
3188 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3190 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3193 template <class _Tp>
3196 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3198 return mask_array<value_type>(__vb, *this);
3201 #ifndef _LIBCPP_CXX03_LANG
3203 template <class _Tp>
3205 __val_expr<__mask_expr<const valarray<_Tp>&> >
3206 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3208 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3211 template <class _Tp>
3214 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3216 return mask_array<value_type>(move(__vb), *this);
3219 #endif // _LIBCPP_CXX03_LANG
3221 template <class _Tp>
3223 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3224 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3226 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3229 template <class _Tp>
3232 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3234 return indirect_array<value_type>(__vs, *this);
3237 #ifndef _LIBCPP_CXX03_LANG
3239 template <class _Tp>
3241 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3242 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3244 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3247 template <class _Tp>
3250 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3252 return indirect_array<value_type>(move(__vs), *this);
3255 #endif // _LIBCPP_CXX03_LANG
3257 template <class _Tp>
3259 valarray<_Tp>::operator+() const
3261 valarray<value_type> __r;
3262 size_t __n = size();
3267 static_cast<value_type*>(
3268 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3269 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3270 ::new (__r.__end_) value_type(+*__p);
3275 template <class _Tp>
3277 valarray<_Tp>::operator-() const
3279 valarray<value_type> __r;
3280 size_t __n = size();
3285 static_cast<value_type*>(
3286 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3287 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3288 ::new (__r.__end_) value_type(-*__p);
3293 template <class _Tp>
3295 valarray<_Tp>::operator~() const
3297 valarray<value_type> __r;
3298 size_t __n = size();
3303 static_cast<value_type*>(
3304 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3305 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3306 ::new (__r.__end_) value_type(~*__p);
3311 template <class _Tp>
3313 valarray<_Tp>::operator!() const
3316 size_t __n = size();
3321 static_cast<bool*>(_VSTD::__libcpp_allocate(__n * sizeof(bool), __alignof(bool)));
3322 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3323 ::new (__r.__end_) bool(!*__p);
3328 template <class _Tp>
3331 valarray<_Tp>::operator*=(const value_type& __x)
3333 for (value_type* __p = __begin_; __p != __end_; ++__p)
3338 template <class _Tp>
3341 valarray<_Tp>::operator/=(const value_type& __x)
3343 for (value_type* __p = __begin_; __p != __end_; ++__p)
3348 template <class _Tp>
3351 valarray<_Tp>::operator%=(const value_type& __x)
3353 for (value_type* __p = __begin_; __p != __end_; ++__p)
3358 template <class _Tp>
3361 valarray<_Tp>::operator+=(const value_type& __x)
3363 for (value_type* __p = __begin_; __p != __end_; ++__p)
3368 template <class _Tp>
3371 valarray<_Tp>::operator-=(const value_type& __x)
3373 for (value_type* __p = __begin_; __p != __end_; ++__p)
3378 template <class _Tp>
3381 valarray<_Tp>::operator^=(const value_type& __x)
3383 for (value_type* __p = __begin_; __p != __end_; ++__p)
3388 template <class _Tp>
3391 valarray<_Tp>::operator&=(const value_type& __x)
3393 for (value_type* __p = __begin_; __p != __end_; ++__p)
3398 template <class _Tp>
3401 valarray<_Tp>::operator|=(const value_type& __x)
3403 for (value_type* __p = __begin_; __p != __end_; ++__p)
3408 template <class _Tp>
3411 valarray<_Tp>::operator<<=(const value_type& __x)
3413 for (value_type* __p = __begin_; __p != __end_; ++__p)
3418 template <class _Tp>
3421 valarray<_Tp>::operator>>=(const value_type& __x)
3423 for (value_type* __p = __begin_; __p != __end_; ++__p)
3428 template <class _Tp>
3429 template <class _Expr>
3433 __is_val_expr<_Expr>::value,
3436 valarray<_Tp>::operator*=(const _Expr& __v)
3439 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3444 template <class _Tp>
3445 template <class _Expr>
3449 __is_val_expr<_Expr>::value,
3452 valarray<_Tp>::operator/=(const _Expr& __v)
3455 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3460 template <class _Tp>
3461 template <class _Expr>
3465 __is_val_expr<_Expr>::value,
3468 valarray<_Tp>::operator%=(const _Expr& __v)
3471 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3476 template <class _Tp>
3477 template <class _Expr>
3481 __is_val_expr<_Expr>::value,
3484 valarray<_Tp>::operator+=(const _Expr& __v)
3487 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3492 template <class _Tp>
3493 template <class _Expr>
3497 __is_val_expr<_Expr>::value,
3500 valarray<_Tp>::operator-=(const _Expr& __v)
3503 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3508 template <class _Tp>
3509 template <class _Expr>
3513 __is_val_expr<_Expr>::value,
3516 valarray<_Tp>::operator^=(const _Expr& __v)
3519 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3524 template <class _Tp>
3525 template <class _Expr>
3529 __is_val_expr<_Expr>::value,
3532 valarray<_Tp>::operator|=(const _Expr& __v)
3535 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3540 template <class _Tp>
3541 template <class _Expr>
3545 __is_val_expr<_Expr>::value,
3548 valarray<_Tp>::operator&=(const _Expr& __v)
3551 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3556 template <class _Tp>
3557 template <class _Expr>
3561 __is_val_expr<_Expr>::value,
3564 valarray<_Tp>::operator<<=(const _Expr& __v)
3567 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3572 template <class _Tp>
3573 template <class _Expr>
3577 __is_val_expr<_Expr>::value,
3580 valarray<_Tp>::operator>>=(const _Expr& __v)
3583 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3588 template <class _Tp>
3591 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3593 _VSTD::swap(__begin_, __v.__begin_);
3594 _VSTD::swap(__end_, __v.__end_);
3597 template <class _Tp>
3600 valarray<_Tp>::sum() const
3602 if (__begin_ == __end_)
3603 return value_type();
3604 const value_type* __p = __begin_;
3606 for (++__p; __p != __end_; ++__p)
3611 template <class _Tp>
3614 valarray<_Tp>::min() const
3616 if (__begin_ == __end_)
3617 return value_type();
3618 return *_VSTD::min_element(__begin_, __end_);
3621 template <class _Tp>
3624 valarray<_Tp>::max() const
3626 if (__begin_ == __end_)
3627 return value_type();
3628 return *_VSTD::max_element(__begin_, __end_);
3631 template <class _Tp>
3633 valarray<_Tp>::shift(int __i) const
3635 valarray<value_type> __r;
3636 size_t __n = size();
3641 static_cast<value_type*>(
3642 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3643 const value_type* __sb;
3648 __i = _VSTD::min(__i, static_cast<int>(__n));
3649 __sb = __begin_ + __i;
3650 __tb = __r.__begin_;
3651 __te = __r.__begin_ + (__n - __i);
3655 __i = _VSTD::min(-__i, static_cast<int>(__n));
3657 __tb = __r.__begin_ + __i;
3658 __te = __r.__begin_ + __n;
3660 for (; __r.__end_ != __tb; ++__r.__end_)
3661 ::new (__r.__end_) value_type();
3662 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3663 ::new (__r.__end_) value_type(*__sb);
3664 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3665 ::new (__r.__end_) value_type();
3670 template <class _Tp>
3672 valarray<_Tp>::cshift(int __i) const
3674 valarray<value_type> __r;
3675 size_t __n = size();
3680 static_cast<value_type*>(
3681 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3682 __i %= static_cast<int>(__n);
3683 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3684 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3685 ::new (__r.__end_) value_type(*__s);
3686 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3687 ::new (__r.__end_) value_type(*__s);
3692 template <class _Tp>
3694 valarray<_Tp>::apply(value_type __f(value_type)) const
3696 valarray<value_type> __r;
3697 size_t __n = size();
3702 static_cast<value_type*>(
3703 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3704 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3705 ::new (__r.__end_) value_type(__f(*__p));
3710 template <class _Tp>
3712 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3714 valarray<value_type> __r;
3715 size_t __n = size();
3720 static_cast<value_type*>(
3721 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3722 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3723 ::new (__r.__end_) value_type(__f(*__p));
3728 template <class _Tp>
3730 valarray<_Tp>::__clear()
3732 if (__begin_ != nullptr)
3734 while (__end_ != __begin_)
3735 (--__end_)->~value_type();
3736 _VSTD::__libcpp_deallocate(__begin_, __alignof(value_type));
3737 __begin_ = __end_ = nullptr;
3741 template <class _Tp>
3743 valarray<_Tp>::resize(size_t __n, value_type __x)
3748 __begin_ = __end_ = static_cast<value_type*>(
3749 _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type)));
3750 #ifndef _LIBCPP_NO_EXCEPTIONS
3753 #endif // _LIBCPP_NO_EXCEPTIONS
3754 for (; __n; --__n, ++__end_)
3755 ::new (__end_) value_type(__x);
3756 #ifndef _LIBCPP_NO_EXCEPTIONS
3763 #endif // _LIBCPP_NO_EXCEPTIONS
3768 inline _LIBCPP_INLINE_VISIBILITY
3770 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3775 template<class _Expr1, class _Expr2>
3776 inline _LIBCPP_INLINE_VISIBILITY
3779 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3780 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3782 operator*(const _Expr1& __x, const _Expr2& __y)
3784 typedef typename _Expr1::value_type value_type;
3785 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3786 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3789 template<class _Expr>
3790 inline _LIBCPP_INLINE_VISIBILITY
3793 __is_val_expr<_Expr>::value,
3794 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3795 _Expr, __scalar_expr<typename _Expr::value_type> > >
3797 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3799 typedef typename _Expr::value_type value_type;
3800 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3801 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3802 __x, __scalar_expr<value_type>(__y, __x.size())));
3805 template<class _Expr>
3806 inline _LIBCPP_INLINE_VISIBILITY
3809 __is_val_expr<_Expr>::value,
3810 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3811 __scalar_expr<typename _Expr::value_type>, _Expr> >
3813 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3815 typedef typename _Expr::value_type value_type;
3816 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3817 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3818 __scalar_expr<value_type>(__x, __y.size()), __y));
3821 template<class _Expr1, class _Expr2>
3822 inline _LIBCPP_INLINE_VISIBILITY
3825 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3826 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3828 operator/(const _Expr1& __x, const _Expr2& __y)
3830 typedef typename _Expr1::value_type value_type;
3831 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3832 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3835 template<class _Expr>
3836 inline _LIBCPP_INLINE_VISIBILITY
3839 __is_val_expr<_Expr>::value,
3840 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3841 _Expr, __scalar_expr<typename _Expr::value_type> > >
3843 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3845 typedef typename _Expr::value_type value_type;
3846 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3847 return __val_expr<_Op>(_Op(divides<value_type>(),
3848 __x, __scalar_expr<value_type>(__y, __x.size())));
3851 template<class _Expr>
3852 inline _LIBCPP_INLINE_VISIBILITY
3855 __is_val_expr<_Expr>::value,
3856 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3857 __scalar_expr<typename _Expr::value_type>, _Expr> >
3859 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3861 typedef typename _Expr::value_type value_type;
3862 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3863 return __val_expr<_Op>(_Op(divides<value_type>(),
3864 __scalar_expr<value_type>(__x, __y.size()), __y));
3867 template<class _Expr1, class _Expr2>
3868 inline _LIBCPP_INLINE_VISIBILITY
3871 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3872 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3874 operator%(const _Expr1& __x, const _Expr2& __y)
3876 typedef typename _Expr1::value_type value_type;
3877 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3878 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3881 template<class _Expr>
3882 inline _LIBCPP_INLINE_VISIBILITY
3885 __is_val_expr<_Expr>::value,
3886 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3887 _Expr, __scalar_expr<typename _Expr::value_type> > >
3889 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3891 typedef typename _Expr::value_type value_type;
3892 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3893 return __val_expr<_Op>(_Op(modulus<value_type>(),
3894 __x, __scalar_expr<value_type>(__y, __x.size())));
3897 template<class _Expr>
3898 inline _LIBCPP_INLINE_VISIBILITY
3901 __is_val_expr<_Expr>::value,
3902 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3903 __scalar_expr<typename _Expr::value_type>, _Expr> >
3905 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3907 typedef typename _Expr::value_type value_type;
3908 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3909 return __val_expr<_Op>(_Op(modulus<value_type>(),
3910 __scalar_expr<value_type>(__x, __y.size()), __y));
3913 template<class _Expr1, class _Expr2>
3914 inline _LIBCPP_INLINE_VISIBILITY
3917 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3918 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3920 operator+(const _Expr1& __x, const _Expr2& __y)
3922 typedef typename _Expr1::value_type value_type;
3923 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3924 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3927 template<class _Expr>
3928 inline _LIBCPP_INLINE_VISIBILITY
3931 __is_val_expr<_Expr>::value,
3932 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3933 _Expr, __scalar_expr<typename _Expr::value_type> > >
3935 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3937 typedef typename _Expr::value_type value_type;
3938 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3939 return __val_expr<_Op>(_Op(plus<value_type>(),
3940 __x, __scalar_expr<value_type>(__y, __x.size())));
3943 template<class _Expr>
3944 inline _LIBCPP_INLINE_VISIBILITY
3947 __is_val_expr<_Expr>::value,
3948 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3949 __scalar_expr<typename _Expr::value_type>, _Expr> >
3951 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3953 typedef typename _Expr::value_type value_type;
3954 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3955 return __val_expr<_Op>(_Op(plus<value_type>(),
3956 __scalar_expr<value_type>(__x, __y.size()), __y));
3959 template<class _Expr1, class _Expr2>
3960 inline _LIBCPP_INLINE_VISIBILITY
3963 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3964 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3966 operator-(const _Expr1& __x, const _Expr2& __y)
3968 typedef typename _Expr1::value_type value_type;
3969 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3970 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3973 template<class _Expr>
3974 inline _LIBCPP_INLINE_VISIBILITY
3977 __is_val_expr<_Expr>::value,
3978 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3979 _Expr, __scalar_expr<typename _Expr::value_type> > >
3981 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3983 typedef typename _Expr::value_type value_type;
3984 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3985 return __val_expr<_Op>(_Op(minus<value_type>(),
3986 __x, __scalar_expr<value_type>(__y, __x.size())));
3989 template<class _Expr>
3990 inline _LIBCPP_INLINE_VISIBILITY
3993 __is_val_expr<_Expr>::value,
3994 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3995 __scalar_expr<typename _Expr::value_type>, _Expr> >
3997 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3999 typedef typename _Expr::value_type value_type;
4000 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4001 return __val_expr<_Op>(_Op(minus<value_type>(),
4002 __scalar_expr<value_type>(__x, __y.size()), __y));
4005 template<class _Expr1, class _Expr2>
4006 inline _LIBCPP_INLINE_VISIBILITY
4009 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4010 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
4012 operator^(const _Expr1& __x, const _Expr2& __y)
4014 typedef typename _Expr1::value_type value_type;
4015 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
4016 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
4019 template<class _Expr>
4020 inline _LIBCPP_INLINE_VISIBILITY
4023 __is_val_expr<_Expr>::value,
4024 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
4025 _Expr, __scalar_expr<typename _Expr::value_type> > >
4027 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
4029 typedef typename _Expr::value_type value_type;
4030 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4031 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
4032 __x, __scalar_expr<value_type>(__y, __x.size())));
4035 template<class _Expr>
4036 inline _LIBCPP_INLINE_VISIBILITY
4039 __is_val_expr<_Expr>::value,
4040 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
4041 __scalar_expr<typename _Expr::value_type>, _Expr> >
4043 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
4045 typedef typename _Expr::value_type value_type;
4046 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4047 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
4048 __scalar_expr<value_type>(__x, __y.size()), __y));
4051 template<class _Expr1, class _Expr2>
4052 inline _LIBCPP_INLINE_VISIBILITY
4055 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4056 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4058 operator&(const _Expr1& __x, const _Expr2& __y)
4060 typedef typename _Expr1::value_type value_type;
4061 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4062 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4065 template<class _Expr>
4066 inline _LIBCPP_INLINE_VISIBILITY
4069 __is_val_expr<_Expr>::value,
4070 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4071 _Expr, __scalar_expr<typename _Expr::value_type> > >
4073 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4075 typedef typename _Expr::value_type value_type;
4076 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4077 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4078 __x, __scalar_expr<value_type>(__y, __x.size())));
4081 template<class _Expr>
4082 inline _LIBCPP_INLINE_VISIBILITY
4085 __is_val_expr<_Expr>::value,
4086 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4087 __scalar_expr<typename _Expr::value_type>, _Expr> >
4089 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4091 typedef typename _Expr::value_type value_type;
4092 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4093 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4094 __scalar_expr<value_type>(__x, __y.size()), __y));
4097 template<class _Expr1, class _Expr2>
4098 inline _LIBCPP_INLINE_VISIBILITY
4101 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4102 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4104 operator|(const _Expr1& __x, const _Expr2& __y)
4106 typedef typename _Expr1::value_type value_type;
4107 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4108 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4111 template<class _Expr>
4112 inline _LIBCPP_INLINE_VISIBILITY
4115 __is_val_expr<_Expr>::value,
4116 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4117 _Expr, __scalar_expr<typename _Expr::value_type> > >
4119 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4121 typedef typename _Expr::value_type value_type;
4122 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4123 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4124 __x, __scalar_expr<value_type>(__y, __x.size())));
4127 template<class _Expr>
4128 inline _LIBCPP_INLINE_VISIBILITY
4131 __is_val_expr<_Expr>::value,
4132 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4133 __scalar_expr<typename _Expr::value_type>, _Expr> >
4135 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4137 typedef typename _Expr::value_type value_type;
4138 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4139 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4140 __scalar_expr<value_type>(__x, __y.size()), __y));
4143 template<class _Expr1, class _Expr2>
4144 inline _LIBCPP_INLINE_VISIBILITY
4147 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4148 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4150 operator<<(const _Expr1& __x, const _Expr2& __y)
4152 typedef typename _Expr1::value_type value_type;
4153 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4154 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4157 template<class _Expr>
4158 inline _LIBCPP_INLINE_VISIBILITY
4161 __is_val_expr<_Expr>::value,
4162 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4163 _Expr, __scalar_expr<typename _Expr::value_type> > >
4165 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4167 typedef typename _Expr::value_type value_type;
4168 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4169 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4170 __x, __scalar_expr<value_type>(__y, __x.size())));
4173 template<class _Expr>
4174 inline _LIBCPP_INLINE_VISIBILITY
4177 __is_val_expr<_Expr>::value,
4178 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4179 __scalar_expr<typename _Expr::value_type>, _Expr> >
4181 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4183 typedef typename _Expr::value_type value_type;
4184 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4185 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4186 __scalar_expr<value_type>(__x, __y.size()), __y));
4189 template<class _Expr1, class _Expr2>
4190 inline _LIBCPP_INLINE_VISIBILITY
4193 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4194 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4196 operator>>(const _Expr1& __x, const _Expr2& __y)
4198 typedef typename _Expr1::value_type value_type;
4199 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4200 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4203 template<class _Expr>
4204 inline _LIBCPP_INLINE_VISIBILITY
4207 __is_val_expr<_Expr>::value,
4208 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4209 _Expr, __scalar_expr<typename _Expr::value_type> > >
4211 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4213 typedef typename _Expr::value_type value_type;
4214 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4215 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4216 __x, __scalar_expr<value_type>(__y, __x.size())));
4219 template<class _Expr>
4220 inline _LIBCPP_INLINE_VISIBILITY
4223 __is_val_expr<_Expr>::value,
4224 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4225 __scalar_expr<typename _Expr::value_type>, _Expr> >
4227 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4229 typedef typename _Expr::value_type value_type;
4230 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4231 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4232 __scalar_expr<value_type>(__x, __y.size()), __y));
4235 template<class _Expr1, class _Expr2>
4236 inline _LIBCPP_INLINE_VISIBILITY
4239 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4240 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4242 operator&&(const _Expr1& __x, const _Expr2& __y)
4244 typedef typename _Expr1::value_type value_type;
4245 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4246 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4249 template<class _Expr>
4250 inline _LIBCPP_INLINE_VISIBILITY
4253 __is_val_expr<_Expr>::value,
4254 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4255 _Expr, __scalar_expr<typename _Expr::value_type> > >
4257 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4259 typedef typename _Expr::value_type value_type;
4260 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4261 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4262 __x, __scalar_expr<value_type>(__y, __x.size())));
4265 template<class _Expr>
4266 inline _LIBCPP_INLINE_VISIBILITY
4269 __is_val_expr<_Expr>::value,
4270 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4271 __scalar_expr<typename _Expr::value_type>, _Expr> >
4273 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4275 typedef typename _Expr::value_type value_type;
4276 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4277 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4278 __scalar_expr<value_type>(__x, __y.size()), __y));
4281 template<class _Expr1, class _Expr2>
4282 inline _LIBCPP_INLINE_VISIBILITY
4285 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4286 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4288 operator||(const _Expr1& __x, const _Expr2& __y)
4290 typedef typename _Expr1::value_type value_type;
4291 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4292 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4295 template<class _Expr>
4296 inline _LIBCPP_INLINE_VISIBILITY
4299 __is_val_expr<_Expr>::value,
4300 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4301 _Expr, __scalar_expr<typename _Expr::value_type> > >
4303 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4305 typedef typename _Expr::value_type value_type;
4306 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4307 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4308 __x, __scalar_expr<value_type>(__y, __x.size())));
4311 template<class _Expr>
4312 inline _LIBCPP_INLINE_VISIBILITY
4315 __is_val_expr<_Expr>::value,
4316 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4317 __scalar_expr<typename _Expr::value_type>, _Expr> >
4319 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4321 typedef typename _Expr::value_type value_type;
4322 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4323 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4324 __scalar_expr<value_type>(__x, __y.size()), __y));
4327 template<class _Expr1, class _Expr2>
4328 inline _LIBCPP_INLINE_VISIBILITY
4331 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4332 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4334 operator==(const _Expr1& __x, const _Expr2& __y)
4336 typedef typename _Expr1::value_type value_type;
4337 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4338 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4341 template<class _Expr>
4342 inline _LIBCPP_INLINE_VISIBILITY
4345 __is_val_expr<_Expr>::value,
4346 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4347 _Expr, __scalar_expr<typename _Expr::value_type> > >
4349 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4351 typedef typename _Expr::value_type value_type;
4352 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4353 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4354 __x, __scalar_expr<value_type>(__y, __x.size())));
4357 template<class _Expr>
4358 inline _LIBCPP_INLINE_VISIBILITY
4361 __is_val_expr<_Expr>::value,
4362 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4363 __scalar_expr<typename _Expr::value_type>, _Expr> >
4365 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4367 typedef typename _Expr::value_type value_type;
4368 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4369 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4370 __scalar_expr<value_type>(__x, __y.size()), __y));
4373 template<class _Expr1, class _Expr2>
4374 inline _LIBCPP_INLINE_VISIBILITY
4377 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4378 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4380 operator!=(const _Expr1& __x, const _Expr2& __y)
4382 typedef typename _Expr1::value_type value_type;
4383 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4384 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4387 template<class _Expr>
4388 inline _LIBCPP_INLINE_VISIBILITY
4391 __is_val_expr<_Expr>::value,
4392 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4393 _Expr, __scalar_expr<typename _Expr::value_type> > >
4395 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4397 typedef typename _Expr::value_type value_type;
4398 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4399 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4400 __x, __scalar_expr<value_type>(__y, __x.size())));
4403 template<class _Expr>
4404 inline _LIBCPP_INLINE_VISIBILITY
4407 __is_val_expr<_Expr>::value,
4408 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4409 __scalar_expr<typename _Expr::value_type>, _Expr> >
4411 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4413 typedef typename _Expr::value_type value_type;
4414 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4415 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4416 __scalar_expr<value_type>(__x, __y.size()), __y));
4419 template<class _Expr1, class _Expr2>
4420 inline _LIBCPP_INLINE_VISIBILITY
4423 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4424 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4426 operator<(const _Expr1& __x, const _Expr2& __y)
4428 typedef typename _Expr1::value_type value_type;
4429 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4430 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4433 template<class _Expr>
4434 inline _LIBCPP_INLINE_VISIBILITY
4437 __is_val_expr<_Expr>::value,
4438 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4439 _Expr, __scalar_expr<typename _Expr::value_type> > >
4441 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4443 typedef typename _Expr::value_type value_type;
4444 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4445 return __val_expr<_Op>(_Op(less<value_type>(),
4446 __x, __scalar_expr<value_type>(__y, __x.size())));
4449 template<class _Expr>
4450 inline _LIBCPP_INLINE_VISIBILITY
4453 __is_val_expr<_Expr>::value,
4454 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4455 __scalar_expr<typename _Expr::value_type>, _Expr> >
4457 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4459 typedef typename _Expr::value_type value_type;
4460 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4461 return __val_expr<_Op>(_Op(less<value_type>(),
4462 __scalar_expr<value_type>(__x, __y.size()), __y));
4465 template<class _Expr1, class _Expr2>
4466 inline _LIBCPP_INLINE_VISIBILITY
4469 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4470 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4472 operator>(const _Expr1& __x, const _Expr2& __y)
4474 typedef typename _Expr1::value_type value_type;
4475 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4476 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4479 template<class _Expr>
4480 inline _LIBCPP_INLINE_VISIBILITY
4483 __is_val_expr<_Expr>::value,
4484 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4485 _Expr, __scalar_expr<typename _Expr::value_type> > >
4487 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4489 typedef typename _Expr::value_type value_type;
4490 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4491 return __val_expr<_Op>(_Op(greater<value_type>(),
4492 __x, __scalar_expr<value_type>(__y, __x.size())));
4495 template<class _Expr>
4496 inline _LIBCPP_INLINE_VISIBILITY
4499 __is_val_expr<_Expr>::value,
4500 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4501 __scalar_expr<typename _Expr::value_type>, _Expr> >
4503 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4505 typedef typename _Expr::value_type value_type;
4506 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4507 return __val_expr<_Op>(_Op(greater<value_type>(),
4508 __scalar_expr<value_type>(__x, __y.size()), __y));
4511 template<class _Expr1, class _Expr2>
4512 inline _LIBCPP_INLINE_VISIBILITY
4515 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4516 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4518 operator<=(const _Expr1& __x, const _Expr2& __y)
4520 typedef typename _Expr1::value_type value_type;
4521 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4522 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4525 template<class _Expr>
4526 inline _LIBCPP_INLINE_VISIBILITY
4529 __is_val_expr<_Expr>::value,
4530 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4531 _Expr, __scalar_expr<typename _Expr::value_type> > >
4533 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4535 typedef typename _Expr::value_type value_type;
4536 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4537 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4538 __x, __scalar_expr<value_type>(__y, __x.size())));
4541 template<class _Expr>
4542 inline _LIBCPP_INLINE_VISIBILITY
4545 __is_val_expr<_Expr>::value,
4546 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4547 __scalar_expr<typename _Expr::value_type>, _Expr> >
4549 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4551 typedef typename _Expr::value_type value_type;
4552 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4553 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4554 __scalar_expr<value_type>(__x, __y.size()), __y));
4557 template<class _Expr1, class _Expr2>
4558 inline _LIBCPP_INLINE_VISIBILITY
4561 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4562 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4564 operator>=(const _Expr1& __x, const _Expr2& __y)
4566 typedef typename _Expr1::value_type value_type;
4567 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4568 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4571 template<class _Expr>
4572 inline _LIBCPP_INLINE_VISIBILITY
4575 __is_val_expr<_Expr>::value,
4576 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4577 _Expr, __scalar_expr<typename _Expr::value_type> > >
4579 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4581 typedef typename _Expr::value_type value_type;
4582 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4583 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4584 __x, __scalar_expr<value_type>(__y, __x.size())));
4587 template<class _Expr>
4588 inline _LIBCPP_INLINE_VISIBILITY
4591 __is_val_expr<_Expr>::value,
4592 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4593 __scalar_expr<typename _Expr::value_type>, _Expr> >
4595 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4597 typedef typename _Expr::value_type value_type;
4598 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4599 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4600 __scalar_expr<value_type>(__x, __y.size()), __y));
4603 template<class _Expr>
4604 inline _LIBCPP_INLINE_VISIBILITY
4607 __is_val_expr<_Expr>::value,
4608 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4610 abs(const _Expr& __x)
4612 typedef typename _Expr::value_type value_type;
4613 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4614 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4617 template<class _Expr>
4618 inline _LIBCPP_INLINE_VISIBILITY
4621 __is_val_expr<_Expr>::value,
4622 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4624 acos(const _Expr& __x)
4626 typedef typename _Expr::value_type value_type;
4627 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4628 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4631 template<class _Expr>
4632 inline _LIBCPP_INLINE_VISIBILITY
4635 __is_val_expr<_Expr>::value,
4636 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4638 asin(const _Expr& __x)
4640 typedef typename _Expr::value_type value_type;
4641 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4642 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4645 template<class _Expr>
4646 inline _LIBCPP_INLINE_VISIBILITY
4649 __is_val_expr<_Expr>::value,
4650 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4652 atan(const _Expr& __x)
4654 typedef typename _Expr::value_type value_type;
4655 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4656 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4659 template<class _Expr1, class _Expr2>
4660 inline _LIBCPP_INLINE_VISIBILITY
4663 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4664 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4666 atan2(const _Expr1& __x, const _Expr2& __y)
4668 typedef typename _Expr1::value_type value_type;
4669 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4670 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4673 template<class _Expr>
4674 inline _LIBCPP_INLINE_VISIBILITY
4677 __is_val_expr<_Expr>::value,
4678 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4679 _Expr, __scalar_expr<typename _Expr::value_type> > >
4681 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4683 typedef typename _Expr::value_type value_type;
4684 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4685 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4686 __x, __scalar_expr<value_type>(__y, __x.size())));
4689 template<class _Expr>
4690 inline _LIBCPP_INLINE_VISIBILITY
4693 __is_val_expr<_Expr>::value,
4694 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4695 __scalar_expr<typename _Expr::value_type>, _Expr> >
4697 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4699 typedef typename _Expr::value_type value_type;
4700 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4701 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4702 __scalar_expr<value_type>(__x, __y.size()), __y));
4705 template<class _Expr>
4706 inline _LIBCPP_INLINE_VISIBILITY
4709 __is_val_expr<_Expr>::value,
4710 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4712 cos(const _Expr& __x)
4714 typedef typename _Expr::value_type value_type;
4715 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4716 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4719 template<class _Expr>
4720 inline _LIBCPP_INLINE_VISIBILITY
4723 __is_val_expr<_Expr>::value,
4724 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4726 cosh(const _Expr& __x)
4728 typedef typename _Expr::value_type value_type;
4729 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4730 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4733 template<class _Expr>
4734 inline _LIBCPP_INLINE_VISIBILITY
4737 __is_val_expr<_Expr>::value,
4738 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4740 exp(const _Expr& __x)
4742 typedef typename _Expr::value_type value_type;
4743 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4744 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4747 template<class _Expr>
4748 inline _LIBCPP_INLINE_VISIBILITY
4751 __is_val_expr<_Expr>::value,
4752 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4754 log(const _Expr& __x)
4756 typedef typename _Expr::value_type value_type;
4757 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4758 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4761 template<class _Expr>
4762 inline _LIBCPP_INLINE_VISIBILITY
4765 __is_val_expr<_Expr>::value,
4766 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4768 log10(const _Expr& __x)
4770 typedef typename _Expr::value_type value_type;
4771 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4772 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4775 template<class _Expr1, class _Expr2>
4776 inline _LIBCPP_INLINE_VISIBILITY
4779 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4780 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4782 pow(const _Expr1& __x, const _Expr2& __y)
4784 typedef typename _Expr1::value_type value_type;
4785 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4786 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4789 template<class _Expr>
4790 inline _LIBCPP_INLINE_VISIBILITY
4793 __is_val_expr<_Expr>::value,
4794 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4795 _Expr, __scalar_expr<typename _Expr::value_type> > >
4797 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4799 typedef typename _Expr::value_type value_type;
4800 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4801 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4802 __x, __scalar_expr<value_type>(__y, __x.size())));
4805 template<class _Expr>
4806 inline _LIBCPP_INLINE_VISIBILITY
4809 __is_val_expr<_Expr>::value,
4810 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4811 __scalar_expr<typename _Expr::value_type>, _Expr> >
4813 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4815 typedef typename _Expr::value_type value_type;
4816 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4817 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4818 __scalar_expr<value_type>(__x, __y.size()), __y));
4821 template<class _Expr>
4822 inline _LIBCPP_INLINE_VISIBILITY
4825 __is_val_expr<_Expr>::value,
4826 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4828 sin(const _Expr& __x)
4830 typedef typename _Expr::value_type value_type;
4831 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4832 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4835 template<class _Expr>
4836 inline _LIBCPP_INLINE_VISIBILITY
4839 __is_val_expr<_Expr>::value,
4840 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4842 sinh(const _Expr& __x)
4844 typedef typename _Expr::value_type value_type;
4845 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4846 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4849 template<class _Expr>
4850 inline _LIBCPP_INLINE_VISIBILITY
4853 __is_val_expr<_Expr>::value,
4854 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4856 sqrt(const _Expr& __x)
4858 typedef typename _Expr::value_type value_type;
4859 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4860 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4863 template<class _Expr>
4864 inline _LIBCPP_INLINE_VISIBILITY
4867 __is_val_expr<_Expr>::value,
4868 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4870 tan(const _Expr& __x)
4872 typedef typename _Expr::value_type value_type;
4873 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4874 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4877 template<class _Expr>
4878 inline _LIBCPP_INLINE_VISIBILITY
4881 __is_val_expr<_Expr>::value,
4882 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4884 tanh(const _Expr& __x)
4886 typedef typename _Expr::value_type value_type;
4887 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4888 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4891 template <class _Tp>
4892 inline _LIBCPP_INLINE_VISIBILITY
4894 begin(valarray<_Tp>& __v)
4896 return __v.__begin_;
4899 template <class _Tp>
4900 inline _LIBCPP_INLINE_VISIBILITY
4902 begin(const valarray<_Tp>& __v)
4904 return __v.__begin_;
4907 template <class _Tp>
4908 inline _LIBCPP_INLINE_VISIBILITY
4910 end(valarray<_Tp>& __v)
4915 template <class _Tp>
4916 inline _LIBCPP_INLINE_VISIBILITY
4918 end(const valarray<_Tp>& __v)
4923 _LIBCPP_END_NAMESPACE_STD
4927 #endif // _LIBCPP_VALARRAY