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 #include <__undef_min_max>
352 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
353 #pragma GCC system_header
356 _LIBCPP_BEGIN_NAMESPACE_STD
358 template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray;
360 class _LIBCPP_TEMPLATE_VIS slice
366 _LIBCPP_INLINE_VISIBILITY
373 _LIBCPP_INLINE_VISIBILITY
374 slice(size_t __start, size_t __size, size_t __stride)
380 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;}
381 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;}
382 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;}
385 template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array;
386 class _LIBCPP_TYPE_VIS gslice;
387 template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array;
388 template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array;
389 template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array;
392 _LIBCPP_INLINE_VISIBILITY
394 begin(valarray<_Tp>& __v);
397 _LIBCPP_INLINE_VISIBILITY
399 begin(const valarray<_Tp>& __v);
402 _LIBCPP_INLINE_VISIBILITY
404 end(valarray<_Tp>& __v);
407 _LIBCPP_INLINE_VISIBILITY
409 end(const valarray<_Tp>& __v);
411 template <class _Op, class _A0>
414 typedef typename _Op::result_type result_type;
415 typedef typename _A0::value_type value_type;
420 _LIBCPP_INLINE_VISIBILITY
421 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {}
423 _LIBCPP_INLINE_VISIBILITY
424 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
426 _LIBCPP_INLINE_VISIBILITY
427 size_t size() const {return __a0_.size();}
430 template <class _Op, class _A0, class _A1>
433 typedef typename _Op::result_type result_type;
434 typedef typename _A0::value_type value_type;
440 _LIBCPP_INLINE_VISIBILITY
441 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1)
442 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
444 _LIBCPP_INLINE_VISIBILITY
445 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
447 _LIBCPP_INLINE_VISIBILITY
448 size_t size() const {return __a0_.size();}
455 typedef _Tp value_type;
456 typedef const _Tp& result_type;
458 const value_type& __t_;
461 _LIBCPP_INLINE_VISIBILITY
462 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {}
464 _LIBCPP_INLINE_VISIBILITY
465 result_type operator[](size_t) const {return __t_;}
467 _LIBCPP_INLINE_VISIBILITY
468 size_t size() const {return __s_;}
472 struct __unary_plus : unary_function<_Tp, _Tp>
474 _LIBCPP_INLINE_VISIBILITY
475 _Tp operator()(const _Tp& __x) const
480 struct __bit_not : unary_function<_Tp, _Tp>
482 _LIBCPP_INLINE_VISIBILITY
483 _Tp operator()(const _Tp& __x) const
488 struct __bit_shift_left : binary_function<_Tp, _Tp, _Tp>
490 _LIBCPP_INLINE_VISIBILITY
491 _Tp operator()(const _Tp& __x, const _Tp& __y) const
496 struct __bit_shift_right : binary_function<_Tp, _Tp, _Tp>
498 _LIBCPP_INLINE_VISIBILITY
499 _Tp operator()(const _Tp& __x, const _Tp& __y) const
503 template <class _Tp, class _Fp>
504 struct __apply_expr : unary_function<_Tp, _Tp>
509 _LIBCPP_INLINE_VISIBILITY
510 explicit __apply_expr(_Fp __f) : __f_(__f) {}
512 _LIBCPP_INLINE_VISIBILITY
513 _Tp operator()(const _Tp& __x) const
518 struct __abs_expr : unary_function<_Tp, _Tp>
520 _LIBCPP_INLINE_VISIBILITY
521 _Tp operator()(const _Tp& __x) const
526 struct __acos_expr : unary_function<_Tp, _Tp>
528 _LIBCPP_INLINE_VISIBILITY
529 _Tp operator()(const _Tp& __x) const
534 struct __asin_expr : unary_function<_Tp, _Tp>
536 _LIBCPP_INLINE_VISIBILITY
537 _Tp operator()(const _Tp& __x) const
542 struct __atan_expr : unary_function<_Tp, _Tp>
544 _LIBCPP_INLINE_VISIBILITY
545 _Tp operator()(const _Tp& __x) const
550 struct __atan2_expr : binary_function<_Tp, _Tp, _Tp>
552 _LIBCPP_INLINE_VISIBILITY
553 _Tp operator()(const _Tp& __x, const _Tp& __y) const
554 {return atan2(__x, __y);}
558 struct __cos_expr : unary_function<_Tp, _Tp>
560 _LIBCPP_INLINE_VISIBILITY
561 _Tp operator()(const _Tp& __x) const
566 struct __cosh_expr : unary_function<_Tp, _Tp>
568 _LIBCPP_INLINE_VISIBILITY
569 _Tp operator()(const _Tp& __x) const
574 struct __exp_expr : unary_function<_Tp, _Tp>
576 _LIBCPP_INLINE_VISIBILITY
577 _Tp operator()(const _Tp& __x) const
582 struct __log_expr : unary_function<_Tp, _Tp>
584 _LIBCPP_INLINE_VISIBILITY
585 _Tp operator()(const _Tp& __x) const
590 struct __log10_expr : unary_function<_Tp, _Tp>
592 _LIBCPP_INLINE_VISIBILITY
593 _Tp operator()(const _Tp& __x) const
598 struct __pow_expr : binary_function<_Tp, _Tp, _Tp>
600 _LIBCPP_INLINE_VISIBILITY
601 _Tp operator()(const _Tp& __x, const _Tp& __y) const
602 {return pow(__x, __y);}
606 struct __sin_expr : unary_function<_Tp, _Tp>
608 _LIBCPP_INLINE_VISIBILITY
609 _Tp operator()(const _Tp& __x) const
614 struct __sinh_expr : unary_function<_Tp, _Tp>
616 _LIBCPP_INLINE_VISIBILITY
617 _Tp operator()(const _Tp& __x) const
622 struct __sqrt_expr : unary_function<_Tp, _Tp>
624 _LIBCPP_INLINE_VISIBILITY
625 _Tp operator()(const _Tp& __x) const
630 struct __tan_expr : unary_function<_Tp, _Tp>
632 _LIBCPP_INLINE_VISIBILITY
633 _Tp operator()(const _Tp& __x) const
638 struct __tanh_expr : unary_function<_Tp, _Tp>
640 _LIBCPP_INLINE_VISIBILITY
641 _Tp operator()(const _Tp& __x) const
645 template <class _ValExpr>
648 typedef typename remove_reference<_ValExpr>::type _RmExpr;
650 typedef typename _RmExpr::value_type value_type;
651 typedef value_type result_type;
659 _LIBCPP_INLINE_VISIBILITY
660 __slice_expr(const slice& __sl, const _RmExpr& __e)
662 __start_(__sl.start()),
663 __size_(__sl.size()),
664 __stride_(__sl.stride())
668 _LIBCPP_INLINE_VISIBILITY
669 result_type operator[](size_t __i) const
670 {return __expr_[__start_ + __i * __stride_];}
672 _LIBCPP_INLINE_VISIBILITY
673 size_t size() const {return __size_;}
675 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
678 template <class _ValExpr>
681 template <class _ValExpr>
682 class __indirect_expr;
684 template <class _ValExpr>
687 typedef typename remove_reference<_ValExpr>::type _RmExpr;
689 typedef typename _RmExpr::value_type value_type;
690 typedef value_type result_type;
698 static const ptrdiff_t _Np = static_cast<ptrdiff_t>(
699 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1);
701 _LIBCPP_INLINE_VISIBILITY
702 __shift_expr(int __n, const _RmExpr& __e)
707 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np);
708 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np);
709 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n);
713 _LIBCPP_INLINE_VISIBILITY
714 result_type operator[](size_t __j) const
716 ptrdiff_t __i = static_cast<ptrdiff_t>(__j);
717 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np;
718 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m);
721 _LIBCPP_INLINE_VISIBILITY
722 size_t size() const {return __size_;}
724 template <class> friend class __val_expr;
727 template <class _ValExpr>
730 typedef typename remove_reference<_ValExpr>::type _RmExpr;
732 typedef typename _RmExpr::value_type value_type;
733 typedef value_type result_type;
742 _LIBCPP_INLINE_VISIBILITY
743 __cshift_expr(int __n, const _RmExpr& __e)
747 __n %= static_cast<int>(__size_);
750 __m_ = __size_ - __n;
752 __o2_ = __n - __size_;
757 __o1_ = __n + __size_;
763 _LIBCPP_INLINE_VISIBILITY
764 result_type operator[](size_t __i) const
767 return __expr_[__i + __o1_];
768 return __expr_[__i + __o2_];
771 _LIBCPP_INLINE_VISIBILITY
772 size_t size() const {return __size_;}
774 template <class> friend class __val_expr;
777 template<class _ValExpr>
780 template<class _ValExpr>
781 struct __is_val_expr : false_type {};
783 template<class _ValExpr>
784 struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
787 struct __is_val_expr<valarray<_Tp> > : true_type {};
790 class _LIBCPP_TEMPLATE_VIS valarray
793 typedef _Tp value_type;
794 typedef _Tp result_type;
797 value_type* __begin_;
801 // construct/destroy:
802 _LIBCPP_INLINE_VISIBILITY
803 valarray() : __begin_(0), __end_(0) {}
804 inline _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
805 explicit valarray(size_t __n);
806 _LIBCPP_INLINE_VISIBILITY
807 valarray(const value_type& __x, size_t __n);
808 valarray(const value_type* __p, size_t __n);
809 valarray(const valarray& __v);
810 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
811 _LIBCPP_INLINE_VISIBILITY
812 valarray(valarray&& __v) _NOEXCEPT;
813 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
814 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
815 valarray(initializer_list<value_type> __il);
816 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
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_HAS_NO_RVALUE_REFERENCES
827 _LIBCPP_INLINE_VISIBILITY
828 valarray& operator=(valarray&& __v) _NOEXCEPT;
829 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
830 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
831 _LIBCPP_INLINE_VISIBILITY
832 valarray& operator=(initializer_list<value_type>);
833 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
834 _LIBCPP_INLINE_VISIBILITY
835 valarray& operator=(const value_type& __x);
836 _LIBCPP_INLINE_VISIBILITY
837 valarray& operator=(const slice_array<value_type>& __sa);
838 _LIBCPP_INLINE_VISIBILITY
839 valarray& operator=(const gslice_array<value_type>& __ga);
840 _LIBCPP_INLINE_VISIBILITY
841 valarray& operator=(const mask_array<value_type>& __ma);
842 _LIBCPP_INLINE_VISIBILITY
843 valarray& operator=(const indirect_array<value_type>& __ia);
844 template <class _ValExpr>
845 _LIBCPP_INLINE_VISIBILITY
846 valarray& operator=(const __val_expr<_ValExpr>& __v);
849 _LIBCPP_INLINE_VISIBILITY
850 const value_type& operator[](size_t __i) const {return __begin_[__i];}
852 _LIBCPP_INLINE_VISIBILITY
853 value_type& operator[](size_t __i) {return __begin_[__i];}
855 // subset operations:
856 _LIBCPP_INLINE_VISIBILITY
857 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const;
858 _LIBCPP_INLINE_VISIBILITY
859 slice_array<value_type> operator[](slice __s);
860 _LIBCPP_INLINE_VISIBILITY
861 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const;
862 _LIBCPP_INLINE_VISIBILITY
863 gslice_array<value_type> operator[](const gslice& __gs);
864 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
865 _LIBCPP_INLINE_VISIBILITY
866 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const;
867 _LIBCPP_INLINE_VISIBILITY
868 gslice_array<value_type> operator[](gslice&& __gs);
869 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
870 _LIBCPP_INLINE_VISIBILITY
871 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const;
872 _LIBCPP_INLINE_VISIBILITY
873 mask_array<value_type> operator[](const valarray<bool>& __vb);
874 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
875 _LIBCPP_INLINE_VISIBILITY
876 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const;
877 _LIBCPP_INLINE_VISIBILITY
878 mask_array<value_type> operator[](valarray<bool>&& __vb);
879 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
880 _LIBCPP_INLINE_VISIBILITY
881 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const;
882 _LIBCPP_INLINE_VISIBILITY
883 indirect_array<value_type> operator[](const valarray<size_t>& __vs);
884 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
885 _LIBCPP_INLINE_VISIBILITY
886 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const;
887 _LIBCPP_INLINE_VISIBILITY
888 indirect_array<value_type> operator[](valarray<size_t>&& __vs);
889 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
892 valarray operator+() const;
893 valarray operator-() const;
894 valarray operator~() const;
895 valarray<bool> operator!() const;
897 // computed assignment:
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);
916 _LIBCPP_INLINE_VISIBILITY
917 valarray& operator>>=(const value_type& __x);
919 template <class _Expr>
922 __is_val_expr<_Expr>::value,
925 _LIBCPP_INLINE_VISIBILITY
926 operator*= (const _Expr& __v);
928 template <class _Expr>
931 __is_val_expr<_Expr>::value,
934 _LIBCPP_INLINE_VISIBILITY
935 operator/= (const _Expr& __v);
937 template <class _Expr>
940 __is_val_expr<_Expr>::value,
943 _LIBCPP_INLINE_VISIBILITY
944 operator%= (const _Expr& __v);
946 template <class _Expr>
949 __is_val_expr<_Expr>::value,
952 _LIBCPP_INLINE_VISIBILITY
953 operator+= (const _Expr& __v);
955 template <class _Expr>
958 __is_val_expr<_Expr>::value,
961 _LIBCPP_INLINE_VISIBILITY
962 operator-= (const _Expr& __v);
964 template <class _Expr>
967 __is_val_expr<_Expr>::value,
970 _LIBCPP_INLINE_VISIBILITY
971 operator^= (const _Expr& __v);
973 template <class _Expr>
976 __is_val_expr<_Expr>::value,
979 _LIBCPP_INLINE_VISIBILITY
980 operator|= (const _Expr& __v);
982 template <class _Expr>
985 __is_val_expr<_Expr>::value,
988 _LIBCPP_INLINE_VISIBILITY
989 operator&= (const _Expr& __v);
991 template <class _Expr>
994 __is_val_expr<_Expr>::value,
997 _LIBCPP_INLINE_VISIBILITY
998 operator<<= (const _Expr& __v);
1000 template <class _Expr>
1003 __is_val_expr<_Expr>::value,
1006 _LIBCPP_INLINE_VISIBILITY
1007 operator>>= (const _Expr& __v);
1009 // member functions:
1010 _LIBCPP_INLINE_VISIBILITY
1011 void swap(valarray& __v) _NOEXCEPT;
1013 _LIBCPP_INLINE_VISIBILITY
1014 size_t size() const {return static_cast<size_t>(__end_ - __begin_);}
1016 _LIBCPP_INLINE_VISIBILITY
1017 value_type sum() const;
1018 _LIBCPP_INLINE_VISIBILITY
1019 value_type min() const;
1020 _LIBCPP_INLINE_VISIBILITY
1021 value_type max() const;
1023 valarray shift (int __i) const;
1024 valarray cshift(int __i) const;
1025 valarray apply(value_type __f(value_type)) const;
1026 valarray apply(value_type __f(const value_type&)) const;
1027 void resize(size_t __n, value_type __x = value_type());
1030 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
1031 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array;
1032 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array;
1033 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array;
1034 template <class> friend class __mask_expr;
1035 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array;
1036 template <class> friend class __indirect_expr;
1037 template <class> friend class __val_expr;
1039 template <class _Up>
1042 begin(valarray<_Up>& __v);
1044 template <class _Up>
1047 begin(const valarray<_Up>& __v);
1049 template <class _Up>
1052 end(valarray<_Up>& __v);
1054 template <class _Up>
1057 end(const valarray<_Up>& __v);
1060 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t))
1061 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray())
1062 _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t))
1064 template <class _Op, class _Tp>
1065 struct _UnaryOp<_Op, valarray<_Tp> >
1067 typedef typename _Op::result_type result_type;
1068 typedef _Tp value_type;
1071 const valarray<_Tp>& __a0_;
1073 _LIBCPP_INLINE_VISIBILITY
1074 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {}
1076 _LIBCPP_INLINE_VISIBILITY
1077 result_type operator[](size_t __i) const {return __op_(__a0_[__i]);}
1079 _LIBCPP_INLINE_VISIBILITY
1080 size_t size() const {return __a0_.size();}
1083 template <class _Op, class _Tp, class _A1>
1084 struct _BinaryOp<_Op, valarray<_Tp>, _A1>
1086 typedef typename _Op::result_type result_type;
1087 typedef _Tp value_type;
1090 const valarray<_Tp>& __a0_;
1093 _LIBCPP_INLINE_VISIBILITY
1094 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1)
1095 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1097 _LIBCPP_INLINE_VISIBILITY
1098 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1100 _LIBCPP_INLINE_VISIBILITY
1101 size_t size() const {return __a0_.size();}
1104 template <class _Op, class _A0, class _Tp>
1105 struct _BinaryOp<_Op, _A0, valarray<_Tp> >
1107 typedef typename _Op::result_type result_type;
1108 typedef _Tp value_type;
1112 const valarray<_Tp>& __a1_;
1114 _LIBCPP_INLINE_VISIBILITY
1115 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1)
1116 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1118 _LIBCPP_INLINE_VISIBILITY
1119 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1121 _LIBCPP_INLINE_VISIBILITY
1122 size_t size() const {return __a0_.size();}
1125 template <class _Op, class _Tp>
1126 struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> >
1128 typedef typename _Op::result_type result_type;
1129 typedef _Tp value_type;
1132 const valarray<_Tp>& __a0_;
1133 const valarray<_Tp>& __a1_;
1135 _LIBCPP_INLINE_VISIBILITY
1136 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1)
1137 : __op_(__op), __a0_(__a0), __a1_(__a1) {}
1139 _LIBCPP_INLINE_VISIBILITY
1140 value_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);}
1142 _LIBCPP_INLINE_VISIBILITY
1143 size_t size() const {return __a0_.size();}
1148 template <class _Tp>
1149 class _LIBCPP_TEMPLATE_VIS slice_array
1152 typedef _Tp value_type;
1160 template <class _Expr>
1163 __is_val_expr<_Expr>::value,
1166 _LIBCPP_INLINE_VISIBILITY
1167 operator=(const _Expr& __v) const;
1169 template <class _Expr>
1172 __is_val_expr<_Expr>::value,
1175 _LIBCPP_INLINE_VISIBILITY
1176 operator*=(const _Expr& __v) const;
1178 template <class _Expr>
1181 __is_val_expr<_Expr>::value,
1184 _LIBCPP_INLINE_VISIBILITY
1185 operator/=(const _Expr& __v) const;
1187 template <class _Expr>
1190 __is_val_expr<_Expr>::value,
1193 _LIBCPP_INLINE_VISIBILITY
1194 operator%=(const _Expr& __v) const;
1196 template <class _Expr>
1199 __is_val_expr<_Expr>::value,
1202 _LIBCPP_INLINE_VISIBILITY
1203 operator+=(const _Expr& __v) const;
1205 template <class _Expr>
1208 __is_val_expr<_Expr>::value,
1211 _LIBCPP_INLINE_VISIBILITY
1212 operator-=(const _Expr& __v) const;
1214 template <class _Expr>
1217 __is_val_expr<_Expr>::value,
1220 _LIBCPP_INLINE_VISIBILITY
1221 operator^=(const _Expr& __v) const;
1223 template <class _Expr>
1226 __is_val_expr<_Expr>::value,
1229 _LIBCPP_INLINE_VISIBILITY
1230 operator&=(const _Expr& __v) const;
1232 template <class _Expr>
1235 __is_val_expr<_Expr>::value,
1238 _LIBCPP_INLINE_VISIBILITY
1239 operator|=(const _Expr& __v) const;
1241 template <class _Expr>
1244 __is_val_expr<_Expr>::value,
1247 _LIBCPP_INLINE_VISIBILITY
1248 operator<<=(const _Expr& __v) const;
1250 template <class _Expr>
1253 __is_val_expr<_Expr>::value,
1256 _LIBCPP_INLINE_VISIBILITY
1257 operator>>=(const _Expr& __v) const;
1259 _LIBCPP_INLINE_VISIBILITY
1260 const slice_array& operator=(const slice_array& __sa) const;
1262 _LIBCPP_INLINE_VISIBILITY
1263 void operator=(const value_type& __x) const;
1266 _LIBCPP_INLINE_VISIBILITY
1267 slice_array(const slice& __sl, const valarray<value_type>& __v)
1268 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())),
1269 __size_(__sl.size()),
1270 __stride_(__sl.stride())
1273 template <class> friend class valarray;
1274 template <class> friend class sliceExpr;
1277 template <class _Tp>
1279 const slice_array<_Tp>&
1280 slice_array<_Tp>::operator=(const slice_array& __sa) const
1282 value_type* __t = __vp_;
1283 const value_type* __s = __sa.__vp_;
1284 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_)
1289 template <class _Tp>
1290 template <class _Expr>
1294 __is_val_expr<_Expr>::value,
1297 slice_array<_Tp>::operator=(const _Expr& __v) const
1299 value_type* __t = __vp_;
1300 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1304 template <class _Tp>
1305 template <class _Expr>
1309 __is_val_expr<_Expr>::value,
1312 slice_array<_Tp>::operator*=(const _Expr& __v) const
1314 value_type* __t = __vp_;
1315 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1319 template <class _Tp>
1320 template <class _Expr>
1324 __is_val_expr<_Expr>::value,
1327 slice_array<_Tp>::operator/=(const _Expr& __v) const
1329 value_type* __t = __vp_;
1330 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1334 template <class _Tp>
1335 template <class _Expr>
1339 __is_val_expr<_Expr>::value,
1342 slice_array<_Tp>::operator%=(const _Expr& __v) const
1344 value_type* __t = __vp_;
1345 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1349 template <class _Tp>
1350 template <class _Expr>
1354 __is_val_expr<_Expr>::value,
1357 slice_array<_Tp>::operator+=(const _Expr& __v) const
1359 value_type* __t = __vp_;
1360 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1364 template <class _Tp>
1365 template <class _Expr>
1369 __is_val_expr<_Expr>::value,
1372 slice_array<_Tp>::operator-=(const _Expr& __v) const
1374 value_type* __t = __vp_;
1375 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1379 template <class _Tp>
1380 template <class _Expr>
1384 __is_val_expr<_Expr>::value,
1387 slice_array<_Tp>::operator^=(const _Expr& __v) const
1389 value_type* __t = __vp_;
1390 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1394 template <class _Tp>
1395 template <class _Expr>
1399 __is_val_expr<_Expr>::value,
1402 slice_array<_Tp>::operator&=(const _Expr& __v) const
1404 value_type* __t = __vp_;
1405 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1409 template <class _Tp>
1410 template <class _Expr>
1414 __is_val_expr<_Expr>::value,
1417 slice_array<_Tp>::operator|=(const _Expr& __v) const
1419 value_type* __t = __vp_;
1420 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1424 template <class _Tp>
1425 template <class _Expr>
1429 __is_val_expr<_Expr>::value,
1432 slice_array<_Tp>::operator<<=(const _Expr& __v) const
1434 value_type* __t = __vp_;
1435 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1439 template <class _Tp>
1440 template <class _Expr>
1444 __is_val_expr<_Expr>::value,
1447 slice_array<_Tp>::operator>>=(const _Expr& __v) const
1449 value_type* __t = __vp_;
1450 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_)
1454 template <class _Tp>
1457 slice_array<_Tp>::operator=(const value_type& __x) const
1459 value_type* __t = __vp_;
1460 for (size_t __n = __size_; __n; --__n, __t += __stride_)
1466 class _LIBCPP_TYPE_VIS gslice
1468 valarray<size_t> __size_;
1469 valarray<size_t> __stride_;
1470 valarray<size_t> __1d_;
1473 _LIBCPP_INLINE_VISIBILITY
1476 _LIBCPP_INLINE_VISIBILITY
1477 gslice(size_t __start, const valarray<size_t>& __size,
1478 const valarray<size_t>& __stride)
1483 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1485 _LIBCPP_INLINE_VISIBILITY
1486 gslice(size_t __start, const valarray<size_t>& __size,
1487 valarray<size_t>&& __stride)
1489 __stride_(move(__stride))
1492 _LIBCPP_INLINE_VISIBILITY
1493 gslice(size_t __start, valarray<size_t>&& __size,
1494 const valarray<size_t>& __stride)
1495 : __size_(move(__size)),
1499 _LIBCPP_INLINE_VISIBILITY
1500 gslice(size_t __start, valarray<size_t>&& __size,
1501 valarray<size_t>&& __stride)
1502 : __size_(move(__size)),
1503 __stride_(move(__stride))
1506 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1508 // gslice(const gslice&) = default;
1509 // gslice(gslice&&) = default;
1510 // gslice& operator=(const gslice&) = default;
1511 // gslice& operator=(gslice&&) = default;
1513 _LIBCPP_INLINE_VISIBILITY
1514 size_t start() const {return __1d_.size() ? __1d_[0] : 0;}
1516 _LIBCPP_INLINE_VISIBILITY
1517 valarray<size_t> size() const {return __size_;}
1519 _LIBCPP_INLINE_VISIBILITY
1520 valarray<size_t> stride() const {return __stride_;}
1523 void __init(size_t __start);
1525 template <class> friend class gslice_array;
1526 template <class> friend class valarray;
1527 template <class> friend class __val_expr;
1532 template <class _Tp>
1533 class _LIBCPP_TEMPLATE_VIS gslice_array
1536 typedef _Tp value_type;
1540 valarray<size_t> __1d_;
1543 template <class _Expr>
1546 __is_val_expr<_Expr>::value,
1549 _LIBCPP_INLINE_VISIBILITY
1550 operator=(const _Expr& __v) const;
1552 template <class _Expr>
1555 __is_val_expr<_Expr>::value,
1558 _LIBCPP_INLINE_VISIBILITY
1559 operator*=(const _Expr& __v) const;
1561 template <class _Expr>
1564 __is_val_expr<_Expr>::value,
1567 _LIBCPP_INLINE_VISIBILITY
1568 operator/=(const _Expr& __v) const;
1570 template <class _Expr>
1573 __is_val_expr<_Expr>::value,
1576 _LIBCPP_INLINE_VISIBILITY
1577 operator%=(const _Expr& __v) const;
1579 template <class _Expr>
1582 __is_val_expr<_Expr>::value,
1585 _LIBCPP_INLINE_VISIBILITY
1586 operator+=(const _Expr& __v) const;
1588 template <class _Expr>
1591 __is_val_expr<_Expr>::value,
1594 _LIBCPP_INLINE_VISIBILITY
1595 operator-=(const _Expr& __v) const;
1597 template <class _Expr>
1600 __is_val_expr<_Expr>::value,
1603 _LIBCPP_INLINE_VISIBILITY
1604 operator^=(const _Expr& __v) const;
1606 template <class _Expr>
1609 __is_val_expr<_Expr>::value,
1612 _LIBCPP_INLINE_VISIBILITY
1613 operator&=(const _Expr& __v) const;
1615 template <class _Expr>
1618 __is_val_expr<_Expr>::value,
1621 _LIBCPP_INLINE_VISIBILITY
1622 operator|=(const _Expr& __v) const;
1624 template <class _Expr>
1627 __is_val_expr<_Expr>::value,
1630 _LIBCPP_INLINE_VISIBILITY
1631 operator<<=(const _Expr& __v) const;
1633 template <class _Expr>
1636 __is_val_expr<_Expr>::value,
1639 _LIBCPP_INLINE_VISIBILITY
1640 operator>>=(const _Expr& __v) const;
1642 _LIBCPP_INLINE_VISIBILITY
1643 const gslice_array& operator=(const gslice_array& __ga) const;
1645 _LIBCPP_INLINE_VISIBILITY
1646 void operator=(const value_type& __x) const;
1648 // gslice_array(const gslice_array&) = default;
1649 // gslice_array(gslice_array&&) = default;
1650 // gslice_array& operator=(const gslice_array&) = default;
1651 // gslice_array& operator=(gslice_array&&) = default;
1654 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
1655 : __vp_(const_cast<value_type*>(__v.__begin_)),
1659 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
1660 gslice_array(gslice&& __gs, const valarray<value_type>& __v)
1661 : __vp_(const_cast<value_type*>(__v.__begin_)),
1662 __1d_(move(__gs.__1d_))
1664 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
1666 template <class> friend class valarray;
1669 template <class _Tp>
1670 template <class _Expr>
1674 __is_val_expr<_Expr>::value,
1677 gslice_array<_Tp>::operator=(const _Expr& __v) const
1679 typedef const size_t* _Ip;
1681 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1682 __vp_[*__i] = __v[__j];
1685 template <class _Tp>
1686 template <class _Expr>
1690 __is_val_expr<_Expr>::value,
1693 gslice_array<_Tp>::operator*=(const _Expr& __v) const
1695 typedef const size_t* _Ip;
1697 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1698 __vp_[*__i] *= __v[__j];
1701 template <class _Tp>
1702 template <class _Expr>
1706 __is_val_expr<_Expr>::value,
1709 gslice_array<_Tp>::operator/=(const _Expr& __v) const
1711 typedef const size_t* _Ip;
1713 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1714 __vp_[*__i] /= __v[__j];
1717 template <class _Tp>
1718 template <class _Expr>
1722 __is_val_expr<_Expr>::value,
1725 gslice_array<_Tp>::operator%=(const _Expr& __v) const
1727 typedef const size_t* _Ip;
1729 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1730 __vp_[*__i] %= __v[__j];
1733 template <class _Tp>
1734 template <class _Expr>
1738 __is_val_expr<_Expr>::value,
1741 gslice_array<_Tp>::operator+=(const _Expr& __v) const
1743 typedef const size_t* _Ip;
1745 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1746 __vp_[*__i] += __v[__j];
1749 template <class _Tp>
1750 template <class _Expr>
1754 __is_val_expr<_Expr>::value,
1757 gslice_array<_Tp>::operator-=(const _Expr& __v) const
1759 typedef const size_t* _Ip;
1761 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1762 __vp_[*__i] -= __v[__j];
1765 template <class _Tp>
1766 template <class _Expr>
1770 __is_val_expr<_Expr>::value,
1773 gslice_array<_Tp>::operator^=(const _Expr& __v) const
1775 typedef const size_t* _Ip;
1777 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1778 __vp_[*__i] ^= __v[__j];
1781 template <class _Tp>
1782 template <class _Expr>
1786 __is_val_expr<_Expr>::value,
1789 gslice_array<_Tp>::operator&=(const _Expr& __v) const
1791 typedef const size_t* _Ip;
1793 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1794 __vp_[*__i] &= __v[__j];
1797 template <class _Tp>
1798 template <class _Expr>
1802 __is_val_expr<_Expr>::value,
1805 gslice_array<_Tp>::operator|=(const _Expr& __v) const
1807 typedef const size_t* _Ip;
1809 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1810 __vp_[*__i] |= __v[__j];
1813 template <class _Tp>
1814 template <class _Expr>
1818 __is_val_expr<_Expr>::value,
1821 gslice_array<_Tp>::operator<<=(const _Expr& __v) const
1823 typedef const size_t* _Ip;
1825 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1826 __vp_[*__i] <<= __v[__j];
1829 template <class _Tp>
1830 template <class _Expr>
1834 __is_val_expr<_Expr>::value,
1837 gslice_array<_Tp>::operator>>=(const _Expr& __v) const
1839 typedef const size_t* _Ip;
1841 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j)
1842 __vp_[*__i] >>= __v[__j];
1845 template <class _Tp>
1847 const gslice_array<_Tp>&
1848 gslice_array<_Tp>::operator=(const gslice_array& __ga) const
1850 typedef const size_t* _Ip;
1851 const value_type* __s = __ga.__vp_;
1852 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_;
1853 __i != __e; ++__i, ++__j)
1854 __vp_[*__i] = __s[*__j];
1858 template <class _Tp>
1861 gslice_array<_Tp>::operator=(const value_type& __x) const
1863 typedef const size_t* _Ip;
1864 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
1870 template <class _Tp>
1871 class _LIBCPP_TEMPLATE_VIS mask_array
1874 typedef _Tp value_type;
1878 valarray<size_t> __1d_;
1881 template <class _Expr>
1884 __is_val_expr<_Expr>::value,
1887 _LIBCPP_INLINE_VISIBILITY
1888 operator=(const _Expr& __v) const;
1890 template <class _Expr>
1893 __is_val_expr<_Expr>::value,
1896 _LIBCPP_INLINE_VISIBILITY
1897 operator*=(const _Expr& __v) const;
1899 template <class _Expr>
1902 __is_val_expr<_Expr>::value,
1905 _LIBCPP_INLINE_VISIBILITY
1906 operator/=(const _Expr& __v) const;
1908 template <class _Expr>
1911 __is_val_expr<_Expr>::value,
1914 _LIBCPP_INLINE_VISIBILITY
1915 operator%=(const _Expr& __v) const;
1917 template <class _Expr>
1920 __is_val_expr<_Expr>::value,
1923 _LIBCPP_INLINE_VISIBILITY
1924 operator+=(const _Expr& __v) const;
1926 template <class _Expr>
1929 __is_val_expr<_Expr>::value,
1932 _LIBCPP_INLINE_VISIBILITY
1933 operator-=(const _Expr& __v) const;
1935 template <class _Expr>
1938 __is_val_expr<_Expr>::value,
1941 _LIBCPP_INLINE_VISIBILITY
1942 operator^=(const _Expr& __v) const;
1944 template <class _Expr>
1947 __is_val_expr<_Expr>::value,
1950 _LIBCPP_INLINE_VISIBILITY
1951 operator&=(const _Expr& __v) const;
1953 template <class _Expr>
1956 __is_val_expr<_Expr>::value,
1959 _LIBCPP_INLINE_VISIBILITY
1960 operator|=(const _Expr& __v) const;
1962 template <class _Expr>
1965 __is_val_expr<_Expr>::value,
1968 _LIBCPP_INLINE_VISIBILITY
1969 operator<<=(const _Expr& __v) const;
1971 template <class _Expr>
1974 __is_val_expr<_Expr>::value,
1977 _LIBCPP_INLINE_VISIBILITY
1978 operator>>=(const _Expr& __v) const;
1980 _LIBCPP_INLINE_VISIBILITY
1981 const mask_array& operator=(const mask_array& __ma) const;
1983 _LIBCPP_INLINE_VISIBILITY
1984 void operator=(const value_type& __x) const;
1986 // mask_array(const mask_array&) = default;
1987 // mask_array(mask_array&&) = default;
1988 // mask_array& operator=(const mask_array&) = default;
1989 // mask_array& operator=(mask_array&&) = default;
1992 _LIBCPP_INLINE_VISIBILITY
1993 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
1994 : __vp_(const_cast<value_type*>(__v.__begin_)),
1995 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
1998 for (size_t __i = 0; __i < __vb.size(); ++__i)
2003 template <class> friend class valarray;
2006 template <class _Tp>
2007 template <class _Expr>
2011 __is_val_expr<_Expr>::value,
2014 mask_array<_Tp>::operator=(const _Expr& __v) const
2016 size_t __n = __1d_.size();
2017 for (size_t __i = 0; __i < __n; ++__i)
2018 __vp_[__1d_[__i]] = __v[__i];
2021 template <class _Tp>
2022 template <class _Expr>
2026 __is_val_expr<_Expr>::value,
2029 mask_array<_Tp>::operator*=(const _Expr& __v) const
2031 size_t __n = __1d_.size();
2032 for (size_t __i = 0; __i < __n; ++__i)
2033 __vp_[__1d_[__i]] *= __v[__i];
2036 template <class _Tp>
2037 template <class _Expr>
2041 __is_val_expr<_Expr>::value,
2044 mask_array<_Tp>::operator/=(const _Expr& __v) const
2046 size_t __n = __1d_.size();
2047 for (size_t __i = 0; __i < __n; ++__i)
2048 __vp_[__1d_[__i]] /= __v[__i];
2051 template <class _Tp>
2052 template <class _Expr>
2056 __is_val_expr<_Expr>::value,
2059 mask_array<_Tp>::operator%=(const _Expr& __v) const
2061 size_t __n = __1d_.size();
2062 for (size_t __i = 0; __i < __n; ++__i)
2063 __vp_[__1d_[__i]] %= __v[__i];
2066 template <class _Tp>
2067 template <class _Expr>
2071 __is_val_expr<_Expr>::value,
2074 mask_array<_Tp>::operator+=(const _Expr& __v) const
2076 size_t __n = __1d_.size();
2077 for (size_t __i = 0; __i < __n; ++__i)
2078 __vp_[__1d_[__i]] += __v[__i];
2081 template <class _Tp>
2082 template <class _Expr>
2086 __is_val_expr<_Expr>::value,
2089 mask_array<_Tp>::operator-=(const _Expr& __v) const
2091 size_t __n = __1d_.size();
2092 for (size_t __i = 0; __i < __n; ++__i)
2093 __vp_[__1d_[__i]] -= __v[__i];
2096 template <class _Tp>
2097 template <class _Expr>
2101 __is_val_expr<_Expr>::value,
2104 mask_array<_Tp>::operator^=(const _Expr& __v) const
2106 size_t __n = __1d_.size();
2107 for (size_t __i = 0; __i < __n; ++__i)
2108 __vp_[__1d_[__i]] ^= __v[__i];
2111 template <class _Tp>
2112 template <class _Expr>
2116 __is_val_expr<_Expr>::value,
2119 mask_array<_Tp>::operator&=(const _Expr& __v) const
2121 size_t __n = __1d_.size();
2122 for (size_t __i = 0; __i < __n; ++__i)
2123 __vp_[__1d_[__i]] &= __v[__i];
2126 template <class _Tp>
2127 template <class _Expr>
2131 __is_val_expr<_Expr>::value,
2134 mask_array<_Tp>::operator|=(const _Expr& __v) const
2136 size_t __n = __1d_.size();
2137 for (size_t __i = 0; __i < __n; ++__i)
2138 __vp_[__1d_[__i]] |= __v[__i];
2141 template <class _Tp>
2142 template <class _Expr>
2146 __is_val_expr<_Expr>::value,
2149 mask_array<_Tp>::operator<<=(const _Expr& __v) const
2151 size_t __n = __1d_.size();
2152 for (size_t __i = 0; __i < __n; ++__i)
2153 __vp_[__1d_[__i]] <<= __v[__i];
2156 template <class _Tp>
2157 template <class _Expr>
2161 __is_val_expr<_Expr>::value,
2164 mask_array<_Tp>::operator>>=(const _Expr& __v) const
2166 size_t __n = __1d_.size();
2167 for (size_t __i = 0; __i < __n; ++__i)
2168 __vp_[__1d_[__i]] >>= __v[__i];
2171 template <class _Tp>
2173 const mask_array<_Tp>&
2174 mask_array<_Tp>::operator=(const mask_array& __ma) const
2176 size_t __n = __1d_.size();
2177 for (size_t __i = 0; __i < __n; ++__i)
2178 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]];
2182 template <class _Tp>
2185 mask_array<_Tp>::operator=(const value_type& __x) const
2187 size_t __n = __1d_.size();
2188 for (size_t __i = 0; __i < __n; ++__i)
2189 __vp_[__1d_[__i]] = __x;
2192 template <class _ValExpr>
2195 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2197 typedef typename _RmExpr::value_type value_type;
2198 typedef value_type result_type;
2202 valarray<size_t> __1d_;
2204 _LIBCPP_INLINE_VISIBILITY
2205 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e)
2207 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true)))
2210 for (size_t __i = 0; __i < __vb.size(); ++__i)
2216 _LIBCPP_INLINE_VISIBILITY
2217 result_type operator[](size_t __i) const
2218 {return __expr_[__1d_[__i]];}
2220 _LIBCPP_INLINE_VISIBILITY
2221 size_t size() const {return __1d_.size();}
2223 template <class> friend class valarray;
2228 template <class _Tp>
2229 class _LIBCPP_TEMPLATE_VIS indirect_array
2232 typedef _Tp value_type;
2236 valarray<size_t> __1d_;
2239 template <class _Expr>
2242 __is_val_expr<_Expr>::value,
2245 _LIBCPP_INLINE_VISIBILITY
2246 operator=(const _Expr& __v) const;
2248 template <class _Expr>
2251 __is_val_expr<_Expr>::value,
2254 _LIBCPP_INLINE_VISIBILITY
2255 operator*=(const _Expr& __v) const;
2257 template <class _Expr>
2260 __is_val_expr<_Expr>::value,
2263 _LIBCPP_INLINE_VISIBILITY
2264 operator/=(const _Expr& __v) const;
2266 template <class _Expr>
2269 __is_val_expr<_Expr>::value,
2272 _LIBCPP_INLINE_VISIBILITY
2273 operator%=(const _Expr& __v) const;
2275 template <class _Expr>
2278 __is_val_expr<_Expr>::value,
2281 _LIBCPP_INLINE_VISIBILITY
2282 operator+=(const _Expr& __v) const;
2284 template <class _Expr>
2287 __is_val_expr<_Expr>::value,
2290 _LIBCPP_INLINE_VISIBILITY
2291 operator-=(const _Expr& __v) const;
2293 template <class _Expr>
2296 __is_val_expr<_Expr>::value,
2299 _LIBCPP_INLINE_VISIBILITY
2300 operator^=(const _Expr& __v) const;
2302 template <class _Expr>
2305 __is_val_expr<_Expr>::value,
2308 _LIBCPP_INLINE_VISIBILITY
2309 operator&=(const _Expr& __v) const;
2311 template <class _Expr>
2314 __is_val_expr<_Expr>::value,
2317 _LIBCPP_INLINE_VISIBILITY
2318 operator|=(const _Expr& __v) const;
2320 template <class _Expr>
2323 __is_val_expr<_Expr>::value,
2326 _LIBCPP_INLINE_VISIBILITY
2327 operator<<=(const _Expr& __v) const;
2329 template <class _Expr>
2332 __is_val_expr<_Expr>::value,
2335 _LIBCPP_INLINE_VISIBILITY
2336 operator>>=(const _Expr& __v) const;
2338 _LIBCPP_INLINE_VISIBILITY
2339 const indirect_array& operator=(const indirect_array& __ia) const;
2341 _LIBCPP_INLINE_VISIBILITY
2342 void operator=(const value_type& __x) const;
2344 // indirect_array(const indirect_array&) = default;
2345 // indirect_array(indirect_array&&) = default;
2346 // indirect_array& operator=(const indirect_array&) = default;
2347 // indirect_array& operator=(indirect_array&&) = default;
2350 _LIBCPP_INLINE_VISIBILITY
2351 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
2352 : __vp_(const_cast<value_type*>(__v.__begin_)),
2356 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2358 _LIBCPP_INLINE_VISIBILITY
2359 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v)
2360 : __vp_(const_cast<value_type*>(__v.__begin_)),
2364 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2366 template <class> friend class valarray;
2369 template <class _Tp>
2370 template <class _Expr>
2374 __is_val_expr<_Expr>::value,
2377 indirect_array<_Tp>::operator=(const _Expr& __v) const
2379 size_t __n = __1d_.size();
2380 for (size_t __i = 0; __i < __n; ++__i)
2381 __vp_[__1d_[__i]] = __v[__i];
2384 template <class _Tp>
2385 template <class _Expr>
2389 __is_val_expr<_Expr>::value,
2392 indirect_array<_Tp>::operator*=(const _Expr& __v) const
2394 size_t __n = __1d_.size();
2395 for (size_t __i = 0; __i < __n; ++__i)
2396 __vp_[__1d_[__i]] *= __v[__i];
2399 template <class _Tp>
2400 template <class _Expr>
2404 __is_val_expr<_Expr>::value,
2407 indirect_array<_Tp>::operator/=(const _Expr& __v) const
2409 size_t __n = __1d_.size();
2410 for (size_t __i = 0; __i < __n; ++__i)
2411 __vp_[__1d_[__i]] /= __v[__i];
2414 template <class _Tp>
2415 template <class _Expr>
2419 __is_val_expr<_Expr>::value,
2422 indirect_array<_Tp>::operator%=(const _Expr& __v) const
2424 size_t __n = __1d_.size();
2425 for (size_t __i = 0; __i < __n; ++__i)
2426 __vp_[__1d_[__i]] %= __v[__i];
2429 template <class _Tp>
2430 template <class _Expr>
2434 __is_val_expr<_Expr>::value,
2437 indirect_array<_Tp>::operator+=(const _Expr& __v) const
2439 size_t __n = __1d_.size();
2440 for (size_t __i = 0; __i < __n; ++__i)
2441 __vp_[__1d_[__i]] += __v[__i];
2444 template <class _Tp>
2445 template <class _Expr>
2449 __is_val_expr<_Expr>::value,
2452 indirect_array<_Tp>::operator-=(const _Expr& __v) const
2454 size_t __n = __1d_.size();
2455 for (size_t __i = 0; __i < __n; ++__i)
2456 __vp_[__1d_[__i]] -= __v[__i];
2459 template <class _Tp>
2460 template <class _Expr>
2464 __is_val_expr<_Expr>::value,
2467 indirect_array<_Tp>::operator^=(const _Expr& __v) const
2469 size_t __n = __1d_.size();
2470 for (size_t __i = 0; __i < __n; ++__i)
2471 __vp_[__1d_[__i]] ^= __v[__i];
2474 template <class _Tp>
2475 template <class _Expr>
2479 __is_val_expr<_Expr>::value,
2482 indirect_array<_Tp>::operator&=(const _Expr& __v) const
2484 size_t __n = __1d_.size();
2485 for (size_t __i = 0; __i < __n; ++__i)
2486 __vp_[__1d_[__i]] &= __v[__i];
2489 template <class _Tp>
2490 template <class _Expr>
2494 __is_val_expr<_Expr>::value,
2497 indirect_array<_Tp>::operator|=(const _Expr& __v) const
2499 size_t __n = __1d_.size();
2500 for (size_t __i = 0; __i < __n; ++__i)
2501 __vp_[__1d_[__i]] |= __v[__i];
2504 template <class _Tp>
2505 template <class _Expr>
2509 __is_val_expr<_Expr>::value,
2512 indirect_array<_Tp>::operator<<=(const _Expr& __v) const
2514 size_t __n = __1d_.size();
2515 for (size_t __i = 0; __i < __n; ++__i)
2516 __vp_[__1d_[__i]] <<= __v[__i];
2519 template <class _Tp>
2520 template <class _Expr>
2524 __is_val_expr<_Expr>::value,
2527 indirect_array<_Tp>::operator>>=(const _Expr& __v) const
2529 size_t __n = __1d_.size();
2530 for (size_t __i = 0; __i < __n; ++__i)
2531 __vp_[__1d_[__i]] >>= __v[__i];
2534 template <class _Tp>
2536 const indirect_array<_Tp>&
2537 indirect_array<_Tp>::operator=(const indirect_array& __ia) const
2539 typedef const size_t* _Ip;
2540 const value_type* __s = __ia.__vp_;
2541 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_;
2542 __i != __e; ++__i, ++__j)
2543 __vp_[*__i] = __s[*__j];
2547 template <class _Tp>
2550 indirect_array<_Tp>::operator=(const value_type& __x) const
2552 typedef const size_t* _Ip;
2553 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i)
2557 template <class _ValExpr>
2558 class __indirect_expr
2560 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2562 typedef typename _RmExpr::value_type value_type;
2563 typedef value_type result_type;
2567 valarray<size_t> __1d_;
2569 _LIBCPP_INLINE_VISIBILITY
2570 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e)
2575 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2577 _LIBCPP_INLINE_VISIBILITY
2578 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e)
2583 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2586 _LIBCPP_INLINE_VISIBILITY
2587 result_type operator[](size_t __i) const
2588 {return __expr_[__1d_[__i]];}
2590 _LIBCPP_INLINE_VISIBILITY
2591 size_t size() const {return __1d_.size();}
2593 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray;
2596 template<class _ValExpr>
2599 typedef typename remove_reference<_ValExpr>::type _RmExpr;
2603 typedef typename _RmExpr::value_type value_type;
2604 typedef typename _RmExpr::result_type result_type;
2606 _LIBCPP_INLINE_VISIBILITY
2607 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {}
2609 _LIBCPP_INLINE_VISIBILITY
2610 result_type operator[](size_t __i) const
2611 {return __expr_[__i];}
2613 _LIBCPP_INLINE_VISIBILITY
2614 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const
2615 {return __val_expr<__slice_expr<_ValExpr> >(__expr_, __s);}
2617 _LIBCPP_INLINE_VISIBILITY
2618 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const
2619 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __gs.__1d_);}
2621 _LIBCPP_INLINE_VISIBILITY
2622 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const
2623 {return __val_expr<__mask_expr<_ValExpr> >(__expr_, __vb);}
2625 _LIBCPP_INLINE_VISIBILITY
2626 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const
2627 {return __val_expr<__indirect_expr<_ValExpr> >(__expr_, __vs);}
2629 _LIBCPP_INLINE_VISIBILITY
2630 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> >
2633 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr;
2634 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_));
2637 _LIBCPP_INLINE_VISIBILITY
2638 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> >
2641 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr;
2642 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_));
2645 _LIBCPP_INLINE_VISIBILITY
2646 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> >
2649 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr;
2650 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_));
2653 _LIBCPP_INLINE_VISIBILITY
2654 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> >
2657 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr;
2658 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_));
2661 operator valarray<result_type>() const;
2663 _LIBCPP_INLINE_VISIBILITY
2664 size_t size() const {return __expr_.size();}
2666 _LIBCPP_INLINE_VISIBILITY
2667 result_type sum() const
2669 size_t __n = __expr_.size();
2670 result_type __r = __n ? __expr_[0] : result_type();
2671 for (size_t __i = 1; __i < __n; ++__i)
2672 __r += __expr_[__i];
2676 _LIBCPP_INLINE_VISIBILITY
2677 result_type min() const
2679 size_t __n = size();
2680 result_type __r = __n ? (*this)[0] : result_type();
2681 for (size_t __i = 1; __i < __n; ++__i)
2683 result_type __x = __expr_[__i];
2690 _LIBCPP_INLINE_VISIBILITY
2691 result_type max() const
2693 size_t __n = size();
2694 result_type __r = __n ? (*this)[0] : result_type();
2695 for (size_t __i = 1; __i < __n; ++__i)
2697 result_type __x = __expr_[__i];
2704 _LIBCPP_INLINE_VISIBILITY
2705 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const
2706 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));}
2708 _LIBCPP_INLINE_VISIBILITY
2709 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const
2710 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));}
2712 _LIBCPP_INLINE_VISIBILITY
2713 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> >
2714 apply(value_type __f(value_type)) const
2716 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op;
2717 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2718 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2721 _LIBCPP_INLINE_VISIBILITY
2722 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> >
2723 apply(value_type __f(const value_type&)) const
2725 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op;
2726 typedef _UnaryOp<_Op, _ValExpr> _NewExpr;
2727 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_));
2731 template<class _ValExpr>
2732 __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const
2734 valarray<result_type> __r;
2735 size_t __n = __expr_.size();
2740 static_cast<result_type*>(_VSTD::__allocate(__n * sizeof(result_type)));
2741 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i)
2742 ::new (__r.__end_) result_type(__expr_[__i]);
2749 template <class _Tp>
2751 valarray<_Tp>::valarray(size_t __n)
2758 template <class _Tp>
2760 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
2767 template <class _Tp>
2768 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
2774 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2775 #ifndef _LIBCPP_NO_EXCEPTIONS
2778 #endif // _LIBCPP_NO_EXCEPTIONS
2779 for (; __n; ++__end_, ++__p, --__n)
2780 ::new (__end_) value_type(*__p);
2781 #ifndef _LIBCPP_NO_EXCEPTIONS
2788 #endif // _LIBCPP_NO_EXCEPTIONS
2792 template <class _Tp>
2793 valarray<_Tp>::valarray(const valarray& __v)
2799 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__v.size() * sizeof(value_type)));
2800 #ifndef _LIBCPP_NO_EXCEPTIONS
2803 #endif // _LIBCPP_NO_EXCEPTIONS
2804 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p)
2805 ::new (__end_) value_type(*__p);
2806 #ifndef _LIBCPP_NO_EXCEPTIONS
2813 #endif // _LIBCPP_NO_EXCEPTIONS
2817 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2819 template <class _Tp>
2821 valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT
2822 : __begin_(__v.__begin_),
2825 __v.__begin_ = __v.__end_ = nullptr;
2828 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
2830 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2832 template <class _Tp>
2833 valarray<_Tp>::valarray(initializer_list<value_type> __il)
2837 size_t __n = __il.size();
2840 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2841 #ifndef _LIBCPP_NO_EXCEPTIONS
2844 #endif // _LIBCPP_NO_EXCEPTIONS
2845 for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n)
2846 ::new (__end_) value_type(*__p);
2847 #ifndef _LIBCPP_NO_EXCEPTIONS
2854 #endif // _LIBCPP_NO_EXCEPTIONS
2858 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
2860 template <class _Tp>
2861 valarray<_Tp>::valarray(const slice_array<value_type>& __sa)
2865 size_t __n = __sa.__size_;
2868 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2869 #ifndef _LIBCPP_NO_EXCEPTIONS
2872 #endif // _LIBCPP_NO_EXCEPTIONS
2873 for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n)
2874 ::new (__end_) value_type(*__p);
2875 #ifndef _LIBCPP_NO_EXCEPTIONS
2882 #endif // _LIBCPP_NO_EXCEPTIONS
2886 template <class _Tp>
2887 valarray<_Tp>::valarray(const gslice_array<value_type>& __ga)
2891 size_t __n = __ga.__1d_.size();
2894 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2895 #ifndef _LIBCPP_NO_EXCEPTIONS
2898 #endif // _LIBCPP_NO_EXCEPTIONS
2899 typedef const size_t* _Ip;
2900 const value_type* __s = __ga.__vp_;
2901 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
2902 __i != __e; ++__i, ++__end_)
2903 ::new (__end_) value_type(__s[*__i]);
2904 #ifndef _LIBCPP_NO_EXCEPTIONS
2911 #endif // _LIBCPP_NO_EXCEPTIONS
2915 template <class _Tp>
2916 valarray<_Tp>::valarray(const mask_array<value_type>& __ma)
2920 size_t __n = __ma.__1d_.size();
2923 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2924 #ifndef _LIBCPP_NO_EXCEPTIONS
2927 #endif // _LIBCPP_NO_EXCEPTIONS
2928 typedef const size_t* _Ip;
2929 const value_type* __s = __ma.__vp_;
2930 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
2931 __i != __e; ++__i, ++__end_)
2932 ::new (__end_) value_type(__s[*__i]);
2933 #ifndef _LIBCPP_NO_EXCEPTIONS
2940 #endif // _LIBCPP_NO_EXCEPTIONS
2944 template <class _Tp>
2945 valarray<_Tp>::valarray(const indirect_array<value_type>& __ia)
2949 size_t __n = __ia.__1d_.size();
2952 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
2953 #ifndef _LIBCPP_NO_EXCEPTIONS
2956 #endif // _LIBCPP_NO_EXCEPTIONS
2957 typedef const size_t* _Ip;
2958 const value_type* __s = __ia.__vp_;
2959 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
2960 __i != __e; ++__i, ++__end_)
2961 ::new (__end_) value_type(__s[*__i]);
2962 #ifndef _LIBCPP_NO_EXCEPTIONS
2969 #endif // _LIBCPP_NO_EXCEPTIONS
2973 template <class _Tp>
2975 valarray<_Tp>::~valarray()
2980 template <class _Tp>
2982 valarray<_Tp>::operator=(const valarray& __v)
2986 if (size() != __v.size())
2988 _VSTD::copy(__v.__begin_, __v.__end_, __begin_);
2993 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
2995 template <class _Tp>
2998 valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT
3001 __begin_ = __v.__begin_;
3002 __end_ = __v.__end_;
3003 __v.__begin_ = nullptr;
3004 __v.__end_ = nullptr;
3008 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3010 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
3012 template <class _Tp>
3015 valarray<_Tp>::operator=(initializer_list<value_type> __il)
3017 if (size() != __il.size())
3018 resize(__il.size());
3019 _VSTD::copy(__il.begin(), __il.end(), __begin_);
3023 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
3025 template <class _Tp>
3028 valarray<_Tp>::operator=(const value_type& __x)
3030 _VSTD::fill(__begin_, __end_, __x);
3034 template <class _Tp>
3037 valarray<_Tp>::operator=(const slice_array<value_type>& __sa)
3039 value_type* __t = __begin_;
3040 const value_type* __s = __sa.__vp_;
3041 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t)
3046 template <class _Tp>
3049 valarray<_Tp>::operator=(const gslice_array<value_type>& __ga)
3051 typedef const size_t* _Ip;
3052 value_type* __t = __begin_;
3053 const value_type* __s = __ga.__vp_;
3054 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_;
3055 __i != __e; ++__i, ++__t)
3060 template <class _Tp>
3063 valarray<_Tp>::operator=(const mask_array<value_type>& __ma)
3065 typedef const size_t* _Ip;
3066 value_type* __t = __begin_;
3067 const value_type* __s = __ma.__vp_;
3068 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_;
3069 __i != __e; ++__i, ++__t)
3074 template <class _Tp>
3077 valarray<_Tp>::operator=(const indirect_array<value_type>& __ia)
3079 typedef const size_t* _Ip;
3080 value_type* __t = __begin_;
3081 const value_type* __s = __ia.__vp_;
3082 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_;
3083 __i != __e; ++__i, ++__t)
3088 template <class _Tp>
3089 template <class _ValExpr>
3092 valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v)
3094 size_t __n = __v.size();
3097 value_type* __t = __begin_;
3098 for (size_t __i = 0; __i != __n; ++__t, ++__i)
3099 *__t = result_type(__v[__i]);
3103 template <class _Tp>
3105 __val_expr<__slice_expr<const valarray<_Tp>&> >
3106 valarray<_Tp>::operator[](slice __s) const
3108 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this));
3111 template <class _Tp>
3114 valarray<_Tp>::operator[](slice __s)
3116 return slice_array<value_type>(__s, *this);
3119 template <class _Tp>
3121 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3122 valarray<_Tp>::operator[](const gslice& __gs) const
3124 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this));
3127 template <class _Tp>
3130 valarray<_Tp>::operator[](const gslice& __gs)
3132 return gslice_array<value_type>(__gs, *this);
3135 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3137 template <class _Tp>
3139 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3140 valarray<_Tp>::operator[](gslice&& __gs) const
3142 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this));
3145 template <class _Tp>
3148 valarray<_Tp>::operator[](gslice&& __gs)
3150 return gslice_array<value_type>(move(__gs), *this);
3153 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3155 template <class _Tp>
3157 __val_expr<__mask_expr<const valarray<_Tp>&> >
3158 valarray<_Tp>::operator[](const valarray<bool>& __vb) const
3160 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this));
3163 template <class _Tp>
3166 valarray<_Tp>::operator[](const valarray<bool>& __vb)
3168 return mask_array<value_type>(__vb, *this);
3171 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3173 template <class _Tp>
3175 __val_expr<__mask_expr<const valarray<_Tp>&> >
3176 valarray<_Tp>::operator[](valarray<bool>&& __vb) const
3178 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this));
3181 template <class _Tp>
3184 valarray<_Tp>::operator[](valarray<bool>&& __vb)
3186 return mask_array<value_type>(move(__vb), *this);
3189 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3191 template <class _Tp>
3193 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3194 valarray<_Tp>::operator[](const valarray<size_t>& __vs) const
3196 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this));
3199 template <class _Tp>
3202 valarray<_Tp>::operator[](const valarray<size_t>& __vs)
3204 return indirect_array<value_type>(__vs, *this);
3207 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
3209 template <class _Tp>
3211 __val_expr<__indirect_expr<const valarray<_Tp>&> >
3212 valarray<_Tp>::operator[](valarray<size_t>&& __vs) const
3214 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this));
3217 template <class _Tp>
3220 valarray<_Tp>::operator[](valarray<size_t>&& __vs)
3222 return indirect_array<value_type>(move(__vs), *this);
3225 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
3227 template <class _Tp>
3229 valarray<_Tp>::operator+() const
3231 valarray<value_type> __r;
3232 size_t __n = size();
3237 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3238 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3239 ::new (__r.__end_) value_type(+*__p);
3244 template <class _Tp>
3246 valarray<_Tp>::operator-() const
3248 valarray<value_type> __r;
3249 size_t __n = size();
3254 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3255 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3256 ::new (__r.__end_) value_type(-*__p);
3261 template <class _Tp>
3263 valarray<_Tp>::operator~() const
3265 valarray<value_type> __r;
3266 size_t __n = size();
3271 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3272 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3273 ::new (__r.__end_) value_type(~*__p);
3278 template <class _Tp>
3280 valarray<_Tp>::operator!() const
3283 size_t __n = size();
3288 static_cast<bool*>(_VSTD::__allocate(__n * sizeof(bool)));
3289 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3290 ::new (__r.__end_) bool(!*__p);
3295 template <class _Tp>
3298 valarray<_Tp>::operator*=(const value_type& __x)
3300 for (value_type* __p = __begin_; __p != __end_; ++__p)
3305 template <class _Tp>
3308 valarray<_Tp>::operator/=(const value_type& __x)
3310 for (value_type* __p = __begin_; __p != __end_; ++__p)
3315 template <class _Tp>
3318 valarray<_Tp>::operator%=(const value_type& __x)
3320 for (value_type* __p = __begin_; __p != __end_; ++__p)
3325 template <class _Tp>
3328 valarray<_Tp>::operator+=(const value_type& __x)
3330 for (value_type* __p = __begin_; __p != __end_; ++__p)
3335 template <class _Tp>
3338 valarray<_Tp>::operator-=(const value_type& __x)
3340 for (value_type* __p = __begin_; __p != __end_; ++__p)
3345 template <class _Tp>
3348 valarray<_Tp>::operator^=(const value_type& __x)
3350 for (value_type* __p = __begin_; __p != __end_; ++__p)
3355 template <class _Tp>
3358 valarray<_Tp>::operator&=(const value_type& __x)
3360 for (value_type* __p = __begin_; __p != __end_; ++__p)
3365 template <class _Tp>
3368 valarray<_Tp>::operator|=(const value_type& __x)
3370 for (value_type* __p = __begin_; __p != __end_; ++__p)
3375 template <class _Tp>
3378 valarray<_Tp>::operator<<=(const value_type& __x)
3380 for (value_type* __p = __begin_; __p != __end_; ++__p)
3385 template <class _Tp>
3388 valarray<_Tp>::operator>>=(const value_type& __x)
3390 for (value_type* __p = __begin_; __p != __end_; ++__p)
3395 template <class _Tp>
3396 template <class _Expr>
3400 __is_val_expr<_Expr>::value,
3403 valarray<_Tp>::operator*=(const _Expr& __v)
3406 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3411 template <class _Tp>
3412 template <class _Expr>
3416 __is_val_expr<_Expr>::value,
3419 valarray<_Tp>::operator/=(const _Expr& __v)
3422 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3427 template <class _Tp>
3428 template <class _Expr>
3432 __is_val_expr<_Expr>::value,
3435 valarray<_Tp>::operator%=(const _Expr& __v)
3438 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3443 template <class _Tp>
3444 template <class _Expr>
3448 __is_val_expr<_Expr>::value,
3451 valarray<_Tp>::operator+=(const _Expr& __v)
3454 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3459 template <class _Tp>
3460 template <class _Expr>
3464 __is_val_expr<_Expr>::value,
3467 valarray<_Tp>::operator-=(const _Expr& __v)
3470 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3475 template <class _Tp>
3476 template <class _Expr>
3480 __is_val_expr<_Expr>::value,
3483 valarray<_Tp>::operator^=(const _Expr& __v)
3486 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3491 template <class _Tp>
3492 template <class _Expr>
3496 __is_val_expr<_Expr>::value,
3499 valarray<_Tp>::operator|=(const _Expr& __v)
3502 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3507 template <class _Tp>
3508 template <class _Expr>
3512 __is_val_expr<_Expr>::value,
3515 valarray<_Tp>::operator&=(const _Expr& __v)
3518 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3523 template <class _Tp>
3524 template <class _Expr>
3528 __is_val_expr<_Expr>::value,
3531 valarray<_Tp>::operator<<=(const _Expr& __v)
3534 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3539 template <class _Tp>
3540 template <class _Expr>
3544 __is_val_expr<_Expr>::value,
3547 valarray<_Tp>::operator>>=(const _Expr& __v)
3550 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i)
3555 template <class _Tp>
3558 valarray<_Tp>::swap(valarray& __v) _NOEXCEPT
3560 _VSTD::swap(__begin_, __v.__begin_);
3561 _VSTD::swap(__end_, __v.__end_);
3564 template <class _Tp>
3567 valarray<_Tp>::sum() const
3569 if (__begin_ == __end_)
3570 return value_type();
3571 const value_type* __p = __begin_;
3573 for (++__p; __p != __end_; ++__p)
3578 template <class _Tp>
3581 valarray<_Tp>::min() const
3583 if (__begin_ == __end_)
3584 return value_type();
3585 return *_VSTD::min_element(__begin_, __end_);
3588 template <class _Tp>
3591 valarray<_Tp>::max() const
3593 if (__begin_ == __end_)
3594 return value_type();
3595 return *_VSTD::max_element(__begin_, __end_);
3598 template <class _Tp>
3600 valarray<_Tp>::shift(int __i) const
3602 valarray<value_type> __r;
3603 size_t __n = size();
3608 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3609 const value_type* __sb;
3614 __i = _VSTD::min(__i, static_cast<int>(__n));
3615 __sb = __begin_ + __i;
3616 __tb = __r.__begin_;
3617 __te = __r.__begin_ + (__n - __i);
3621 __i = _VSTD::min(-__i, static_cast<int>(__n));
3623 __tb = __r.__begin_ + __i;
3624 __te = __r.__begin_ + __n;
3626 for (; __r.__end_ != __tb; ++__r.__end_)
3627 ::new (__r.__end_) value_type();
3628 for (; __r.__end_ != __te; ++__r.__end_, ++__sb)
3629 ::new (__r.__end_) value_type(*__sb);
3630 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_)
3631 ::new (__r.__end_) value_type();
3636 template <class _Tp>
3638 valarray<_Tp>::cshift(int __i) const
3640 valarray<value_type> __r;
3641 size_t __n = size();
3646 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3647 __i %= static_cast<int>(__n);
3648 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i;
3649 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s)
3650 ::new (__r.__end_) value_type(*__s);
3651 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s)
3652 ::new (__r.__end_) value_type(*__s);
3657 template <class _Tp>
3659 valarray<_Tp>::apply(value_type __f(value_type)) const
3661 valarray<value_type> __r;
3662 size_t __n = size();
3667 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3668 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3669 ::new (__r.__end_) value_type(__f(*__p));
3674 template <class _Tp>
3676 valarray<_Tp>::apply(value_type __f(const value_type&)) const
3678 valarray<value_type> __r;
3679 size_t __n = size();
3684 static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3685 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n)
3686 ::new (__r.__end_) value_type(__f(*__p));
3691 template <class _Tp>
3693 valarray<_Tp>::resize(size_t __n, value_type __x)
3695 if (__begin_ != nullptr)
3697 while (__end_ != __begin_)
3698 (--__end_)->~value_type();
3699 _VSTD::__libcpp_deallocate(__begin_);
3700 __begin_ = __end_ = nullptr;
3704 __begin_ = __end_ = static_cast<value_type*>(_VSTD::__allocate(__n * sizeof(value_type)));
3705 #ifndef _LIBCPP_NO_EXCEPTIONS
3708 #endif // _LIBCPP_NO_EXCEPTIONS
3709 for (; __n; --__n, ++__end_)
3710 ::new (__end_) value_type(__x);
3711 #ifndef _LIBCPP_NO_EXCEPTIONS
3718 #endif // _LIBCPP_NO_EXCEPTIONS
3723 inline _LIBCPP_INLINE_VISIBILITY
3725 swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT
3730 template<class _Expr1, class _Expr2>
3731 inline _LIBCPP_INLINE_VISIBILITY
3734 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3735 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> >
3737 operator*(const _Expr1& __x, const _Expr2& __y)
3739 typedef typename _Expr1::value_type value_type;
3740 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op;
3741 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y));
3744 template<class _Expr>
3745 inline _LIBCPP_INLINE_VISIBILITY
3748 __is_val_expr<_Expr>::value,
3749 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3750 _Expr, __scalar_expr<typename _Expr::value_type> > >
3752 operator*(const _Expr& __x, const typename _Expr::value_type& __y)
3754 typedef typename _Expr::value_type value_type;
3755 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3756 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3757 __x, __scalar_expr<value_type>(__y, __x.size())));
3760 template<class _Expr>
3761 inline _LIBCPP_INLINE_VISIBILITY
3764 __is_val_expr<_Expr>::value,
3765 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>,
3766 __scalar_expr<typename _Expr::value_type>, _Expr> >
3768 operator*(const typename _Expr::value_type& __x, const _Expr& __y)
3770 typedef typename _Expr::value_type value_type;
3771 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3772 return __val_expr<_Op>(_Op(multiplies<value_type>(),
3773 __scalar_expr<value_type>(__x, __y.size()), __y));
3776 template<class _Expr1, class _Expr2>
3777 inline _LIBCPP_INLINE_VISIBILITY
3780 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3781 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> >
3783 operator/(const _Expr1& __x, const _Expr2& __y)
3785 typedef typename _Expr1::value_type value_type;
3786 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op;
3787 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y));
3790 template<class _Expr>
3791 inline _LIBCPP_INLINE_VISIBILITY
3794 __is_val_expr<_Expr>::value,
3795 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3796 _Expr, __scalar_expr<typename _Expr::value_type> > >
3798 operator/(const _Expr& __x, const typename _Expr::value_type& __y)
3800 typedef typename _Expr::value_type value_type;
3801 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3802 return __val_expr<_Op>(_Op(divides<value_type>(),
3803 __x, __scalar_expr<value_type>(__y, __x.size())));
3806 template<class _Expr>
3807 inline _LIBCPP_INLINE_VISIBILITY
3810 __is_val_expr<_Expr>::value,
3811 __val_expr<_BinaryOp<divides<typename _Expr::value_type>,
3812 __scalar_expr<typename _Expr::value_type>, _Expr> >
3814 operator/(const typename _Expr::value_type& __x, const _Expr& __y)
3816 typedef typename _Expr::value_type value_type;
3817 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3818 return __val_expr<_Op>(_Op(divides<value_type>(),
3819 __scalar_expr<value_type>(__x, __y.size()), __y));
3822 template<class _Expr1, class _Expr2>
3823 inline _LIBCPP_INLINE_VISIBILITY
3826 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3827 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3829 operator%(const _Expr1& __x, const _Expr2& __y)
3831 typedef typename _Expr1::value_type value_type;
3832 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op;
3833 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y));
3836 template<class _Expr>
3837 inline _LIBCPP_INLINE_VISIBILITY
3840 __is_val_expr<_Expr>::value,
3841 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3842 _Expr, __scalar_expr<typename _Expr::value_type> > >
3844 operator%(const _Expr& __x, const typename _Expr::value_type& __y)
3846 typedef typename _Expr::value_type value_type;
3847 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3848 return __val_expr<_Op>(_Op(modulus<value_type>(),
3849 __x, __scalar_expr<value_type>(__y, __x.size())));
3852 template<class _Expr>
3853 inline _LIBCPP_INLINE_VISIBILITY
3856 __is_val_expr<_Expr>::value,
3857 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>,
3858 __scalar_expr<typename _Expr::value_type>, _Expr> >
3860 operator%(const typename _Expr::value_type& __x, const _Expr& __y)
3862 typedef typename _Expr::value_type value_type;
3863 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3864 return __val_expr<_Op>(_Op(modulus<value_type>(),
3865 __scalar_expr<value_type>(__x, __y.size()), __y));
3868 template<class _Expr1, class _Expr2>
3869 inline _LIBCPP_INLINE_VISIBILITY
3872 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3873 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3875 operator+(const _Expr1& __x, const _Expr2& __y)
3877 typedef typename _Expr1::value_type value_type;
3878 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op;
3879 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y));
3882 template<class _Expr>
3883 inline _LIBCPP_INLINE_VISIBILITY
3886 __is_val_expr<_Expr>::value,
3887 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3888 _Expr, __scalar_expr<typename _Expr::value_type> > >
3890 operator+(const _Expr& __x, const typename _Expr::value_type& __y)
3892 typedef typename _Expr::value_type value_type;
3893 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3894 return __val_expr<_Op>(_Op(plus<value_type>(),
3895 __x, __scalar_expr<value_type>(__y, __x.size())));
3898 template<class _Expr>
3899 inline _LIBCPP_INLINE_VISIBILITY
3902 __is_val_expr<_Expr>::value,
3903 __val_expr<_BinaryOp<plus<typename _Expr::value_type>,
3904 __scalar_expr<typename _Expr::value_type>, _Expr> >
3906 operator+(const typename _Expr::value_type& __x, const _Expr& __y)
3908 typedef typename _Expr::value_type value_type;
3909 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3910 return __val_expr<_Op>(_Op(plus<value_type>(),
3911 __scalar_expr<value_type>(__x, __y.size()), __y));
3914 template<class _Expr1, class _Expr2>
3915 inline _LIBCPP_INLINE_VISIBILITY
3918 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3919 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> >
3921 operator-(const _Expr1& __x, const _Expr2& __y)
3923 typedef typename _Expr1::value_type value_type;
3924 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op;
3925 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y));
3928 template<class _Expr>
3929 inline _LIBCPP_INLINE_VISIBILITY
3932 __is_val_expr<_Expr>::value,
3933 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3934 _Expr, __scalar_expr<typename _Expr::value_type> > >
3936 operator-(const _Expr& __x, const typename _Expr::value_type& __y)
3938 typedef typename _Expr::value_type value_type;
3939 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3940 return __val_expr<_Op>(_Op(minus<value_type>(),
3941 __x, __scalar_expr<value_type>(__y, __x.size())));
3944 template<class _Expr>
3945 inline _LIBCPP_INLINE_VISIBILITY
3948 __is_val_expr<_Expr>::value,
3949 __val_expr<_BinaryOp<minus<typename _Expr::value_type>,
3950 __scalar_expr<typename _Expr::value_type>, _Expr> >
3952 operator-(const typename _Expr::value_type& __x, const _Expr& __y)
3954 typedef typename _Expr::value_type value_type;
3955 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
3956 return __val_expr<_Op>(_Op(minus<value_type>(),
3957 __scalar_expr<value_type>(__x, __y.size()), __y));
3960 template<class _Expr1, class _Expr2>
3961 inline _LIBCPP_INLINE_VISIBILITY
3964 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
3965 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> >
3967 operator^(const _Expr1& __x, const _Expr2& __y)
3969 typedef typename _Expr1::value_type value_type;
3970 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op;
3971 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y));
3974 template<class _Expr>
3975 inline _LIBCPP_INLINE_VISIBILITY
3978 __is_val_expr<_Expr>::value,
3979 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3980 _Expr, __scalar_expr<typename _Expr::value_type> > >
3982 operator^(const _Expr& __x, const typename _Expr::value_type& __y)
3984 typedef typename _Expr::value_type value_type;
3985 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
3986 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
3987 __x, __scalar_expr<value_type>(__y, __x.size())));
3990 template<class _Expr>
3991 inline _LIBCPP_INLINE_VISIBILITY
3994 __is_val_expr<_Expr>::value,
3995 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>,
3996 __scalar_expr<typename _Expr::value_type>, _Expr> >
3998 operator^(const typename _Expr::value_type& __x, const _Expr& __y)
4000 typedef typename _Expr::value_type value_type;
4001 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4002 return __val_expr<_Op>(_Op(bit_xor<value_type>(),
4003 __scalar_expr<value_type>(__x, __y.size()), __y));
4006 template<class _Expr1, class _Expr2>
4007 inline _LIBCPP_INLINE_VISIBILITY
4010 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4011 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4013 operator&(const _Expr1& __x, const _Expr2& __y)
4015 typedef typename _Expr1::value_type value_type;
4016 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op;
4017 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y));
4020 template<class _Expr>
4021 inline _LIBCPP_INLINE_VISIBILITY
4024 __is_val_expr<_Expr>::value,
4025 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4026 _Expr, __scalar_expr<typename _Expr::value_type> > >
4028 operator&(const _Expr& __x, const typename _Expr::value_type& __y)
4030 typedef typename _Expr::value_type value_type;
4031 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4032 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4033 __x, __scalar_expr<value_type>(__y, __x.size())));
4036 template<class _Expr>
4037 inline _LIBCPP_INLINE_VISIBILITY
4040 __is_val_expr<_Expr>::value,
4041 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>,
4042 __scalar_expr<typename _Expr::value_type>, _Expr> >
4044 operator&(const typename _Expr::value_type& __x, const _Expr& __y)
4046 typedef typename _Expr::value_type value_type;
4047 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4048 return __val_expr<_Op>(_Op(bit_and<value_type>(),
4049 __scalar_expr<value_type>(__x, __y.size()), __y));
4052 template<class _Expr1, class _Expr2>
4053 inline _LIBCPP_INLINE_VISIBILITY
4056 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4057 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4059 operator|(const _Expr1& __x, const _Expr2& __y)
4061 typedef typename _Expr1::value_type value_type;
4062 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op;
4063 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y));
4066 template<class _Expr>
4067 inline _LIBCPP_INLINE_VISIBILITY
4070 __is_val_expr<_Expr>::value,
4071 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4072 _Expr, __scalar_expr<typename _Expr::value_type> > >
4074 operator|(const _Expr& __x, const typename _Expr::value_type& __y)
4076 typedef typename _Expr::value_type value_type;
4077 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4078 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4079 __x, __scalar_expr<value_type>(__y, __x.size())));
4082 template<class _Expr>
4083 inline _LIBCPP_INLINE_VISIBILITY
4086 __is_val_expr<_Expr>::value,
4087 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>,
4088 __scalar_expr<typename _Expr::value_type>, _Expr> >
4090 operator|(const typename _Expr::value_type& __x, const _Expr& __y)
4092 typedef typename _Expr::value_type value_type;
4093 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4094 return __val_expr<_Op>(_Op(bit_or<value_type>(),
4095 __scalar_expr<value_type>(__x, __y.size()), __y));
4098 template<class _Expr1, class _Expr2>
4099 inline _LIBCPP_INLINE_VISIBILITY
4102 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4103 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> >
4105 operator<<(const _Expr1& __x, const _Expr2& __y)
4107 typedef typename _Expr1::value_type value_type;
4108 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op;
4109 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y));
4112 template<class _Expr>
4113 inline _LIBCPP_INLINE_VISIBILITY
4116 __is_val_expr<_Expr>::value,
4117 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4118 _Expr, __scalar_expr<typename _Expr::value_type> > >
4120 operator<<(const _Expr& __x, const typename _Expr::value_type& __y)
4122 typedef typename _Expr::value_type value_type;
4123 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4124 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4125 __x, __scalar_expr<value_type>(__y, __x.size())));
4128 template<class _Expr>
4129 inline _LIBCPP_INLINE_VISIBILITY
4132 __is_val_expr<_Expr>::value,
4133 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
4134 __scalar_expr<typename _Expr::value_type>, _Expr> >
4136 operator<<(const typename _Expr::value_type& __x, const _Expr& __y)
4138 typedef typename _Expr::value_type value_type;
4139 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4140 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(),
4141 __scalar_expr<value_type>(__x, __y.size()), __y));
4144 template<class _Expr1, class _Expr2>
4145 inline _LIBCPP_INLINE_VISIBILITY
4148 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4149 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> >
4151 operator>>(const _Expr1& __x, const _Expr2& __y)
4153 typedef typename _Expr1::value_type value_type;
4154 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op;
4155 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y));
4158 template<class _Expr>
4159 inline _LIBCPP_INLINE_VISIBILITY
4162 __is_val_expr<_Expr>::value,
4163 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4164 _Expr, __scalar_expr<typename _Expr::value_type> > >
4166 operator>>(const _Expr& __x, const typename _Expr::value_type& __y)
4168 typedef typename _Expr::value_type value_type;
4169 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4170 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4171 __x, __scalar_expr<value_type>(__y, __x.size())));
4174 template<class _Expr>
4175 inline _LIBCPP_INLINE_VISIBILITY
4178 __is_val_expr<_Expr>::value,
4179 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>,
4180 __scalar_expr<typename _Expr::value_type>, _Expr> >
4182 operator>>(const typename _Expr::value_type& __x, const _Expr& __y)
4184 typedef typename _Expr::value_type value_type;
4185 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4186 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(),
4187 __scalar_expr<value_type>(__x, __y.size()), __y));
4190 template<class _Expr1, class _Expr2>
4191 inline _LIBCPP_INLINE_VISIBILITY
4194 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4195 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> >
4197 operator&&(const _Expr1& __x, const _Expr2& __y)
4199 typedef typename _Expr1::value_type value_type;
4200 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op;
4201 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y));
4204 template<class _Expr>
4205 inline _LIBCPP_INLINE_VISIBILITY
4208 __is_val_expr<_Expr>::value,
4209 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4210 _Expr, __scalar_expr<typename _Expr::value_type> > >
4212 operator&&(const _Expr& __x, const typename _Expr::value_type& __y)
4214 typedef typename _Expr::value_type value_type;
4215 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4216 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4217 __x, __scalar_expr<value_type>(__y, __x.size())));
4220 template<class _Expr>
4221 inline _LIBCPP_INLINE_VISIBILITY
4224 __is_val_expr<_Expr>::value,
4225 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>,
4226 __scalar_expr<typename _Expr::value_type>, _Expr> >
4228 operator&&(const typename _Expr::value_type& __x, const _Expr& __y)
4230 typedef typename _Expr::value_type value_type;
4231 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4232 return __val_expr<_Op>(_Op(logical_and<value_type>(),
4233 __scalar_expr<value_type>(__x, __y.size()), __y));
4236 template<class _Expr1, class _Expr2>
4237 inline _LIBCPP_INLINE_VISIBILITY
4240 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4241 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> >
4243 operator||(const _Expr1& __x, const _Expr2& __y)
4245 typedef typename _Expr1::value_type value_type;
4246 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op;
4247 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y));
4250 template<class _Expr>
4251 inline _LIBCPP_INLINE_VISIBILITY
4254 __is_val_expr<_Expr>::value,
4255 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4256 _Expr, __scalar_expr<typename _Expr::value_type> > >
4258 operator||(const _Expr& __x, const typename _Expr::value_type& __y)
4260 typedef typename _Expr::value_type value_type;
4261 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4262 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4263 __x, __scalar_expr<value_type>(__y, __x.size())));
4266 template<class _Expr>
4267 inline _LIBCPP_INLINE_VISIBILITY
4270 __is_val_expr<_Expr>::value,
4271 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>,
4272 __scalar_expr<typename _Expr::value_type>, _Expr> >
4274 operator||(const typename _Expr::value_type& __x, const _Expr& __y)
4276 typedef typename _Expr::value_type value_type;
4277 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4278 return __val_expr<_Op>(_Op(logical_or<value_type>(),
4279 __scalar_expr<value_type>(__x, __y.size()), __y));
4282 template<class _Expr1, class _Expr2>
4283 inline _LIBCPP_INLINE_VISIBILITY
4286 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4287 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4289 operator==(const _Expr1& __x, const _Expr2& __y)
4291 typedef typename _Expr1::value_type value_type;
4292 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op;
4293 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y));
4296 template<class _Expr>
4297 inline _LIBCPP_INLINE_VISIBILITY
4300 __is_val_expr<_Expr>::value,
4301 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4302 _Expr, __scalar_expr<typename _Expr::value_type> > >
4304 operator==(const _Expr& __x, const typename _Expr::value_type& __y)
4306 typedef typename _Expr::value_type value_type;
4307 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4308 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4309 __x, __scalar_expr<value_type>(__y, __x.size())));
4312 template<class _Expr>
4313 inline _LIBCPP_INLINE_VISIBILITY
4316 __is_val_expr<_Expr>::value,
4317 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>,
4318 __scalar_expr<typename _Expr::value_type>, _Expr> >
4320 operator==(const typename _Expr::value_type& __x, const _Expr& __y)
4322 typedef typename _Expr::value_type value_type;
4323 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4324 return __val_expr<_Op>(_Op(equal_to<value_type>(),
4325 __scalar_expr<value_type>(__x, __y.size()), __y));
4328 template<class _Expr1, class _Expr2>
4329 inline _LIBCPP_INLINE_VISIBILITY
4332 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4333 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> >
4335 operator!=(const _Expr1& __x, const _Expr2& __y)
4337 typedef typename _Expr1::value_type value_type;
4338 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op;
4339 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y));
4342 template<class _Expr>
4343 inline _LIBCPP_INLINE_VISIBILITY
4346 __is_val_expr<_Expr>::value,
4347 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4348 _Expr, __scalar_expr<typename _Expr::value_type> > >
4350 operator!=(const _Expr& __x, const typename _Expr::value_type& __y)
4352 typedef typename _Expr::value_type value_type;
4353 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4354 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4355 __x, __scalar_expr<value_type>(__y, __x.size())));
4358 template<class _Expr>
4359 inline _LIBCPP_INLINE_VISIBILITY
4362 __is_val_expr<_Expr>::value,
4363 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>,
4364 __scalar_expr<typename _Expr::value_type>, _Expr> >
4366 operator!=(const typename _Expr::value_type& __x, const _Expr& __y)
4368 typedef typename _Expr::value_type value_type;
4369 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4370 return __val_expr<_Op>(_Op(not_equal_to<value_type>(),
4371 __scalar_expr<value_type>(__x, __y.size()), __y));
4374 template<class _Expr1, class _Expr2>
4375 inline _LIBCPP_INLINE_VISIBILITY
4378 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4379 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> >
4381 operator<(const _Expr1& __x, const _Expr2& __y)
4383 typedef typename _Expr1::value_type value_type;
4384 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op;
4385 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y));
4388 template<class _Expr>
4389 inline _LIBCPP_INLINE_VISIBILITY
4392 __is_val_expr<_Expr>::value,
4393 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4394 _Expr, __scalar_expr<typename _Expr::value_type> > >
4396 operator<(const _Expr& __x, const typename _Expr::value_type& __y)
4398 typedef typename _Expr::value_type value_type;
4399 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4400 return __val_expr<_Op>(_Op(less<value_type>(),
4401 __x, __scalar_expr<value_type>(__y, __x.size())));
4404 template<class _Expr>
4405 inline _LIBCPP_INLINE_VISIBILITY
4408 __is_val_expr<_Expr>::value,
4409 __val_expr<_BinaryOp<less<typename _Expr::value_type>,
4410 __scalar_expr<typename _Expr::value_type>, _Expr> >
4412 operator<(const typename _Expr::value_type& __x, const _Expr& __y)
4414 typedef typename _Expr::value_type value_type;
4415 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4416 return __val_expr<_Op>(_Op(less<value_type>(),
4417 __scalar_expr<value_type>(__x, __y.size()), __y));
4420 template<class _Expr1, class _Expr2>
4421 inline _LIBCPP_INLINE_VISIBILITY
4424 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4425 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> >
4427 operator>(const _Expr1& __x, const _Expr2& __y)
4429 typedef typename _Expr1::value_type value_type;
4430 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op;
4431 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y));
4434 template<class _Expr>
4435 inline _LIBCPP_INLINE_VISIBILITY
4438 __is_val_expr<_Expr>::value,
4439 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4440 _Expr, __scalar_expr<typename _Expr::value_type> > >
4442 operator>(const _Expr& __x, const typename _Expr::value_type& __y)
4444 typedef typename _Expr::value_type value_type;
4445 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4446 return __val_expr<_Op>(_Op(greater<value_type>(),
4447 __x, __scalar_expr<value_type>(__y, __x.size())));
4450 template<class _Expr>
4451 inline _LIBCPP_INLINE_VISIBILITY
4454 __is_val_expr<_Expr>::value,
4455 __val_expr<_BinaryOp<greater<typename _Expr::value_type>,
4456 __scalar_expr<typename _Expr::value_type>, _Expr> >
4458 operator>(const typename _Expr::value_type& __x, const _Expr& __y)
4460 typedef typename _Expr::value_type value_type;
4461 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4462 return __val_expr<_Op>(_Op(greater<value_type>(),
4463 __scalar_expr<value_type>(__x, __y.size()), __y));
4466 template<class _Expr1, class _Expr2>
4467 inline _LIBCPP_INLINE_VISIBILITY
4470 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4471 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4473 operator<=(const _Expr1& __x, const _Expr2& __y)
4475 typedef typename _Expr1::value_type value_type;
4476 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op;
4477 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y));
4480 template<class _Expr>
4481 inline _LIBCPP_INLINE_VISIBILITY
4484 __is_val_expr<_Expr>::value,
4485 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4486 _Expr, __scalar_expr<typename _Expr::value_type> > >
4488 operator<=(const _Expr& __x, const typename _Expr::value_type& __y)
4490 typedef typename _Expr::value_type value_type;
4491 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4492 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4493 __x, __scalar_expr<value_type>(__y, __x.size())));
4496 template<class _Expr>
4497 inline _LIBCPP_INLINE_VISIBILITY
4500 __is_val_expr<_Expr>::value,
4501 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>,
4502 __scalar_expr<typename _Expr::value_type>, _Expr> >
4504 operator<=(const typename _Expr::value_type& __x, const _Expr& __y)
4506 typedef typename _Expr::value_type value_type;
4507 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4508 return __val_expr<_Op>(_Op(less_equal<value_type>(),
4509 __scalar_expr<value_type>(__x, __y.size()), __y));
4512 template<class _Expr1, class _Expr2>
4513 inline _LIBCPP_INLINE_VISIBILITY
4516 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4517 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> >
4519 operator>=(const _Expr1& __x, const _Expr2& __y)
4521 typedef typename _Expr1::value_type value_type;
4522 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op;
4523 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y));
4526 template<class _Expr>
4527 inline _LIBCPP_INLINE_VISIBILITY
4530 __is_val_expr<_Expr>::value,
4531 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4532 _Expr, __scalar_expr<typename _Expr::value_type> > >
4534 operator>=(const _Expr& __x, const typename _Expr::value_type& __y)
4536 typedef typename _Expr::value_type value_type;
4537 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4538 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4539 __x, __scalar_expr<value_type>(__y, __x.size())));
4542 template<class _Expr>
4543 inline _LIBCPP_INLINE_VISIBILITY
4546 __is_val_expr<_Expr>::value,
4547 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>,
4548 __scalar_expr<typename _Expr::value_type>, _Expr> >
4550 operator>=(const typename _Expr::value_type& __x, const _Expr& __y)
4552 typedef typename _Expr::value_type value_type;
4553 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4554 return __val_expr<_Op>(_Op(greater_equal<value_type>(),
4555 __scalar_expr<value_type>(__x, __y.size()), __y));
4558 template<class _Expr>
4559 inline _LIBCPP_INLINE_VISIBILITY
4562 __is_val_expr<_Expr>::value,
4563 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> >
4565 abs(const _Expr& __x)
4567 typedef typename _Expr::value_type value_type;
4568 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op;
4569 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x));
4572 template<class _Expr>
4573 inline _LIBCPP_INLINE_VISIBILITY
4576 __is_val_expr<_Expr>::value,
4577 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> >
4579 acos(const _Expr& __x)
4581 typedef typename _Expr::value_type value_type;
4582 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op;
4583 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x));
4586 template<class _Expr>
4587 inline _LIBCPP_INLINE_VISIBILITY
4590 __is_val_expr<_Expr>::value,
4591 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> >
4593 asin(const _Expr& __x)
4595 typedef typename _Expr::value_type value_type;
4596 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op;
4597 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x));
4600 template<class _Expr>
4601 inline _LIBCPP_INLINE_VISIBILITY
4604 __is_val_expr<_Expr>::value,
4605 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> >
4607 atan(const _Expr& __x)
4609 typedef typename _Expr::value_type value_type;
4610 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op;
4611 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x));
4614 template<class _Expr1, class _Expr2>
4615 inline _LIBCPP_INLINE_VISIBILITY
4618 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4619 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4621 atan2(const _Expr1& __x, const _Expr2& __y)
4623 typedef typename _Expr1::value_type value_type;
4624 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op;
4625 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y));
4628 template<class _Expr>
4629 inline _LIBCPP_INLINE_VISIBILITY
4632 __is_val_expr<_Expr>::value,
4633 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4634 _Expr, __scalar_expr<typename _Expr::value_type> > >
4636 atan2(const _Expr& __x, const typename _Expr::value_type& __y)
4638 typedef typename _Expr::value_type value_type;
4639 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4640 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4641 __x, __scalar_expr<value_type>(__y, __x.size())));
4644 template<class _Expr>
4645 inline _LIBCPP_INLINE_VISIBILITY
4648 __is_val_expr<_Expr>::value,
4649 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>,
4650 __scalar_expr<typename _Expr::value_type>, _Expr> >
4652 atan2(const typename _Expr::value_type& __x, const _Expr& __y)
4654 typedef typename _Expr::value_type value_type;
4655 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4656 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(),
4657 __scalar_expr<value_type>(__x, __y.size()), __y));
4660 template<class _Expr>
4661 inline _LIBCPP_INLINE_VISIBILITY
4664 __is_val_expr<_Expr>::value,
4665 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> >
4667 cos(const _Expr& __x)
4669 typedef typename _Expr::value_type value_type;
4670 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op;
4671 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x));
4674 template<class _Expr>
4675 inline _LIBCPP_INLINE_VISIBILITY
4678 __is_val_expr<_Expr>::value,
4679 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> >
4681 cosh(const _Expr& __x)
4683 typedef typename _Expr::value_type value_type;
4684 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op;
4685 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x));
4688 template<class _Expr>
4689 inline _LIBCPP_INLINE_VISIBILITY
4692 __is_val_expr<_Expr>::value,
4693 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> >
4695 exp(const _Expr& __x)
4697 typedef typename _Expr::value_type value_type;
4698 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op;
4699 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x));
4702 template<class _Expr>
4703 inline _LIBCPP_INLINE_VISIBILITY
4706 __is_val_expr<_Expr>::value,
4707 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> >
4709 log(const _Expr& __x)
4711 typedef typename _Expr::value_type value_type;
4712 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op;
4713 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x));
4716 template<class _Expr>
4717 inline _LIBCPP_INLINE_VISIBILITY
4720 __is_val_expr<_Expr>::value,
4721 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> >
4723 log10(const _Expr& __x)
4725 typedef typename _Expr::value_type value_type;
4726 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op;
4727 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x));
4730 template<class _Expr1, class _Expr2>
4731 inline _LIBCPP_INLINE_VISIBILITY
4734 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value,
4735 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> >
4737 pow(const _Expr1& __x, const _Expr2& __y)
4739 typedef typename _Expr1::value_type value_type;
4740 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op;
4741 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y));
4744 template<class _Expr>
4745 inline _LIBCPP_INLINE_VISIBILITY
4748 __is_val_expr<_Expr>::value,
4749 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4750 _Expr, __scalar_expr<typename _Expr::value_type> > >
4752 pow(const _Expr& __x, const typename _Expr::value_type& __y)
4754 typedef typename _Expr::value_type value_type;
4755 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
4756 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4757 __x, __scalar_expr<value_type>(__y, __x.size())));
4760 template<class _Expr>
4761 inline _LIBCPP_INLINE_VISIBILITY
4764 __is_val_expr<_Expr>::value,
4765 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>,
4766 __scalar_expr<typename _Expr::value_type>, _Expr> >
4768 pow(const typename _Expr::value_type& __x, const _Expr& __y)
4770 typedef typename _Expr::value_type value_type;
4771 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
4772 return __val_expr<_Op>(_Op(__pow_expr<value_type>(),
4773 __scalar_expr<value_type>(__x, __y.size()), __y));
4776 template<class _Expr>
4777 inline _LIBCPP_INLINE_VISIBILITY
4780 __is_val_expr<_Expr>::value,
4781 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> >
4783 sin(const _Expr& __x)
4785 typedef typename _Expr::value_type value_type;
4786 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op;
4787 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x));
4790 template<class _Expr>
4791 inline _LIBCPP_INLINE_VISIBILITY
4794 __is_val_expr<_Expr>::value,
4795 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> >
4797 sinh(const _Expr& __x)
4799 typedef typename _Expr::value_type value_type;
4800 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op;
4801 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x));
4804 template<class _Expr>
4805 inline _LIBCPP_INLINE_VISIBILITY
4808 __is_val_expr<_Expr>::value,
4809 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> >
4811 sqrt(const _Expr& __x)
4813 typedef typename _Expr::value_type value_type;
4814 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op;
4815 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x));
4818 template<class _Expr>
4819 inline _LIBCPP_INLINE_VISIBILITY
4822 __is_val_expr<_Expr>::value,
4823 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> >
4825 tan(const _Expr& __x)
4827 typedef typename _Expr::value_type value_type;
4828 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op;
4829 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x));
4832 template<class _Expr>
4833 inline _LIBCPP_INLINE_VISIBILITY
4836 __is_val_expr<_Expr>::value,
4837 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> >
4839 tanh(const _Expr& __x)
4841 typedef typename _Expr::value_type value_type;
4842 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op;
4843 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x));
4846 template <class _Tp>
4847 inline _LIBCPP_INLINE_VISIBILITY
4849 begin(valarray<_Tp>& __v)
4851 return __v.__begin_;
4854 template <class _Tp>
4855 inline _LIBCPP_INLINE_VISIBILITY
4857 begin(const valarray<_Tp>& __v)
4859 return __v.__begin_;
4862 template <class _Tp>
4863 inline _LIBCPP_INLINE_VISIBILITY
4865 end(valarray<_Tp>& __v)
4870 template <class _Tp>
4871 inline _LIBCPP_INLINE_VISIBILITY
4873 end(const valarray<_Tp>& __v)
4878 _LIBCPP_END_NAMESPACE_STD
4880 #endif // _LIBCPP_VALARRAY