1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_VALARRAY 11#define _LIBCPP_VALARRAY 12 13/* 14 valarray synopsis 15 16namespace std 17{ 18 19template<class T> 20class valarray 21{ 22public: 23 typedef T value_type; 24 25 // construct/destroy: 26 valarray(); 27 explicit valarray(size_t n); 28 valarray(const value_type& x, size_t n); 29 valarray(const value_type* px, size_t n); 30 valarray(const valarray& v); 31 valarray(valarray&& v) noexcept; 32 valarray(const slice_array<value_type>& sa); 33 valarray(const gslice_array<value_type>& ga); 34 valarray(const mask_array<value_type>& ma); 35 valarray(const indirect_array<value_type>& ia); 36 valarray(initializer_list<value_type> il); 37 ~valarray(); 38 39 // assignment: 40 valarray& operator=(const valarray& v); 41 valarray& operator=(valarray&& v) noexcept; 42 valarray& operator=(initializer_list<value_type> il); 43 valarray& operator=(const value_type& x); 44 valarray& operator=(const slice_array<value_type>& sa); 45 valarray& operator=(const gslice_array<value_type>& ga); 46 valarray& operator=(const mask_array<value_type>& ma); 47 valarray& operator=(const indirect_array<value_type>& ia); 48 49 // element access: 50 const value_type& operator[](size_t i) const; 51 value_type& operator[](size_t i); 52 53 // subset operations: 54 valarray operator[](slice s) const; 55 slice_array<value_type> operator[](slice s); 56 valarray operator[](const gslice& gs) const; 57 gslice_array<value_type> operator[](const gslice& gs); 58 valarray operator[](const valarray<bool>& vb) const; 59 mask_array<value_type> operator[](const valarray<bool>& vb); 60 valarray operator[](const valarray<size_t>& vs) const; 61 indirect_array<value_type> operator[](const valarray<size_t>& vs); 62 63 // unary operators: 64 valarray operator+() const; 65 valarray operator-() const; 66 valarray operator~() const; 67 valarray<bool> operator!() const; 68 69 // computed assignment: 70 valarray& operator*= (const value_type& x); 71 valarray& operator/= (const value_type& x); 72 valarray& operator%= (const value_type& x); 73 valarray& operator+= (const value_type& x); 74 valarray& operator-= (const value_type& x); 75 valarray& operator^= (const value_type& x); 76 valarray& operator&= (const value_type& x); 77 valarray& operator|= (const value_type& x); 78 valarray& operator<<=(const value_type& x); 79 valarray& operator>>=(const value_type& x); 80 81 valarray& operator*= (const valarray& v); 82 valarray& operator/= (const valarray& v); 83 valarray& operator%= (const valarray& v); 84 valarray& operator+= (const valarray& v); 85 valarray& operator-= (const valarray& v); 86 valarray& operator^= (const valarray& v); 87 valarray& operator|= (const valarray& v); 88 valarray& operator&= (const valarray& v); 89 valarray& operator<<=(const valarray& v); 90 valarray& operator>>=(const valarray& v); 91 92 // member functions: 93 void swap(valarray& v) noexcept; 94 95 size_t size() const; 96 97 value_type sum() const; 98 value_type min() const; 99 value_type max() const; 100 101 valarray shift (int i) const; 102 valarray cshift(int i) const; 103 valarray apply(value_type f(value_type)) const; 104 valarray apply(value_type f(const value_type&)) const; 105 void resize(size_t n, value_type x = value_type()); 106}; 107 108template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; 109 110class slice 111{ 112public: 113 slice(); 114 slice(size_t start, size_t size, size_t stride); 115 116 size_t start() const; 117 size_t size() const; 118 size_t stride() const; 119}; 120 121template <class T> 122class slice_array 123{ 124public: 125 typedef T value_type; 126 127 const slice_array& operator=(const slice_array& sa) const; 128 void operator= (const valarray<value_type>& v) const; 129 void operator*= (const valarray<value_type>& v) const; 130 void operator/= (const valarray<value_type>& v) const; 131 void operator%= (const valarray<value_type>& v) const; 132 void operator+= (const valarray<value_type>& v) const; 133 void operator-= (const valarray<value_type>& v) const; 134 void operator^= (const valarray<value_type>& v) const; 135 void operator&= (const valarray<value_type>& v) const; 136 void operator|= (const valarray<value_type>& v) const; 137 void operator<<=(const valarray<value_type>& v) const; 138 void operator>>=(const valarray<value_type>& v) const; 139 140 void operator=(const value_type& x) const; 141 void operator=(const valarray<T>& val_arr) const; 142 143 slice_array() = delete; 144}; 145 146class gslice 147{ 148public: 149 gslice(); 150 gslice(size_t start, const valarray<size_t>& size, 151 const valarray<size_t>& stride); 152 153 size_t start() const; 154 valarray<size_t> size() const; 155 valarray<size_t> stride() const; 156}; 157 158template <class T> 159class gslice_array 160{ 161public: 162 typedef T value_type; 163 164 void operator= (const valarray<value_type>& v) const; 165 void operator*= (const valarray<value_type>& v) const; 166 void operator/= (const valarray<value_type>& v) const; 167 void operator%= (const valarray<value_type>& v) const; 168 void operator+= (const valarray<value_type>& v) const; 169 void operator-= (const valarray<value_type>& v) const; 170 void operator^= (const valarray<value_type>& v) const; 171 void operator&= (const valarray<value_type>& v) const; 172 void operator|= (const valarray<value_type>& v) const; 173 void operator<<=(const valarray<value_type>& v) const; 174 void operator>>=(const valarray<value_type>& v) const; 175 176 gslice_array(const gslice_array& ga); 177 ~gslice_array(); 178 const gslice_array& operator=(const gslice_array& ga) const; 179 void operator=(const value_type& x) const; 180 181 gslice_array() = delete; 182}; 183 184template <class T> 185class mask_array 186{ 187public: 188 typedef T value_type; 189 190 void operator= (const valarray<value_type>& v) const; 191 void operator*= (const valarray<value_type>& v) const; 192 void operator/= (const valarray<value_type>& v) const; 193 void operator%= (const valarray<value_type>& v) const; 194 void operator+= (const valarray<value_type>& v) const; 195 void operator-= (const valarray<value_type>& v) const; 196 void operator^= (const valarray<value_type>& v) const; 197 void operator&= (const valarray<value_type>& v) const; 198 void operator|= (const valarray<value_type>& v) const; 199 void operator<<=(const valarray<value_type>& v) const; 200 void operator>>=(const valarray<value_type>& v) const; 201 202 mask_array(const mask_array& ma); 203 ~mask_array(); 204 const mask_array& operator=(const mask_array& ma) const; 205 void operator=(const value_type& x) const; 206 207 mask_array() = delete; 208}; 209 210template <class T> 211class indirect_array 212{ 213public: 214 typedef T value_type; 215 216 void operator= (const valarray<value_type>& v) const; 217 void operator*= (const valarray<value_type>& v) const; 218 void operator/= (const valarray<value_type>& v) const; 219 void operator%= (const valarray<value_type>& v) const; 220 void operator+= (const valarray<value_type>& v) const; 221 void operator-= (const valarray<value_type>& v) const; 222 void operator^= (const valarray<value_type>& v) const; 223 void operator&= (const valarray<value_type>& v) const; 224 void operator|= (const valarray<value_type>& v) const; 225 void operator<<=(const valarray<value_type>& v) const; 226 void operator>>=(const valarray<value_type>& v) const; 227 228 indirect_array(const indirect_array& ia); 229 ~indirect_array(); 230 const indirect_array& operator=(const indirect_array& ia) const; 231 void operator=(const value_type& x) const; 232 233 indirect_array() = delete; 234}; 235 236template<class T> void swap(valarray<T>& x, valarray<T>& y) noexcept; 237 238template<class T> valarray<T> operator* (const valarray<T>& x, const valarray<T>& y); 239template<class T> valarray<T> operator* (const valarray<T>& x, const T& y); 240template<class T> valarray<T> operator* (const T& x, const valarray<T>& y); 241 242template<class T> valarray<T> operator/ (const valarray<T>& x, const valarray<T>& y); 243template<class T> valarray<T> operator/ (const valarray<T>& x, const T& y); 244template<class T> valarray<T> operator/ (const T& x, const valarray<T>& y); 245 246template<class T> valarray<T> operator% (const valarray<T>& x, const valarray<T>& y); 247template<class T> valarray<T> operator% (const valarray<T>& x, const T& y); 248template<class T> valarray<T> operator% (const T& x, const valarray<T>& y); 249 250template<class T> valarray<T> operator+ (const valarray<T>& x, const valarray<T>& y); 251template<class T> valarray<T> operator+ (const valarray<T>& x, const T& y); 252template<class T> valarray<T> operator+ (const T& x, const valarray<T>& y); 253 254template<class T> valarray<T> operator- (const valarray<T>& x, const valarray<T>& y); 255template<class T> valarray<T> operator- (const valarray<T>& x, const T& y); 256template<class T> valarray<T> operator- (const T& x, const valarray<T>& y); 257 258template<class T> valarray<T> operator^ (const valarray<T>& x, const valarray<T>& y); 259template<class T> valarray<T> operator^ (const valarray<T>& x, const T& y); 260template<class T> valarray<T> operator^ (const T& x, const valarray<T>& y); 261 262template<class T> valarray<T> operator& (const valarray<T>& x, const valarray<T>& y); 263template<class T> valarray<T> operator& (const valarray<T>& x, const T& y); 264template<class T> valarray<T> operator& (const T& x, const valarray<T>& y); 265 266template<class T> valarray<T> operator| (const valarray<T>& x, const valarray<T>& y); 267template<class T> valarray<T> operator| (const valarray<T>& x, const T& y); 268template<class T> valarray<T> operator| (const T& x, const valarray<T>& y); 269 270template<class T> valarray<T> operator<<(const valarray<T>& x, const valarray<T>& y); 271template<class T> valarray<T> operator<<(const valarray<T>& x, const T& y); 272template<class T> valarray<T> operator<<(const T& x, const valarray<T>& y); 273 274template<class T> valarray<T> operator>>(const valarray<T>& x, const valarray<T>& y); 275template<class T> valarray<T> operator>>(const valarray<T>& x, const T& y); 276template<class T> valarray<T> operator>>(const T& x, const valarray<T>& y); 277 278template<class T> valarray<bool> operator&&(const valarray<T>& x, const valarray<T>& y); 279template<class T> valarray<bool> operator&&(const valarray<T>& x, const T& y); 280template<class T> valarray<bool> operator&&(const T& x, const valarray<T>& y); 281 282template<class T> valarray<bool> operator||(const valarray<T>& x, const valarray<T>& y); 283template<class T> valarray<bool> operator||(const valarray<T>& x, const T& y); 284template<class T> valarray<bool> operator||(const T& x, const valarray<T>& y); 285 286template<class T> valarray<bool> operator==(const valarray<T>& x, const valarray<T>& y); 287template<class T> valarray<bool> operator==(const valarray<T>& x, const T& y); 288template<class T> valarray<bool> operator==(const T& x, const valarray<T>& y); 289 290template<class T> valarray<bool> operator!=(const valarray<T>& x, const valarray<T>& y); 291template<class T> valarray<bool> operator!=(const valarray<T>& x, const T& y); 292template<class T> valarray<bool> operator!=(const T& x, const valarray<T>& y); 293 294template<class T> valarray<bool> operator< (const valarray<T>& x, const valarray<T>& y); 295template<class T> valarray<bool> operator< (const valarray<T>& x, const T& y); 296template<class T> valarray<bool> operator< (const T& x, const valarray<T>& y); 297 298template<class T> valarray<bool> operator> (const valarray<T>& x, const valarray<T>& y); 299template<class T> valarray<bool> operator> (const valarray<T>& x, const T& y); 300template<class T> valarray<bool> operator> (const T& x, const valarray<T>& y); 301 302template<class T> valarray<bool> operator<=(const valarray<T>& x, const valarray<T>& y); 303template<class T> valarray<bool> operator<=(const valarray<T>& x, const T& y); 304template<class T> valarray<bool> operator<=(const T& x, const valarray<T>& y); 305 306template<class T> valarray<bool> operator>=(const valarray<T>& x, const valarray<T>& y); 307template<class T> valarray<bool> operator>=(const valarray<T>& x, const T& y); 308template<class T> valarray<bool> operator>=(const T& x, const valarray<T>& y); 309 310template<class T> valarray<T> abs (const valarray<T>& x); 311template<class T> valarray<T> acos (const valarray<T>& x); 312template<class T> valarray<T> asin (const valarray<T>& x); 313template<class T> valarray<T> atan (const valarray<T>& x); 314 315template<class T> valarray<T> atan2(const valarray<T>& x, const valarray<T>& y); 316template<class T> valarray<T> atan2(const valarray<T>& x, const T& y); 317template<class T> valarray<T> atan2(const T& x, const valarray<T>& y); 318 319template<class T> valarray<T> cos (const valarray<T>& x); 320template<class T> valarray<T> cosh (const valarray<T>& x); 321template<class T> valarray<T> exp (const valarray<T>& x); 322template<class T> valarray<T> log (const valarray<T>& x); 323template<class T> valarray<T> log10(const valarray<T>& x); 324 325template<class T> valarray<T> pow(const valarray<T>& x, const valarray<T>& y); 326template<class T> valarray<T> pow(const valarray<T>& x, const T& y); 327template<class T> valarray<T> pow(const T& x, const valarray<T>& y); 328 329template<class T> valarray<T> sin (const valarray<T>& x); 330template<class T> valarray<T> sinh (const valarray<T>& x); 331template<class T> valarray<T> sqrt (const valarray<T>& x); 332template<class T> valarray<T> tan (const valarray<T>& x); 333template<class T> valarray<T> tanh (const valarray<T>& x); 334 335template <class T> unspecified1 begin(valarray<T>& v); 336template <class T> unspecified2 begin(const valarray<T>& v); 337template <class T> unspecified1 end(valarray<T>& v); 338template <class T> unspecified2 end(const valarray<T>& v); 339 340} // std 341 342*/ 343 344#include <__config> 345#include <algorithm> 346#include <cmath> 347#include <cstddef> 348#include <functional> 349#include <initializer_list> 350#include <new> 351 352#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 353#pragma GCC system_header 354#endif 355 356_LIBCPP_PUSH_MACROS 357#include <__undef_macros> 358 359_LIBCPP_BEGIN_NAMESPACE_STD 360 361template<class _Tp> class _LIBCPP_TEMPLATE_VIS valarray; 362 363class _LIBCPP_TEMPLATE_VIS slice 364{ 365 size_t __start_; 366 size_t __size_; 367 size_t __stride_; 368public: 369 _LIBCPP_INLINE_VISIBILITY 370 slice() 371 : __start_(0), 372 __size_(0), 373 __stride_(0) 374 {} 375 376 _LIBCPP_INLINE_VISIBILITY 377 slice(size_t __start, size_t __size, size_t __stride) 378 : __start_(__start), 379 __size_(__size), 380 __stride_(__stride) 381 {} 382 383 _LIBCPP_INLINE_VISIBILITY size_t start() const {return __start_;} 384 _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} 385 _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} 386}; 387 388template <class _Tp> class _LIBCPP_TEMPLATE_VIS slice_array; 389class _LIBCPP_TYPE_VIS gslice; 390template <class _Tp> class _LIBCPP_TEMPLATE_VIS gslice_array; 391template <class _Tp> class _LIBCPP_TEMPLATE_VIS mask_array; 392template <class _Tp> class _LIBCPP_TEMPLATE_VIS indirect_array; 393 394template <class _Tp> 395_LIBCPP_INLINE_VISIBILITY 396_Tp* 397begin(valarray<_Tp>& __v); 398 399template <class _Tp> 400_LIBCPP_INLINE_VISIBILITY 401const _Tp* 402begin(const valarray<_Tp>& __v); 403 404template <class _Tp> 405_LIBCPP_INLINE_VISIBILITY 406_Tp* 407end(valarray<_Tp>& __v); 408 409template <class _Tp> 410_LIBCPP_INLINE_VISIBILITY 411const _Tp* 412end(const valarray<_Tp>& __v); 413 414template <class _Op, class _A0> 415struct _UnaryOp 416{ 417 typedef typename _Op::__result_type __result_type; 418 typedef typename decay<__result_type>::type value_type; 419 420 _Op __op_; 421 _A0 __a0_; 422 423 _LIBCPP_INLINE_VISIBILITY 424 _UnaryOp(const _Op& __op, const _A0& __a0) : __op_(__op), __a0_(__a0) {} 425 426 _LIBCPP_INLINE_VISIBILITY 427 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} 428 429 _LIBCPP_INLINE_VISIBILITY 430 size_t size() const {return __a0_.size();} 431}; 432 433template <class _Op, class _A0, class _A1> 434struct _BinaryOp 435{ 436 typedef typename _Op::__result_type __result_type; 437 typedef typename decay<__result_type>::type value_type; 438 439 _Op __op_; 440 _A0 __a0_; 441 _A1 __a1_; 442 443 _LIBCPP_INLINE_VISIBILITY 444 _BinaryOp(const _Op& __op, const _A0& __a0, const _A1& __a1) 445 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 446 447 _LIBCPP_INLINE_VISIBILITY 448 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 449 450 _LIBCPP_INLINE_VISIBILITY 451 size_t size() const {return __a0_.size();} 452}; 453 454template <class _Tp> 455class __scalar_expr 456{ 457public: 458 typedef _Tp value_type; 459 typedef const _Tp& __result_type; 460private: 461 const value_type& __t_; 462 size_t __s_; 463public: 464 _LIBCPP_INLINE_VISIBILITY 465 explicit __scalar_expr(const value_type& __t, size_t __s) : __t_(__t), __s_(__s) {} 466 467 _LIBCPP_INLINE_VISIBILITY 468 __result_type operator[](size_t) const {return __t_;} 469 470 _LIBCPP_INLINE_VISIBILITY 471 size_t size() const {return __s_;} 472}; 473 474template <class _Tp> 475struct __unary_plus 476{ 477 typedef _Tp __result_type; 478 _LIBCPP_INLINE_VISIBILITY 479 _Tp operator()(const _Tp& __x) const 480 {return +__x;} 481}; 482 483template <class _Tp> 484struct __bit_not 485{ 486 typedef _Tp __result_type; 487 _LIBCPP_INLINE_VISIBILITY 488 _Tp operator()(const _Tp& __x) const 489 {return ~__x;} 490}; 491 492template <class _Tp> 493struct __bit_shift_left 494{ 495 typedef _Tp __result_type; 496 _LIBCPP_INLINE_VISIBILITY 497 _Tp operator()(const _Tp& __x, const _Tp& __y) const 498 {return __x << __y;} 499}; 500 501template <class _Tp> 502struct __bit_shift_right 503{ 504 typedef _Tp __result_type; 505 _LIBCPP_INLINE_VISIBILITY 506 _Tp operator()(const _Tp& __x, const _Tp& __y) const 507 {return __x >> __y;} 508}; 509 510template <class _Tp, class _Fp> 511struct __apply_expr 512{ 513private: 514 _Fp __f_; 515public: 516 typedef _Tp __result_type; 517 518 _LIBCPP_INLINE_VISIBILITY 519 explicit __apply_expr(_Fp __f) : __f_(__f) {} 520 521 _LIBCPP_INLINE_VISIBILITY 522 _Tp operator()(const _Tp& __x) const 523 {return __f_(__x);} 524}; 525 526template <class _Tp> 527struct __abs_expr 528{ 529 typedef _Tp __result_type; 530 _LIBCPP_INLINE_VISIBILITY 531 _Tp operator()(const _Tp& __x) const 532 {return abs(__x);} 533}; 534 535template <class _Tp> 536struct __acos_expr 537{ 538 typedef _Tp __result_type; 539 _LIBCPP_INLINE_VISIBILITY 540 _Tp operator()(const _Tp& __x) const 541 {return acos(__x);} 542}; 543 544template <class _Tp> 545struct __asin_expr 546{ 547 typedef _Tp __result_type; 548 _LIBCPP_INLINE_VISIBILITY 549 _Tp operator()(const _Tp& __x) const 550 {return asin(__x);} 551}; 552 553template <class _Tp> 554struct __atan_expr 555{ 556 typedef _Tp __result_type; 557 _LIBCPP_INLINE_VISIBILITY 558 _Tp operator()(const _Tp& __x) const 559 {return atan(__x);} 560}; 561 562template <class _Tp> 563struct __atan2_expr 564{ 565 typedef _Tp __result_type; 566 _LIBCPP_INLINE_VISIBILITY 567 _Tp operator()(const _Tp& __x, const _Tp& __y) const 568 {return atan2(__x, __y);} 569}; 570 571template <class _Tp> 572struct __cos_expr 573{ 574 typedef _Tp __result_type; 575 _LIBCPP_INLINE_VISIBILITY 576 _Tp operator()(const _Tp& __x) const 577 {return cos(__x);} 578}; 579 580template <class _Tp> 581struct __cosh_expr 582{ 583 typedef _Tp __result_type; 584 _LIBCPP_INLINE_VISIBILITY 585 _Tp operator()(const _Tp& __x) const 586 {return cosh(__x);} 587}; 588 589template <class _Tp> 590struct __exp_expr 591{ 592 typedef _Tp __result_type; 593 _LIBCPP_INLINE_VISIBILITY 594 _Tp operator()(const _Tp& __x) const 595 {return exp(__x);} 596}; 597 598template <class _Tp> 599struct __log_expr 600{ 601 typedef _Tp __result_type; 602 _LIBCPP_INLINE_VISIBILITY 603 _Tp operator()(const _Tp& __x) const 604 {return log(__x);} 605}; 606 607template <class _Tp> 608struct __log10_expr 609{ 610 typedef _Tp __result_type; 611 _LIBCPP_INLINE_VISIBILITY 612 _Tp operator()(const _Tp& __x) const 613 {return log10(__x);} 614}; 615 616template <class _Tp> 617struct __pow_expr 618{ 619 typedef _Tp __result_type; 620 _LIBCPP_INLINE_VISIBILITY 621 _Tp operator()(const _Tp& __x, const _Tp& __y) const 622 {return pow(__x, __y);} 623}; 624 625template <class _Tp> 626struct __sin_expr 627{ 628 typedef _Tp __result_type; 629 _LIBCPP_INLINE_VISIBILITY 630 _Tp operator()(const _Tp& __x) const 631 {return sin(__x);} 632}; 633 634template <class _Tp> 635struct __sinh_expr 636{ 637 typedef _Tp __result_type; 638 _LIBCPP_INLINE_VISIBILITY 639 _Tp operator()(const _Tp& __x) const 640 {return sinh(__x);} 641}; 642 643template <class _Tp> 644struct __sqrt_expr 645{ 646 typedef _Tp __result_type; 647 _LIBCPP_INLINE_VISIBILITY 648 _Tp operator()(const _Tp& __x) const 649 {return sqrt(__x);} 650}; 651 652template <class _Tp> 653struct __tan_expr 654{ 655 typedef _Tp __result_type; 656 _LIBCPP_INLINE_VISIBILITY 657 _Tp operator()(const _Tp& __x) const 658 {return tan(__x);} 659}; 660 661template <class _Tp> 662struct __tanh_expr 663{ 664 typedef _Tp __result_type; 665 _LIBCPP_INLINE_VISIBILITY 666 _Tp operator()(const _Tp& __x) const 667 {return tanh(__x);} 668}; 669 670template <class _ValExpr> 671class __slice_expr 672{ 673 typedef typename remove_reference<_ValExpr>::type _RmExpr; 674public: 675 typedef typename _RmExpr::value_type value_type; 676 typedef value_type __result_type; 677 678private: 679 _ValExpr __expr_; 680 size_t __start_; 681 size_t __size_; 682 size_t __stride_; 683 684 _LIBCPP_INLINE_VISIBILITY 685 __slice_expr(const slice& __sl, const _RmExpr& __e) 686 : __expr_(__e), 687 __start_(__sl.start()), 688 __size_(__sl.size()), 689 __stride_(__sl.stride()) 690 {} 691public: 692 693 _LIBCPP_INLINE_VISIBILITY 694 __result_type operator[](size_t __i) const 695 {return __expr_[__start_ + __i * __stride_];} 696 697 _LIBCPP_INLINE_VISIBILITY 698 size_t size() const {return __size_;} 699 700 template <class> friend class __val_expr; 701 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 702}; 703 704template <class _ValExpr> 705class __mask_expr; 706 707template <class _ValExpr> 708class __indirect_expr; 709 710template <class _ValExpr> 711class __shift_expr 712{ 713 typedef typename remove_reference<_ValExpr>::type _RmExpr; 714public: 715 typedef typename _RmExpr::value_type value_type; 716 typedef value_type __result_type; 717 718private: 719 _ValExpr __expr_; 720 size_t __size_; 721 ptrdiff_t __ul_; 722 ptrdiff_t __sn_; 723 ptrdiff_t __n_; 724 static const ptrdiff_t _Np = static_cast<ptrdiff_t>( 725 sizeof(ptrdiff_t) * __CHAR_BIT__ - 1); 726 727 _LIBCPP_INLINE_VISIBILITY 728 __shift_expr(int __n, const _RmExpr& __e) 729 : __expr_(__e), 730 __size_(__e.size()), 731 __n_(__n) 732 { 733 ptrdiff_t __neg_n = static_cast<ptrdiff_t>(__n_ >> _Np); 734 __sn_ = __neg_n | static_cast<ptrdiff_t>(static_cast<size_t>(-__n_) >> _Np); 735 __ul_ = ((__size_ - __n_) & ~__neg_n) | ((__n_ + 1) & __neg_n); 736 } 737public: 738 739 _LIBCPP_INLINE_VISIBILITY 740 __result_type operator[](size_t __j) const 741 { 742 ptrdiff_t __i = static_cast<ptrdiff_t>(__j); 743 ptrdiff_t __m = (__sn_ * __i - __ul_) >> _Np; 744 return (__expr_[(__i + __n_) & __m] & __m) | (value_type() & ~__m); 745 } 746 747 _LIBCPP_INLINE_VISIBILITY 748 size_t size() const {return __size_;} 749 750 template <class> friend class __val_expr; 751}; 752 753template <class _ValExpr> 754class __cshift_expr 755{ 756 typedef typename remove_reference<_ValExpr>::type _RmExpr; 757public: 758 typedef typename _RmExpr::value_type value_type; 759 typedef value_type __result_type; 760 761private: 762 _ValExpr __expr_; 763 size_t __size_; 764 size_t __m_; 765 size_t __o1_; 766 size_t __o2_; 767 768 _LIBCPP_INLINE_VISIBILITY 769 __cshift_expr(int __n, const _RmExpr& __e) 770 : __expr_(__e), 771 __size_(__e.size()) 772 { 773 __n %= static_cast<int>(__size_); 774 if (__n >= 0) 775 { 776 __m_ = __size_ - __n; 777 __o1_ = __n; 778 __o2_ = __n - __size_; 779 } 780 else 781 { 782 __m_ = -__n; 783 __o1_ = __n + __size_; 784 __o2_ = __n; 785 } 786 } 787public: 788 789 _LIBCPP_INLINE_VISIBILITY 790 __result_type operator[](size_t __i) const 791 { 792 if (__i < __m_) 793 return __expr_[__i + __o1_]; 794 return __expr_[__i + __o2_]; 795 } 796 797 _LIBCPP_INLINE_VISIBILITY 798 size_t size() const {return __size_;} 799 800 template <class> friend class __val_expr; 801}; 802 803template<class _ValExpr> 804class __val_expr; 805 806template<class _ValExpr> 807struct __is_val_expr : false_type {}; 808 809template<class _ValExpr> 810struct __is_val_expr<__val_expr<_ValExpr> > : true_type {}; 811 812template<class _Tp> 813struct __is_val_expr<valarray<_Tp> > : true_type {}; 814 815template<class _Tp> 816class _LIBCPP_TEMPLATE_VIS valarray 817{ 818public: 819 typedef _Tp value_type; 820 typedef _Tp __result_type; 821 822private: 823 value_type* __begin_; 824 value_type* __end_; 825 826public: 827 // construct/destroy: 828 _LIBCPP_INLINE_VISIBILITY 829 valarray() : __begin_(nullptr), __end_(nullptr) {} 830 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 831 explicit valarray(size_t __n); 832 _LIBCPP_INLINE_VISIBILITY 833 valarray(const value_type& __x, size_t __n); 834 valarray(const value_type* __p, size_t __n); 835 valarray(const valarray& __v); 836#ifndef _LIBCPP_CXX03_LANG 837 _LIBCPP_INLINE_VISIBILITY 838 valarray(valarray&& __v) _NOEXCEPT; 839 valarray(initializer_list<value_type> __il); 840#endif // _LIBCPP_CXX03_LANG 841 valarray(const slice_array<value_type>& __sa); 842 valarray(const gslice_array<value_type>& __ga); 843 valarray(const mask_array<value_type>& __ma); 844 valarray(const indirect_array<value_type>& __ia); 845 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 846 ~valarray(); 847 848 // assignment: 849 valarray& operator=(const valarray& __v); 850#ifndef _LIBCPP_CXX03_LANG 851 _LIBCPP_INLINE_VISIBILITY 852 valarray& operator=(valarray&& __v) _NOEXCEPT; 853 _LIBCPP_INLINE_VISIBILITY 854 valarray& operator=(initializer_list<value_type>); 855#endif // _LIBCPP_CXX03_LANG 856 _LIBCPP_INLINE_VISIBILITY 857 valarray& operator=(const value_type& __x); 858 _LIBCPP_INLINE_VISIBILITY 859 valarray& operator=(const slice_array<value_type>& __sa); 860 _LIBCPP_INLINE_VISIBILITY 861 valarray& operator=(const gslice_array<value_type>& __ga); 862 _LIBCPP_INLINE_VISIBILITY 863 valarray& operator=(const mask_array<value_type>& __ma); 864 _LIBCPP_INLINE_VISIBILITY 865 valarray& operator=(const indirect_array<value_type>& __ia); 866 template <class _ValExpr> 867 _LIBCPP_INLINE_VISIBILITY 868 valarray& operator=(const __val_expr<_ValExpr>& __v); 869 870 // element access: 871 _LIBCPP_INLINE_VISIBILITY 872 const value_type& operator[](size_t __i) const {return __begin_[__i];} 873 874 _LIBCPP_INLINE_VISIBILITY 875 value_type& operator[](size_t __i) {return __begin_[__i];} 876 877 // subset operations: 878 _LIBCPP_INLINE_VISIBILITY 879 __val_expr<__slice_expr<const valarray&> > operator[](slice __s) const; 880 _LIBCPP_INLINE_VISIBILITY 881 slice_array<value_type> operator[](slice __s); 882 _LIBCPP_INLINE_VISIBILITY 883 __val_expr<__indirect_expr<const valarray&> > operator[](const gslice& __gs) const; 884 _LIBCPP_INLINE_VISIBILITY 885 gslice_array<value_type> operator[](const gslice& __gs); 886#ifndef _LIBCPP_CXX03_LANG 887 _LIBCPP_INLINE_VISIBILITY 888 __val_expr<__indirect_expr<const valarray&> > operator[](gslice&& __gs) const; 889 _LIBCPP_INLINE_VISIBILITY 890 gslice_array<value_type> operator[](gslice&& __gs); 891#endif // _LIBCPP_CXX03_LANG 892 _LIBCPP_INLINE_VISIBILITY 893 __val_expr<__mask_expr<const valarray&> > operator[](const valarray<bool>& __vb) const; 894 _LIBCPP_INLINE_VISIBILITY 895 mask_array<value_type> operator[](const valarray<bool>& __vb); 896#ifndef _LIBCPP_CXX03_LANG 897 _LIBCPP_INLINE_VISIBILITY 898 __val_expr<__mask_expr<const valarray&> > operator[](valarray<bool>&& __vb) const; 899 _LIBCPP_INLINE_VISIBILITY 900 mask_array<value_type> operator[](valarray<bool>&& __vb); 901#endif // _LIBCPP_CXX03_LANG 902 _LIBCPP_INLINE_VISIBILITY 903 __val_expr<__indirect_expr<const valarray&> > operator[](const valarray<size_t>& __vs) const; 904 _LIBCPP_INLINE_VISIBILITY 905 indirect_array<value_type> operator[](const valarray<size_t>& __vs); 906#ifndef _LIBCPP_CXX03_LANG 907 _LIBCPP_INLINE_VISIBILITY 908 __val_expr<__indirect_expr<const valarray&> > operator[](valarray<size_t>&& __vs) const; 909 _LIBCPP_INLINE_VISIBILITY 910 indirect_array<value_type> operator[](valarray<size_t>&& __vs); 911#endif // _LIBCPP_CXX03_LANG 912 913 // unary operators: 914 valarray operator+() const; 915 valarray operator-() const; 916 valarray operator~() const; 917 valarray<bool> operator!() const; 918 919 // computed assignment: 920 _LIBCPP_INLINE_VISIBILITY 921 valarray& operator*= (const value_type& __x); 922 _LIBCPP_INLINE_VISIBILITY 923 valarray& operator/= (const value_type& __x); 924 _LIBCPP_INLINE_VISIBILITY 925 valarray& operator%= (const value_type& __x); 926 _LIBCPP_INLINE_VISIBILITY 927 valarray& operator+= (const value_type& __x); 928 _LIBCPP_INLINE_VISIBILITY 929 valarray& operator-= (const value_type& __x); 930 _LIBCPP_INLINE_VISIBILITY 931 valarray& operator^= (const value_type& __x); 932 _LIBCPP_INLINE_VISIBILITY 933 valarray& operator&= (const value_type& __x); 934 _LIBCPP_INLINE_VISIBILITY 935 valarray& operator|= (const value_type& __x); 936 _LIBCPP_INLINE_VISIBILITY 937 valarray& operator<<=(const value_type& __x); 938 _LIBCPP_INLINE_VISIBILITY 939 valarray& operator>>=(const value_type& __x); 940 941 template <class _Expr> 942 typename enable_if 943 < 944 __is_val_expr<_Expr>::value, 945 valarray& 946 >::type 947 _LIBCPP_INLINE_VISIBILITY 948 operator*= (const _Expr& __v); 949 950 template <class _Expr> 951 typename enable_if 952 < 953 __is_val_expr<_Expr>::value, 954 valarray& 955 >::type 956 _LIBCPP_INLINE_VISIBILITY 957 operator/= (const _Expr& __v); 958 959 template <class _Expr> 960 typename enable_if 961 < 962 __is_val_expr<_Expr>::value, 963 valarray& 964 >::type 965 _LIBCPP_INLINE_VISIBILITY 966 operator%= (const _Expr& __v); 967 968 template <class _Expr> 969 typename enable_if 970 < 971 __is_val_expr<_Expr>::value, 972 valarray& 973 >::type 974 _LIBCPP_INLINE_VISIBILITY 975 operator+= (const _Expr& __v); 976 977 template <class _Expr> 978 typename enable_if 979 < 980 __is_val_expr<_Expr>::value, 981 valarray& 982 >::type 983 _LIBCPP_INLINE_VISIBILITY 984 operator-= (const _Expr& __v); 985 986 template <class _Expr> 987 typename enable_if 988 < 989 __is_val_expr<_Expr>::value, 990 valarray& 991 >::type 992 _LIBCPP_INLINE_VISIBILITY 993 operator^= (const _Expr& __v); 994 995 template <class _Expr> 996 typename enable_if 997 < 998 __is_val_expr<_Expr>::value, 999 valarray& 1000 >::type 1001 _LIBCPP_INLINE_VISIBILITY 1002 operator|= (const _Expr& __v); 1003 1004 template <class _Expr> 1005 typename enable_if 1006 < 1007 __is_val_expr<_Expr>::value, 1008 valarray& 1009 >::type 1010 _LIBCPP_INLINE_VISIBILITY 1011 operator&= (const _Expr& __v); 1012 1013 template <class _Expr> 1014 typename enable_if 1015 < 1016 __is_val_expr<_Expr>::value, 1017 valarray& 1018 >::type 1019 _LIBCPP_INLINE_VISIBILITY 1020 operator<<= (const _Expr& __v); 1021 1022 template <class _Expr> 1023 typename enable_if 1024 < 1025 __is_val_expr<_Expr>::value, 1026 valarray& 1027 >::type 1028 _LIBCPP_INLINE_VISIBILITY 1029 operator>>= (const _Expr& __v); 1030 1031 // member functions: 1032 _LIBCPP_INLINE_VISIBILITY 1033 void swap(valarray& __v) _NOEXCEPT; 1034 1035 _LIBCPP_INLINE_VISIBILITY 1036 size_t size() const {return static_cast<size_t>(__end_ - __begin_);} 1037 1038 _LIBCPP_INLINE_VISIBILITY 1039 value_type sum() const; 1040 _LIBCPP_INLINE_VISIBILITY 1041 value_type min() const; 1042 _LIBCPP_INLINE_VISIBILITY 1043 value_type max() const; 1044 1045 valarray shift (int __i) const; 1046 valarray cshift(int __i) const; 1047 valarray apply(value_type __f(value_type)) const; 1048 valarray apply(value_type __f(const value_type&)) const; 1049 void resize(size_t __n, value_type __x = value_type()); 1050 1051private: 1052 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 1053 template <class> friend class _LIBCPP_TEMPLATE_VIS slice_array; 1054 template <class> friend class _LIBCPP_TEMPLATE_VIS gslice_array; 1055 template <class> friend class _LIBCPP_TEMPLATE_VIS mask_array; 1056 template <class> friend class __mask_expr; 1057 template <class> friend class _LIBCPP_TEMPLATE_VIS indirect_array; 1058 template <class> friend class __indirect_expr; 1059 template <class> friend class __val_expr; 1060 1061 template <class _Up> 1062 friend 1063 _Up* 1064 begin(valarray<_Up>& __v); 1065 1066 template <class _Up> 1067 friend 1068 const _Up* 1069 begin(const valarray<_Up>& __v); 1070 1071 template <class _Up> 1072 friend 1073 _Up* 1074 end(valarray<_Up>& __v); 1075 1076 template <class _Up> 1077 friend 1078 const _Up* 1079 end(const valarray<_Up>& __v); 1080 1081 _LIBCPP_INLINE_VISIBILITY 1082 void __clear(size_t __capacity); 1083 valarray& __assign_range(const value_type* __f, const value_type* __l); 1084}; 1085 1086#if _LIBCPP_STD_VER > 14 1087template<class _Tp, size_t _Size> 1088valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; 1089#endif 1090 1091_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) 1092 1093template <class _Op, class _Tp> 1094struct _UnaryOp<_Op, valarray<_Tp> > 1095{ 1096 typedef typename _Op::__result_type __result_type; 1097 typedef typename decay<__result_type>::type value_type; 1098 1099 _Op __op_; 1100 const valarray<_Tp>& __a0_; 1101 1102 _LIBCPP_INLINE_VISIBILITY 1103 _UnaryOp(const _Op& __op, const valarray<_Tp>& __a0) : __op_(__op), __a0_(__a0) {} 1104 1105 _LIBCPP_INLINE_VISIBILITY 1106 __result_type operator[](size_t __i) const {return __op_(__a0_[__i]);} 1107 1108 _LIBCPP_INLINE_VISIBILITY 1109 size_t size() const {return __a0_.size();} 1110}; 1111 1112template <class _Op, class _Tp, class _A1> 1113struct _BinaryOp<_Op, valarray<_Tp>, _A1> 1114{ 1115 typedef typename _Op::__result_type __result_type; 1116 typedef typename decay<__result_type>::type value_type; 1117 1118 _Op __op_; 1119 const valarray<_Tp>& __a0_; 1120 _A1 __a1_; 1121 1122 _LIBCPP_INLINE_VISIBILITY 1123 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const _A1& __a1) 1124 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1125 1126 _LIBCPP_INLINE_VISIBILITY 1127 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1128 1129 _LIBCPP_INLINE_VISIBILITY 1130 size_t size() const {return __a0_.size();} 1131}; 1132 1133template <class _Op, class _A0, class _Tp> 1134struct _BinaryOp<_Op, _A0, valarray<_Tp> > 1135{ 1136 typedef typename _Op::__result_type __result_type; 1137 typedef typename decay<__result_type>::type value_type; 1138 1139 _Op __op_; 1140 _A0 __a0_; 1141 const valarray<_Tp>& __a1_; 1142 1143 _LIBCPP_INLINE_VISIBILITY 1144 _BinaryOp(const _Op& __op, const _A0& __a0, const valarray<_Tp>& __a1) 1145 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1146 1147 _LIBCPP_INLINE_VISIBILITY 1148 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1149 1150 _LIBCPP_INLINE_VISIBILITY 1151 size_t size() const {return __a0_.size();} 1152}; 1153 1154template <class _Op, class _Tp> 1155struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > 1156{ 1157 typedef typename _Op::__result_type __result_type; 1158 typedef typename decay<__result_type>::type value_type; 1159 1160 _Op __op_; 1161 const valarray<_Tp>& __a0_; 1162 const valarray<_Tp>& __a1_; 1163 1164 _LIBCPP_INLINE_VISIBILITY 1165 _BinaryOp(const _Op& __op, const valarray<_Tp>& __a0, const valarray<_Tp>& __a1) 1166 : __op_(__op), __a0_(__a0), __a1_(__a1) {} 1167 1168 _LIBCPP_INLINE_VISIBILITY 1169 __result_type operator[](size_t __i) const {return __op_(__a0_[__i], __a1_[__i]);} 1170 1171 _LIBCPP_INLINE_VISIBILITY 1172 size_t size() const {return __a0_.size();} 1173}; 1174 1175// slice_array 1176 1177template <class _Tp> 1178class _LIBCPP_TEMPLATE_VIS slice_array 1179{ 1180public: 1181 typedef _Tp value_type; 1182 1183private: 1184 value_type* __vp_; 1185 size_t __size_; 1186 size_t __stride_; 1187 1188public: 1189 template <class _Expr> 1190 typename enable_if 1191 < 1192 __is_val_expr<_Expr>::value, 1193 void 1194 >::type 1195 _LIBCPP_INLINE_VISIBILITY 1196 operator=(const _Expr& __v) const; 1197 1198 template <class _Expr> 1199 typename enable_if 1200 < 1201 __is_val_expr<_Expr>::value, 1202 void 1203 >::type 1204 _LIBCPP_INLINE_VISIBILITY 1205 operator*=(const _Expr& __v) const; 1206 1207 template <class _Expr> 1208 typename enable_if 1209 < 1210 __is_val_expr<_Expr>::value, 1211 void 1212 >::type 1213 _LIBCPP_INLINE_VISIBILITY 1214 operator/=(const _Expr& __v) const; 1215 1216 template <class _Expr> 1217 typename enable_if 1218 < 1219 __is_val_expr<_Expr>::value, 1220 void 1221 >::type 1222 _LIBCPP_INLINE_VISIBILITY 1223 operator%=(const _Expr& __v) const; 1224 1225 template <class _Expr> 1226 typename enable_if 1227 < 1228 __is_val_expr<_Expr>::value, 1229 void 1230 >::type 1231 _LIBCPP_INLINE_VISIBILITY 1232 operator+=(const _Expr& __v) const; 1233 1234 template <class _Expr> 1235 typename enable_if 1236 < 1237 __is_val_expr<_Expr>::value, 1238 void 1239 >::type 1240 _LIBCPP_INLINE_VISIBILITY 1241 operator-=(const _Expr& __v) const; 1242 1243 template <class _Expr> 1244 typename enable_if 1245 < 1246 __is_val_expr<_Expr>::value, 1247 void 1248 >::type 1249 _LIBCPP_INLINE_VISIBILITY 1250 operator^=(const _Expr& __v) const; 1251 1252 template <class _Expr> 1253 typename enable_if 1254 < 1255 __is_val_expr<_Expr>::value, 1256 void 1257 >::type 1258 _LIBCPP_INLINE_VISIBILITY 1259 operator&=(const _Expr& __v) const; 1260 1261 template <class _Expr> 1262 typename enable_if 1263 < 1264 __is_val_expr<_Expr>::value, 1265 void 1266 >::type 1267 _LIBCPP_INLINE_VISIBILITY 1268 operator|=(const _Expr& __v) const; 1269 1270 template <class _Expr> 1271 typename enable_if 1272 < 1273 __is_val_expr<_Expr>::value, 1274 void 1275 >::type 1276 _LIBCPP_INLINE_VISIBILITY 1277 operator<<=(const _Expr& __v) const; 1278 1279 template <class _Expr> 1280 typename enable_if 1281 < 1282 __is_val_expr<_Expr>::value, 1283 void 1284 >::type 1285 _LIBCPP_INLINE_VISIBILITY 1286 operator>>=(const _Expr& __v) const; 1287 1288 slice_array(slice_array const&) = default; 1289 1290 _LIBCPP_INLINE_VISIBILITY 1291 const slice_array& operator=(const slice_array& __sa) const; 1292 1293 _LIBCPP_INLINE_VISIBILITY 1294 void operator=(const value_type& __x) const; 1295 1296 _LIBCPP_INLINE_VISIBILITY 1297 void operator=(const valarray<value_type>& __va) const; 1298 1299private: 1300 _LIBCPP_INLINE_VISIBILITY 1301 slice_array(const slice& __sl, const valarray<value_type>& __v) 1302 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), 1303 __size_(__sl.size()), 1304 __stride_(__sl.stride()) 1305 {} 1306 1307 template <class> friend class valarray; 1308 template <class> friend class sliceExpr; 1309}; 1310 1311template <class _Tp> 1312inline 1313const slice_array<_Tp>& 1314slice_array<_Tp>::operator=(const slice_array& __sa) const 1315{ 1316 value_type* __t = __vp_; 1317 const value_type* __s = __sa.__vp_; 1318 for (size_t __n = __size_; __n; --__n, __t += __stride_, __s += __sa.__stride_) 1319 *__t = *__s; 1320 return *this; 1321} 1322 1323template <class _Tp> 1324template <class _Expr> 1325inline 1326typename enable_if 1327< 1328 __is_val_expr<_Expr>::value, 1329 void 1330>::type 1331slice_array<_Tp>::operator=(const _Expr& __v) const 1332{ 1333 value_type* __t = __vp_; 1334 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1335 *__t = __v[__i]; 1336} 1337 1338template <class _Tp> 1339inline void 1340slice_array<_Tp>::operator=(const valarray<value_type>& __va) const 1341{ 1342 value_type* __t = __vp_; 1343 for (size_t __i = 0; __i < __va.size(); ++__i, __t += __stride_) 1344 *__t = __va[__i]; 1345} 1346 1347template <class _Tp> 1348template <class _Expr> 1349inline 1350typename enable_if 1351< 1352 __is_val_expr<_Expr>::value, 1353 void 1354>::type 1355slice_array<_Tp>::operator*=(const _Expr& __v) const 1356{ 1357 value_type* __t = __vp_; 1358 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1359 *__t *= __v[__i]; 1360} 1361 1362template <class _Tp> 1363template <class _Expr> 1364inline 1365typename enable_if 1366< 1367 __is_val_expr<_Expr>::value, 1368 void 1369>::type 1370slice_array<_Tp>::operator/=(const _Expr& __v) const 1371{ 1372 value_type* __t = __vp_; 1373 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1374 *__t /= __v[__i]; 1375} 1376 1377template <class _Tp> 1378template <class _Expr> 1379inline 1380typename enable_if 1381< 1382 __is_val_expr<_Expr>::value, 1383 void 1384>::type 1385slice_array<_Tp>::operator%=(const _Expr& __v) const 1386{ 1387 value_type* __t = __vp_; 1388 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1389 *__t %= __v[__i]; 1390} 1391 1392template <class _Tp> 1393template <class _Expr> 1394inline 1395typename enable_if 1396< 1397 __is_val_expr<_Expr>::value, 1398 void 1399>::type 1400slice_array<_Tp>::operator+=(const _Expr& __v) const 1401{ 1402 value_type* __t = __vp_; 1403 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1404 *__t += __v[__i]; 1405} 1406 1407template <class _Tp> 1408template <class _Expr> 1409inline 1410typename enable_if 1411< 1412 __is_val_expr<_Expr>::value, 1413 void 1414>::type 1415slice_array<_Tp>::operator-=(const _Expr& __v) const 1416{ 1417 value_type* __t = __vp_; 1418 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1419 *__t -= __v[__i]; 1420} 1421 1422template <class _Tp> 1423template <class _Expr> 1424inline 1425typename enable_if 1426< 1427 __is_val_expr<_Expr>::value, 1428 void 1429>::type 1430slice_array<_Tp>::operator^=(const _Expr& __v) const 1431{ 1432 value_type* __t = __vp_; 1433 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1434 *__t ^= __v[__i]; 1435} 1436 1437template <class _Tp> 1438template <class _Expr> 1439inline 1440typename enable_if 1441< 1442 __is_val_expr<_Expr>::value, 1443 void 1444>::type 1445slice_array<_Tp>::operator&=(const _Expr& __v) const 1446{ 1447 value_type* __t = __vp_; 1448 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1449 *__t &= __v[__i]; 1450} 1451 1452template <class _Tp> 1453template <class _Expr> 1454inline 1455typename enable_if 1456< 1457 __is_val_expr<_Expr>::value, 1458 void 1459>::type 1460slice_array<_Tp>::operator|=(const _Expr& __v) const 1461{ 1462 value_type* __t = __vp_; 1463 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1464 *__t |= __v[__i]; 1465} 1466 1467template <class _Tp> 1468template <class _Expr> 1469inline 1470typename enable_if 1471< 1472 __is_val_expr<_Expr>::value, 1473 void 1474>::type 1475slice_array<_Tp>::operator<<=(const _Expr& __v) const 1476{ 1477 value_type* __t = __vp_; 1478 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1479 *__t <<= __v[__i]; 1480} 1481 1482template <class _Tp> 1483template <class _Expr> 1484inline 1485typename enable_if 1486< 1487 __is_val_expr<_Expr>::value, 1488 void 1489>::type 1490slice_array<_Tp>::operator>>=(const _Expr& __v) const 1491{ 1492 value_type* __t = __vp_; 1493 for (size_t __i = 0; __i < __size_; ++__i, __t += __stride_) 1494 *__t >>= __v[__i]; 1495} 1496 1497template <class _Tp> 1498inline 1499void 1500slice_array<_Tp>::operator=(const value_type& __x) const 1501{ 1502 value_type* __t = __vp_; 1503 for (size_t __n = __size_; __n; --__n, __t += __stride_) 1504 *__t = __x; 1505} 1506 1507// gslice 1508 1509class _LIBCPP_TYPE_VIS gslice 1510{ 1511 valarray<size_t> __size_; 1512 valarray<size_t> __stride_; 1513 valarray<size_t> __1d_; 1514 1515public: 1516 _LIBCPP_INLINE_VISIBILITY 1517 gslice() {} 1518 1519 _LIBCPP_INLINE_VISIBILITY 1520 gslice(size_t __start, const valarray<size_t>& __size, 1521 const valarray<size_t>& __stride) 1522 : __size_(__size), 1523 __stride_(__stride) 1524 {__init(__start);} 1525 1526#ifndef _LIBCPP_CXX03_LANG 1527 1528 _LIBCPP_INLINE_VISIBILITY 1529 gslice(size_t __start, const valarray<size_t>& __size, 1530 valarray<size_t>&& __stride) 1531 : __size_(__size), 1532 __stride_(move(__stride)) 1533 {__init(__start);} 1534 1535 _LIBCPP_INLINE_VISIBILITY 1536 gslice(size_t __start, valarray<size_t>&& __size, 1537 const valarray<size_t>& __stride) 1538 : __size_(move(__size)), 1539 __stride_(__stride) 1540 {__init(__start);} 1541 1542 _LIBCPP_INLINE_VISIBILITY 1543 gslice(size_t __start, valarray<size_t>&& __size, 1544 valarray<size_t>&& __stride) 1545 : __size_(move(__size)), 1546 __stride_(move(__stride)) 1547 {__init(__start);} 1548 1549#endif // _LIBCPP_CXX03_LANG 1550 1551 _LIBCPP_INLINE_VISIBILITY 1552 size_t start() const {return __1d_.size() ? __1d_[0] : 0;} 1553 1554 _LIBCPP_INLINE_VISIBILITY 1555 valarray<size_t> size() const {return __size_;} 1556 1557 _LIBCPP_INLINE_VISIBILITY 1558 valarray<size_t> stride() const {return __stride_;} 1559 1560private: 1561 void __init(size_t __start); 1562 1563 template <class> friend class gslice_array; 1564 template <class> friend class valarray; 1565 template <class> friend class __val_expr; 1566}; 1567 1568// gslice_array 1569 1570template <class _Tp> 1571class _LIBCPP_TEMPLATE_VIS gslice_array 1572{ 1573public: 1574 typedef _Tp value_type; 1575 1576private: 1577 value_type* __vp_; 1578 valarray<size_t> __1d_; 1579 1580public: 1581 template <class _Expr> 1582 typename enable_if 1583 < 1584 __is_val_expr<_Expr>::value, 1585 void 1586 >::type 1587 _LIBCPP_INLINE_VISIBILITY 1588 operator=(const _Expr& __v) const; 1589 1590 template <class _Expr> 1591 typename enable_if 1592 < 1593 __is_val_expr<_Expr>::value, 1594 void 1595 >::type 1596 _LIBCPP_INLINE_VISIBILITY 1597 operator*=(const _Expr& __v) const; 1598 1599 template <class _Expr> 1600 typename enable_if 1601 < 1602 __is_val_expr<_Expr>::value, 1603 void 1604 >::type 1605 _LIBCPP_INLINE_VISIBILITY 1606 operator/=(const _Expr& __v) const; 1607 1608 template <class _Expr> 1609 typename enable_if 1610 < 1611 __is_val_expr<_Expr>::value, 1612 void 1613 >::type 1614 _LIBCPP_INLINE_VISIBILITY 1615 operator%=(const _Expr& __v) const; 1616 1617 template <class _Expr> 1618 typename enable_if 1619 < 1620 __is_val_expr<_Expr>::value, 1621 void 1622 >::type 1623 _LIBCPP_INLINE_VISIBILITY 1624 operator+=(const _Expr& __v) const; 1625 1626 template <class _Expr> 1627 typename enable_if 1628 < 1629 __is_val_expr<_Expr>::value, 1630 void 1631 >::type 1632 _LIBCPP_INLINE_VISIBILITY 1633 operator-=(const _Expr& __v) const; 1634 1635 template <class _Expr> 1636 typename enable_if 1637 < 1638 __is_val_expr<_Expr>::value, 1639 void 1640 >::type 1641 _LIBCPP_INLINE_VISIBILITY 1642 operator^=(const _Expr& __v) const; 1643 1644 template <class _Expr> 1645 typename enable_if 1646 < 1647 __is_val_expr<_Expr>::value, 1648 void 1649 >::type 1650 _LIBCPP_INLINE_VISIBILITY 1651 operator&=(const _Expr& __v) const; 1652 1653 template <class _Expr> 1654 typename enable_if 1655 < 1656 __is_val_expr<_Expr>::value, 1657 void 1658 >::type 1659 _LIBCPP_INLINE_VISIBILITY 1660 operator|=(const _Expr& __v) const; 1661 1662 template <class _Expr> 1663 typename enable_if 1664 < 1665 __is_val_expr<_Expr>::value, 1666 void 1667 >::type 1668 _LIBCPP_INLINE_VISIBILITY 1669 operator<<=(const _Expr& __v) const; 1670 1671 template <class _Expr> 1672 typename enable_if 1673 < 1674 __is_val_expr<_Expr>::value, 1675 void 1676 >::type 1677 _LIBCPP_INLINE_VISIBILITY 1678 operator>>=(const _Expr& __v) const; 1679 1680 _LIBCPP_INLINE_VISIBILITY 1681 const gslice_array& operator=(const gslice_array& __ga) const; 1682 1683 _LIBCPP_INLINE_VISIBILITY 1684 void operator=(const value_type& __x) const; 1685 1686 gslice_array(const gslice_array&) = default; 1687 1688private: 1689 gslice_array(const gslice& __gs, const valarray<value_type>& __v) 1690 : __vp_(const_cast<value_type*>(__v.__begin_)), 1691 __1d_(__gs.__1d_) 1692 {} 1693 1694#ifndef _LIBCPP_CXX03_LANG 1695 gslice_array(gslice&& __gs, const valarray<value_type>& __v) 1696 : __vp_(const_cast<value_type*>(__v.__begin_)), 1697 __1d_(move(__gs.__1d_)) 1698 {} 1699#endif // _LIBCPP_CXX03_LANG 1700 1701 template <class> friend class valarray; 1702}; 1703 1704template <class _Tp> 1705template <class _Expr> 1706inline 1707typename enable_if 1708< 1709 __is_val_expr<_Expr>::value, 1710 void 1711>::type 1712gslice_array<_Tp>::operator=(const _Expr& __v) const 1713{ 1714 typedef const size_t* _Ip; 1715 size_t __j = 0; 1716 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1717 __vp_[*__i] = __v[__j]; 1718} 1719 1720template <class _Tp> 1721template <class _Expr> 1722inline 1723typename enable_if 1724< 1725 __is_val_expr<_Expr>::value, 1726 void 1727>::type 1728gslice_array<_Tp>::operator*=(const _Expr& __v) const 1729{ 1730 typedef const size_t* _Ip; 1731 size_t __j = 0; 1732 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1733 __vp_[*__i] *= __v[__j]; 1734} 1735 1736template <class _Tp> 1737template <class _Expr> 1738inline 1739typename enable_if 1740< 1741 __is_val_expr<_Expr>::value, 1742 void 1743>::type 1744gslice_array<_Tp>::operator/=(const _Expr& __v) const 1745{ 1746 typedef const size_t* _Ip; 1747 size_t __j = 0; 1748 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1749 __vp_[*__i] /= __v[__j]; 1750} 1751 1752template <class _Tp> 1753template <class _Expr> 1754inline 1755typename enable_if 1756< 1757 __is_val_expr<_Expr>::value, 1758 void 1759>::type 1760gslice_array<_Tp>::operator%=(const _Expr& __v) const 1761{ 1762 typedef const size_t* _Ip; 1763 size_t __j = 0; 1764 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1765 __vp_[*__i] %= __v[__j]; 1766} 1767 1768template <class _Tp> 1769template <class _Expr> 1770inline 1771typename enable_if 1772< 1773 __is_val_expr<_Expr>::value, 1774 void 1775>::type 1776gslice_array<_Tp>::operator+=(const _Expr& __v) const 1777{ 1778 typedef const size_t* _Ip; 1779 size_t __j = 0; 1780 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1781 __vp_[*__i] += __v[__j]; 1782} 1783 1784template <class _Tp> 1785template <class _Expr> 1786inline 1787typename enable_if 1788< 1789 __is_val_expr<_Expr>::value, 1790 void 1791>::type 1792gslice_array<_Tp>::operator-=(const _Expr& __v) const 1793{ 1794 typedef const size_t* _Ip; 1795 size_t __j = 0; 1796 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1797 __vp_[*__i] -= __v[__j]; 1798} 1799 1800template <class _Tp> 1801template <class _Expr> 1802inline 1803typename enable_if 1804< 1805 __is_val_expr<_Expr>::value, 1806 void 1807>::type 1808gslice_array<_Tp>::operator^=(const _Expr& __v) const 1809{ 1810 typedef const size_t* _Ip; 1811 size_t __j = 0; 1812 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1813 __vp_[*__i] ^= __v[__j]; 1814} 1815 1816template <class _Tp> 1817template <class _Expr> 1818inline 1819typename enable_if 1820< 1821 __is_val_expr<_Expr>::value, 1822 void 1823>::type 1824gslice_array<_Tp>::operator&=(const _Expr& __v) const 1825{ 1826 typedef const size_t* _Ip; 1827 size_t __j = 0; 1828 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1829 __vp_[*__i] &= __v[__j]; 1830} 1831 1832template <class _Tp> 1833template <class _Expr> 1834inline 1835typename enable_if 1836< 1837 __is_val_expr<_Expr>::value, 1838 void 1839>::type 1840gslice_array<_Tp>::operator|=(const _Expr& __v) const 1841{ 1842 typedef const size_t* _Ip; 1843 size_t __j = 0; 1844 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1845 __vp_[*__i] |= __v[__j]; 1846} 1847 1848template <class _Tp> 1849template <class _Expr> 1850inline 1851typename enable_if 1852< 1853 __is_val_expr<_Expr>::value, 1854 void 1855>::type 1856gslice_array<_Tp>::operator<<=(const _Expr& __v) const 1857{ 1858 typedef const size_t* _Ip; 1859 size_t __j = 0; 1860 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1861 __vp_[*__i] <<= __v[__j]; 1862} 1863 1864template <class _Tp> 1865template <class _Expr> 1866inline 1867typename enable_if 1868< 1869 __is_val_expr<_Expr>::value, 1870 void 1871>::type 1872gslice_array<_Tp>::operator>>=(const _Expr& __v) const 1873{ 1874 typedef const size_t* _Ip; 1875 size_t __j = 0; 1876 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i, ++__j) 1877 __vp_[*__i] >>= __v[__j]; 1878} 1879 1880template <class _Tp> 1881inline 1882const gslice_array<_Tp>& 1883gslice_array<_Tp>::operator=(const gslice_array& __ga) const 1884{ 1885 typedef const size_t* _Ip; 1886 const value_type* __s = __ga.__vp_; 1887 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ga.__1d_.__begin_; 1888 __i != __e; ++__i, ++__j) 1889 __vp_[*__i] = __s[*__j]; 1890 return *this; 1891} 1892 1893template <class _Tp> 1894inline 1895void 1896gslice_array<_Tp>::operator=(const value_type& __x) const 1897{ 1898 typedef const size_t* _Ip; 1899 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) 1900 __vp_[*__i] = __x; 1901} 1902 1903// mask_array 1904 1905template <class _Tp> 1906class _LIBCPP_TEMPLATE_VIS mask_array 1907{ 1908public: 1909 typedef _Tp value_type; 1910 1911private: 1912 value_type* __vp_; 1913 valarray<size_t> __1d_; 1914 1915public: 1916 template <class _Expr> 1917 typename enable_if 1918 < 1919 __is_val_expr<_Expr>::value, 1920 void 1921 >::type 1922 _LIBCPP_INLINE_VISIBILITY 1923 operator=(const _Expr& __v) const; 1924 1925 template <class _Expr> 1926 typename enable_if 1927 < 1928 __is_val_expr<_Expr>::value, 1929 void 1930 >::type 1931 _LIBCPP_INLINE_VISIBILITY 1932 operator*=(const _Expr& __v) const; 1933 1934 template <class _Expr> 1935 typename enable_if 1936 < 1937 __is_val_expr<_Expr>::value, 1938 void 1939 >::type 1940 _LIBCPP_INLINE_VISIBILITY 1941 operator/=(const _Expr& __v) const; 1942 1943 template <class _Expr> 1944 typename enable_if 1945 < 1946 __is_val_expr<_Expr>::value, 1947 void 1948 >::type 1949 _LIBCPP_INLINE_VISIBILITY 1950 operator%=(const _Expr& __v) const; 1951 1952 template <class _Expr> 1953 typename enable_if 1954 < 1955 __is_val_expr<_Expr>::value, 1956 void 1957 >::type 1958 _LIBCPP_INLINE_VISIBILITY 1959 operator+=(const _Expr& __v) const; 1960 1961 template <class _Expr> 1962 typename enable_if 1963 < 1964 __is_val_expr<_Expr>::value, 1965 void 1966 >::type 1967 _LIBCPP_INLINE_VISIBILITY 1968 operator-=(const _Expr& __v) const; 1969 1970 template <class _Expr> 1971 typename enable_if 1972 < 1973 __is_val_expr<_Expr>::value, 1974 void 1975 >::type 1976 _LIBCPP_INLINE_VISIBILITY 1977 operator^=(const _Expr& __v) const; 1978 1979 template <class _Expr> 1980 typename enable_if 1981 < 1982 __is_val_expr<_Expr>::value, 1983 void 1984 >::type 1985 _LIBCPP_INLINE_VISIBILITY 1986 operator&=(const _Expr& __v) const; 1987 1988 template <class _Expr> 1989 typename enable_if 1990 < 1991 __is_val_expr<_Expr>::value, 1992 void 1993 >::type 1994 _LIBCPP_INLINE_VISIBILITY 1995 operator|=(const _Expr& __v) const; 1996 1997 template <class _Expr> 1998 typename enable_if 1999 < 2000 __is_val_expr<_Expr>::value, 2001 void 2002 >::type 2003 _LIBCPP_INLINE_VISIBILITY 2004 operator<<=(const _Expr& __v) const; 2005 2006 template <class _Expr> 2007 typename enable_if 2008 < 2009 __is_val_expr<_Expr>::value, 2010 void 2011 >::type 2012 _LIBCPP_INLINE_VISIBILITY 2013 operator>>=(const _Expr& __v) const; 2014 2015 mask_array(const mask_array&) = default; 2016 2017 _LIBCPP_INLINE_VISIBILITY 2018 const mask_array& operator=(const mask_array& __ma) const; 2019 2020 _LIBCPP_INLINE_VISIBILITY 2021 void operator=(const value_type& __x) const; 2022 2023private: 2024 _LIBCPP_INLINE_VISIBILITY 2025 mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v) 2026 : __vp_(const_cast<value_type*>(__v.__begin_)), 2027 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) 2028 { 2029 size_t __j = 0; 2030 for (size_t __i = 0; __i < __vb.size(); ++__i) 2031 if (__vb[__i]) 2032 __1d_[__j++] = __i; 2033 } 2034 2035 template <class> friend class valarray; 2036}; 2037 2038template <class _Tp> 2039template <class _Expr> 2040inline 2041typename enable_if 2042< 2043 __is_val_expr<_Expr>::value, 2044 void 2045>::type 2046mask_array<_Tp>::operator=(const _Expr& __v) const 2047{ 2048 size_t __n = __1d_.size(); 2049 for (size_t __i = 0; __i < __n; ++__i) 2050 __vp_[__1d_[__i]] = __v[__i]; 2051} 2052 2053template <class _Tp> 2054template <class _Expr> 2055inline 2056typename enable_if 2057< 2058 __is_val_expr<_Expr>::value, 2059 void 2060>::type 2061mask_array<_Tp>::operator*=(const _Expr& __v) const 2062{ 2063 size_t __n = __1d_.size(); 2064 for (size_t __i = 0; __i < __n; ++__i) 2065 __vp_[__1d_[__i]] *= __v[__i]; 2066} 2067 2068template <class _Tp> 2069template <class _Expr> 2070inline 2071typename enable_if 2072< 2073 __is_val_expr<_Expr>::value, 2074 void 2075>::type 2076mask_array<_Tp>::operator/=(const _Expr& __v) const 2077{ 2078 size_t __n = __1d_.size(); 2079 for (size_t __i = 0; __i < __n; ++__i) 2080 __vp_[__1d_[__i]] /= __v[__i]; 2081} 2082 2083template <class _Tp> 2084template <class _Expr> 2085inline 2086typename enable_if 2087< 2088 __is_val_expr<_Expr>::value, 2089 void 2090>::type 2091mask_array<_Tp>::operator%=(const _Expr& __v) const 2092{ 2093 size_t __n = __1d_.size(); 2094 for (size_t __i = 0; __i < __n; ++__i) 2095 __vp_[__1d_[__i]] %= __v[__i]; 2096} 2097 2098template <class _Tp> 2099template <class _Expr> 2100inline 2101typename enable_if 2102< 2103 __is_val_expr<_Expr>::value, 2104 void 2105>::type 2106mask_array<_Tp>::operator+=(const _Expr& __v) const 2107{ 2108 size_t __n = __1d_.size(); 2109 for (size_t __i = 0; __i < __n; ++__i) 2110 __vp_[__1d_[__i]] += __v[__i]; 2111} 2112 2113template <class _Tp> 2114template <class _Expr> 2115inline 2116typename enable_if 2117< 2118 __is_val_expr<_Expr>::value, 2119 void 2120>::type 2121mask_array<_Tp>::operator-=(const _Expr& __v) const 2122{ 2123 size_t __n = __1d_.size(); 2124 for (size_t __i = 0; __i < __n; ++__i) 2125 __vp_[__1d_[__i]] -= __v[__i]; 2126} 2127 2128template <class _Tp> 2129template <class _Expr> 2130inline 2131typename enable_if 2132< 2133 __is_val_expr<_Expr>::value, 2134 void 2135>::type 2136mask_array<_Tp>::operator^=(const _Expr& __v) const 2137{ 2138 size_t __n = __1d_.size(); 2139 for (size_t __i = 0; __i < __n; ++__i) 2140 __vp_[__1d_[__i]] ^= __v[__i]; 2141} 2142 2143template <class _Tp> 2144template <class _Expr> 2145inline 2146typename enable_if 2147< 2148 __is_val_expr<_Expr>::value, 2149 void 2150>::type 2151mask_array<_Tp>::operator&=(const _Expr& __v) const 2152{ 2153 size_t __n = __1d_.size(); 2154 for (size_t __i = 0; __i < __n; ++__i) 2155 __vp_[__1d_[__i]] &= __v[__i]; 2156} 2157 2158template <class _Tp> 2159template <class _Expr> 2160inline 2161typename enable_if 2162< 2163 __is_val_expr<_Expr>::value, 2164 void 2165>::type 2166mask_array<_Tp>::operator|=(const _Expr& __v) const 2167{ 2168 size_t __n = __1d_.size(); 2169 for (size_t __i = 0; __i < __n; ++__i) 2170 __vp_[__1d_[__i]] |= __v[__i]; 2171} 2172 2173template <class _Tp> 2174template <class _Expr> 2175inline 2176typename enable_if 2177< 2178 __is_val_expr<_Expr>::value, 2179 void 2180>::type 2181mask_array<_Tp>::operator<<=(const _Expr& __v) const 2182{ 2183 size_t __n = __1d_.size(); 2184 for (size_t __i = 0; __i < __n; ++__i) 2185 __vp_[__1d_[__i]] <<= __v[__i]; 2186} 2187 2188template <class _Tp> 2189template <class _Expr> 2190inline 2191typename enable_if 2192< 2193 __is_val_expr<_Expr>::value, 2194 void 2195>::type 2196mask_array<_Tp>::operator>>=(const _Expr& __v) const 2197{ 2198 size_t __n = __1d_.size(); 2199 for (size_t __i = 0; __i < __n; ++__i) 2200 __vp_[__1d_[__i]] >>= __v[__i]; 2201} 2202 2203template <class _Tp> 2204inline 2205const mask_array<_Tp>& 2206mask_array<_Tp>::operator=(const mask_array& __ma) const 2207{ 2208 size_t __n = __1d_.size(); 2209 for (size_t __i = 0; __i < __n; ++__i) 2210 __vp_[__1d_[__i]] = __ma.__vp_[__1d_[__i]]; 2211 return *this; 2212} 2213 2214template <class _Tp> 2215inline 2216void 2217mask_array<_Tp>::operator=(const value_type& __x) const 2218{ 2219 size_t __n = __1d_.size(); 2220 for (size_t __i = 0; __i < __n; ++__i) 2221 __vp_[__1d_[__i]] = __x; 2222} 2223 2224template <class _ValExpr> 2225class __mask_expr 2226{ 2227 typedef typename remove_reference<_ValExpr>::type _RmExpr; 2228public: 2229 typedef typename _RmExpr::value_type value_type; 2230 typedef value_type __result_type; 2231 2232private: 2233 _ValExpr __expr_; 2234 valarray<size_t> __1d_; 2235 2236 _LIBCPP_INLINE_VISIBILITY 2237 __mask_expr(const valarray<bool>& __vb, const _RmExpr& __e) 2238 : __expr_(__e), 2239 __1d_(static_cast<size_t>(count(__vb.__begin_, __vb.__end_, true))) 2240 { 2241 size_t __j = 0; 2242 for (size_t __i = 0; __i < __vb.size(); ++__i) 2243 if (__vb[__i]) 2244 __1d_[__j++] = __i; 2245 } 2246 2247public: 2248 _LIBCPP_INLINE_VISIBILITY 2249 __result_type operator[](size_t __i) const 2250 {return __expr_[__1d_[__i]];} 2251 2252 _LIBCPP_INLINE_VISIBILITY 2253 size_t size() const {return __1d_.size();} 2254 2255 template <class> friend class __val_expr; 2256 template <class> friend class valarray; 2257}; 2258 2259// indirect_array 2260 2261template <class _Tp> 2262class _LIBCPP_TEMPLATE_VIS indirect_array 2263{ 2264public: 2265 typedef _Tp value_type; 2266 2267private: 2268 value_type* __vp_; 2269 valarray<size_t> __1d_; 2270 2271public: 2272 template <class _Expr> 2273 typename enable_if 2274 < 2275 __is_val_expr<_Expr>::value, 2276 void 2277 >::type 2278 _LIBCPP_INLINE_VISIBILITY 2279 operator=(const _Expr& __v) const; 2280 2281 template <class _Expr> 2282 typename enable_if 2283 < 2284 __is_val_expr<_Expr>::value, 2285 void 2286 >::type 2287 _LIBCPP_INLINE_VISIBILITY 2288 operator*=(const _Expr& __v) const; 2289 2290 template <class _Expr> 2291 typename enable_if 2292 < 2293 __is_val_expr<_Expr>::value, 2294 void 2295 >::type 2296 _LIBCPP_INLINE_VISIBILITY 2297 operator/=(const _Expr& __v) const; 2298 2299 template <class _Expr> 2300 typename enable_if 2301 < 2302 __is_val_expr<_Expr>::value, 2303 void 2304 >::type 2305 _LIBCPP_INLINE_VISIBILITY 2306 operator%=(const _Expr& __v) const; 2307 2308 template <class _Expr> 2309 typename enable_if 2310 < 2311 __is_val_expr<_Expr>::value, 2312 void 2313 >::type 2314 _LIBCPP_INLINE_VISIBILITY 2315 operator+=(const _Expr& __v) const; 2316 2317 template <class _Expr> 2318 typename enable_if 2319 < 2320 __is_val_expr<_Expr>::value, 2321 void 2322 >::type 2323 _LIBCPP_INLINE_VISIBILITY 2324 operator-=(const _Expr& __v) const; 2325 2326 template <class _Expr> 2327 typename enable_if 2328 < 2329 __is_val_expr<_Expr>::value, 2330 void 2331 >::type 2332 _LIBCPP_INLINE_VISIBILITY 2333 operator^=(const _Expr& __v) const; 2334 2335 template <class _Expr> 2336 typename enable_if 2337 < 2338 __is_val_expr<_Expr>::value, 2339 void 2340 >::type 2341 _LIBCPP_INLINE_VISIBILITY 2342 operator&=(const _Expr& __v) const; 2343 2344 template <class _Expr> 2345 typename enable_if 2346 < 2347 __is_val_expr<_Expr>::value, 2348 void 2349 >::type 2350 _LIBCPP_INLINE_VISIBILITY 2351 operator|=(const _Expr& __v) const; 2352 2353 template <class _Expr> 2354 typename enable_if 2355 < 2356 __is_val_expr<_Expr>::value, 2357 void 2358 >::type 2359 _LIBCPP_INLINE_VISIBILITY 2360 operator<<=(const _Expr& __v) const; 2361 2362 template <class _Expr> 2363 typename enable_if 2364 < 2365 __is_val_expr<_Expr>::value, 2366 void 2367 >::type 2368 _LIBCPP_INLINE_VISIBILITY 2369 operator>>=(const _Expr& __v) const; 2370 2371 indirect_array(const indirect_array&) = default; 2372 2373 _LIBCPP_INLINE_VISIBILITY 2374 const indirect_array& operator=(const indirect_array& __ia) const; 2375 2376 _LIBCPP_INLINE_VISIBILITY 2377 void operator=(const value_type& __x) const; 2378 2379private: 2380 _LIBCPP_INLINE_VISIBILITY 2381 indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v) 2382 : __vp_(const_cast<value_type*>(__v.__begin_)), 2383 __1d_(__ia) 2384 {} 2385 2386#ifndef _LIBCPP_CXX03_LANG 2387 2388 _LIBCPP_INLINE_VISIBILITY 2389 indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) 2390 : __vp_(const_cast<value_type*>(__v.__begin_)), 2391 __1d_(move(__ia)) 2392 {} 2393 2394#endif // _LIBCPP_CXX03_LANG 2395 2396 template <class> friend class valarray; 2397}; 2398 2399template <class _Tp> 2400template <class _Expr> 2401inline 2402typename enable_if 2403< 2404 __is_val_expr<_Expr>::value, 2405 void 2406>::type 2407indirect_array<_Tp>::operator=(const _Expr& __v) const 2408{ 2409 size_t __n = __1d_.size(); 2410 for (size_t __i = 0; __i < __n; ++__i) 2411 __vp_[__1d_[__i]] = __v[__i]; 2412} 2413 2414template <class _Tp> 2415template <class _Expr> 2416inline 2417typename enable_if 2418< 2419 __is_val_expr<_Expr>::value, 2420 void 2421>::type 2422indirect_array<_Tp>::operator*=(const _Expr& __v) const 2423{ 2424 size_t __n = __1d_.size(); 2425 for (size_t __i = 0; __i < __n; ++__i) 2426 __vp_[__1d_[__i]] *= __v[__i]; 2427} 2428 2429template <class _Tp> 2430template <class _Expr> 2431inline 2432typename enable_if 2433< 2434 __is_val_expr<_Expr>::value, 2435 void 2436>::type 2437indirect_array<_Tp>::operator/=(const _Expr& __v) const 2438{ 2439 size_t __n = __1d_.size(); 2440 for (size_t __i = 0; __i < __n; ++__i) 2441 __vp_[__1d_[__i]] /= __v[__i]; 2442} 2443 2444template <class _Tp> 2445template <class _Expr> 2446inline 2447typename enable_if 2448< 2449 __is_val_expr<_Expr>::value, 2450 void 2451>::type 2452indirect_array<_Tp>::operator%=(const _Expr& __v) const 2453{ 2454 size_t __n = __1d_.size(); 2455 for (size_t __i = 0; __i < __n; ++__i) 2456 __vp_[__1d_[__i]] %= __v[__i]; 2457} 2458 2459template <class _Tp> 2460template <class _Expr> 2461inline 2462typename enable_if 2463< 2464 __is_val_expr<_Expr>::value, 2465 void 2466>::type 2467indirect_array<_Tp>::operator+=(const _Expr& __v) const 2468{ 2469 size_t __n = __1d_.size(); 2470 for (size_t __i = 0; __i < __n; ++__i) 2471 __vp_[__1d_[__i]] += __v[__i]; 2472} 2473 2474template <class _Tp> 2475template <class _Expr> 2476inline 2477typename enable_if 2478< 2479 __is_val_expr<_Expr>::value, 2480 void 2481>::type 2482indirect_array<_Tp>::operator-=(const _Expr& __v) const 2483{ 2484 size_t __n = __1d_.size(); 2485 for (size_t __i = 0; __i < __n; ++__i) 2486 __vp_[__1d_[__i]] -= __v[__i]; 2487} 2488 2489template <class _Tp> 2490template <class _Expr> 2491inline 2492typename enable_if 2493< 2494 __is_val_expr<_Expr>::value, 2495 void 2496>::type 2497indirect_array<_Tp>::operator^=(const _Expr& __v) const 2498{ 2499 size_t __n = __1d_.size(); 2500 for (size_t __i = 0; __i < __n; ++__i) 2501 __vp_[__1d_[__i]] ^= __v[__i]; 2502} 2503 2504template <class _Tp> 2505template <class _Expr> 2506inline 2507typename enable_if 2508< 2509 __is_val_expr<_Expr>::value, 2510 void 2511>::type 2512indirect_array<_Tp>::operator&=(const _Expr& __v) const 2513{ 2514 size_t __n = __1d_.size(); 2515 for (size_t __i = 0; __i < __n; ++__i) 2516 __vp_[__1d_[__i]] &= __v[__i]; 2517} 2518 2519template <class _Tp> 2520template <class _Expr> 2521inline 2522typename enable_if 2523< 2524 __is_val_expr<_Expr>::value, 2525 void 2526>::type 2527indirect_array<_Tp>::operator|=(const _Expr& __v) const 2528{ 2529 size_t __n = __1d_.size(); 2530 for (size_t __i = 0; __i < __n; ++__i) 2531 __vp_[__1d_[__i]] |= __v[__i]; 2532} 2533 2534template <class _Tp> 2535template <class _Expr> 2536inline 2537typename enable_if 2538< 2539 __is_val_expr<_Expr>::value, 2540 void 2541>::type 2542indirect_array<_Tp>::operator<<=(const _Expr& __v) const 2543{ 2544 size_t __n = __1d_.size(); 2545 for (size_t __i = 0; __i < __n; ++__i) 2546 __vp_[__1d_[__i]] <<= __v[__i]; 2547} 2548 2549template <class _Tp> 2550template <class _Expr> 2551inline 2552typename enable_if 2553< 2554 __is_val_expr<_Expr>::value, 2555 void 2556>::type 2557indirect_array<_Tp>::operator>>=(const _Expr& __v) const 2558{ 2559 size_t __n = __1d_.size(); 2560 for (size_t __i = 0; __i < __n; ++__i) 2561 __vp_[__1d_[__i]] >>= __v[__i]; 2562} 2563 2564template <class _Tp> 2565inline 2566const indirect_array<_Tp>& 2567indirect_array<_Tp>::operator=(const indirect_array& __ia) const 2568{ 2569 typedef const size_t* _Ip; 2570 const value_type* __s = __ia.__vp_; 2571 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_, __j = __ia.__1d_.__begin_; 2572 __i != __e; ++__i, ++__j) 2573 __vp_[*__i] = __s[*__j]; 2574 return *this; 2575} 2576 2577template <class _Tp> 2578inline 2579void 2580indirect_array<_Tp>::operator=(const value_type& __x) const 2581{ 2582 typedef const size_t* _Ip; 2583 for (_Ip __i = __1d_.__begin_, __e = __1d_.__end_; __i != __e; ++__i) 2584 __vp_[*__i] = __x; 2585} 2586 2587template <class _ValExpr> 2588class __indirect_expr 2589{ 2590 typedef typename remove_reference<_ValExpr>::type _RmExpr; 2591public: 2592 typedef typename _RmExpr::value_type value_type; 2593 typedef value_type __result_type; 2594 2595private: 2596 _ValExpr __expr_; 2597 valarray<size_t> __1d_; 2598 2599 _LIBCPP_INLINE_VISIBILITY 2600 __indirect_expr(const valarray<size_t>& __ia, const _RmExpr& __e) 2601 : __expr_(__e), 2602 __1d_(__ia) 2603 {} 2604 2605#ifndef _LIBCPP_CXX03_LANG 2606 2607 _LIBCPP_INLINE_VISIBILITY 2608 __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) 2609 : __expr_(__e), 2610 __1d_(move(__ia)) 2611 {} 2612 2613#endif // _LIBCPP_CXX03_LANG 2614 2615public: 2616 _LIBCPP_INLINE_VISIBILITY 2617 __result_type operator[](size_t __i) const 2618 {return __expr_[__1d_[__i]];} 2619 2620 _LIBCPP_INLINE_VISIBILITY 2621 size_t size() const {return __1d_.size();} 2622 2623 template <class> friend class __val_expr; 2624 template <class> friend class _LIBCPP_TEMPLATE_VIS valarray; 2625}; 2626 2627template<class _ValExpr> 2628class __val_expr 2629{ 2630 typedef typename remove_reference<_ValExpr>::type _RmExpr; 2631 2632 _ValExpr __expr_; 2633public: 2634 typedef typename _RmExpr::value_type value_type; 2635 typedef typename _RmExpr::__result_type __result_type; 2636 2637 _LIBCPP_INLINE_VISIBILITY 2638 explicit __val_expr(const _RmExpr& __e) : __expr_(__e) {} 2639 2640 _LIBCPP_INLINE_VISIBILITY 2641 __result_type operator[](size_t __i) const 2642 {return __expr_[__i];} 2643 2644 _LIBCPP_INLINE_VISIBILITY 2645 __val_expr<__slice_expr<_ValExpr> > operator[](slice __s) const 2646 { 2647 typedef __slice_expr<_ValExpr> _NewExpr; 2648 return __val_expr< _NewExpr >(_NewExpr(__s, __expr_)); 2649 } 2650 2651 _LIBCPP_INLINE_VISIBILITY 2652 __val_expr<__indirect_expr<_ValExpr> > operator[](const gslice& __gs) const 2653 { 2654 typedef __indirect_expr<_ValExpr> _NewExpr; 2655 return __val_expr<_NewExpr >(_NewExpr(__gs.__1d_, __expr_)); 2656 } 2657 2658 _LIBCPP_INLINE_VISIBILITY 2659 __val_expr<__mask_expr<_ValExpr> > operator[](const valarray<bool>& __vb) const 2660 { 2661 typedef __mask_expr<_ValExpr> _NewExpr; 2662 return __val_expr< _NewExpr >( _NewExpr(__vb, __expr_)); 2663 } 2664 2665 _LIBCPP_INLINE_VISIBILITY 2666 __val_expr<__indirect_expr<_ValExpr> > operator[](const valarray<size_t>& __vs) const 2667 { 2668 typedef __indirect_expr<_ValExpr> _NewExpr; 2669 return __val_expr< _NewExpr >(_NewExpr(__vs, __expr_)); 2670 } 2671 2672 _LIBCPP_INLINE_VISIBILITY 2673 __val_expr<_UnaryOp<__unary_plus<value_type>, _ValExpr> > 2674 operator+() const 2675 { 2676 typedef _UnaryOp<__unary_plus<value_type>, _ValExpr> _NewExpr; 2677 return __val_expr<_NewExpr>(_NewExpr(__unary_plus<value_type>(), __expr_)); 2678 } 2679 2680 _LIBCPP_INLINE_VISIBILITY 2681 __val_expr<_UnaryOp<negate<value_type>, _ValExpr> > 2682 operator-() const 2683 { 2684 typedef _UnaryOp<negate<value_type>, _ValExpr> _NewExpr; 2685 return __val_expr<_NewExpr>(_NewExpr(negate<value_type>(), __expr_)); 2686 } 2687 2688 _LIBCPP_INLINE_VISIBILITY 2689 __val_expr<_UnaryOp<__bit_not<value_type>, _ValExpr> > 2690 operator~() const 2691 { 2692 typedef _UnaryOp<__bit_not<value_type>, _ValExpr> _NewExpr; 2693 return __val_expr<_NewExpr>(_NewExpr(__bit_not<value_type>(), __expr_)); 2694 } 2695 2696 _LIBCPP_INLINE_VISIBILITY 2697 __val_expr<_UnaryOp<logical_not<value_type>, _ValExpr> > 2698 operator!() const 2699 { 2700 typedef _UnaryOp<logical_not<value_type>, _ValExpr> _NewExpr; 2701 return __val_expr<_NewExpr>(_NewExpr(logical_not<value_type>(), __expr_)); 2702 } 2703 2704 operator valarray<__result_type>() const; 2705 2706 _LIBCPP_INLINE_VISIBILITY 2707 size_t size() const {return __expr_.size();} 2708 2709 _LIBCPP_INLINE_VISIBILITY 2710 __result_type sum() const 2711 { 2712 size_t __n = __expr_.size(); 2713 __result_type __r = __n ? __expr_[0] : __result_type(); 2714 for (size_t __i = 1; __i < __n; ++__i) 2715 __r += __expr_[__i]; 2716 return __r; 2717 } 2718 2719 _LIBCPP_INLINE_VISIBILITY 2720 __result_type min() const 2721 { 2722 size_t __n = size(); 2723 __result_type __r = __n ? (*this)[0] : __result_type(); 2724 for (size_t __i = 1; __i < __n; ++__i) 2725 { 2726 __result_type __x = __expr_[__i]; 2727 if (__x < __r) 2728 __r = __x; 2729 } 2730 return __r; 2731 } 2732 2733 _LIBCPP_INLINE_VISIBILITY 2734 __result_type max() const 2735 { 2736 size_t __n = size(); 2737 __result_type __r = __n ? (*this)[0] : __result_type(); 2738 for (size_t __i = 1; __i < __n; ++__i) 2739 { 2740 __result_type __x = __expr_[__i]; 2741 if (__r < __x) 2742 __r = __x; 2743 } 2744 return __r; 2745 } 2746 2747 _LIBCPP_INLINE_VISIBILITY 2748 __val_expr<__shift_expr<_ValExpr> > shift (int __i) const 2749 {return __val_expr<__shift_expr<_ValExpr> >(__shift_expr<_ValExpr>(__i, __expr_));} 2750 2751 _LIBCPP_INLINE_VISIBILITY 2752 __val_expr<__cshift_expr<_ValExpr> > cshift(int __i) const 2753 {return __val_expr<__cshift_expr<_ValExpr> >(__cshift_expr<_ValExpr>(__i, __expr_));} 2754 2755 _LIBCPP_INLINE_VISIBILITY 2756 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(value_type)>, _ValExpr> > 2757 apply(value_type __f(value_type)) const 2758 { 2759 typedef __apply_expr<value_type, value_type(*)(value_type)> _Op; 2760 typedef _UnaryOp<_Op, _ValExpr> _NewExpr; 2761 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); 2762 } 2763 2764 _LIBCPP_INLINE_VISIBILITY 2765 __val_expr<_UnaryOp<__apply_expr<value_type, value_type(*)(const value_type&)>, _ValExpr> > 2766 apply(value_type __f(const value_type&)) const 2767 { 2768 typedef __apply_expr<value_type, value_type(*)(const value_type&)> _Op; 2769 typedef _UnaryOp<_Op, _ValExpr> _NewExpr; 2770 return __val_expr<_NewExpr>(_NewExpr(_Op(__f), __expr_)); 2771 } 2772}; 2773 2774template<class _ValExpr> 2775__val_expr<_ValExpr>::operator valarray<__val_expr::__result_type>() const 2776{ 2777 valarray<__result_type> __r; 2778 size_t __n = __expr_.size(); 2779 if (__n) 2780 { 2781 __r.__begin_ = 2782 __r.__end_ = allocator<__result_type>().allocate(__n); 2783 for (size_t __i = 0; __i != __n; ++__r.__end_, ++__i) 2784 ::new ((void*)__r.__end_) __result_type(__expr_[__i]); 2785 } 2786 return __r; 2787} 2788 2789// valarray 2790 2791template <class _Tp> 2792inline 2793valarray<_Tp>::valarray(size_t __n) 2794 : __begin_(nullptr), 2795 __end_(nullptr) 2796{ 2797 if (__n) 2798 { 2799 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2800#ifndef _LIBCPP_NO_EXCEPTIONS 2801 try 2802 { 2803#endif // _LIBCPP_NO_EXCEPTIONS 2804 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) 2805 ::new ((void*)__end_) value_type(); 2806#ifndef _LIBCPP_NO_EXCEPTIONS 2807 } 2808 catch (...) 2809 { 2810 __clear(__n); 2811 throw; 2812 } 2813#endif // _LIBCPP_NO_EXCEPTIONS 2814 } 2815} 2816 2817template <class _Tp> 2818inline 2819valarray<_Tp>::valarray(const value_type& __x, size_t __n) 2820 : __begin_(nullptr), 2821 __end_(nullptr) 2822{ 2823 resize(__n, __x); 2824} 2825 2826template <class _Tp> 2827valarray<_Tp>::valarray(const value_type* __p, size_t __n) 2828 : __begin_(nullptr), 2829 __end_(nullptr) 2830{ 2831 if (__n) 2832 { 2833 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2834#ifndef _LIBCPP_NO_EXCEPTIONS 2835 try 2836 { 2837#endif // _LIBCPP_NO_EXCEPTIONS 2838 for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) 2839 ::new ((void*)__end_) value_type(*__p); 2840#ifndef _LIBCPP_NO_EXCEPTIONS 2841 } 2842 catch (...) 2843 { 2844 __clear(__n); 2845 throw; 2846 } 2847#endif // _LIBCPP_NO_EXCEPTIONS 2848 } 2849} 2850 2851template <class _Tp> 2852valarray<_Tp>::valarray(const valarray& __v) 2853 : __begin_(nullptr), 2854 __end_(nullptr) 2855{ 2856 if (__v.size()) 2857 { 2858 __begin_ = __end_ = allocator<value_type>().allocate(__v.size()); 2859#ifndef _LIBCPP_NO_EXCEPTIONS 2860 try 2861 { 2862#endif // _LIBCPP_NO_EXCEPTIONS 2863 for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) 2864 ::new ((void*)__end_) value_type(*__p); 2865#ifndef _LIBCPP_NO_EXCEPTIONS 2866 } 2867 catch (...) 2868 { 2869 __clear(__v.size()); 2870 throw; 2871 } 2872#endif // _LIBCPP_NO_EXCEPTIONS 2873 } 2874} 2875 2876#ifndef _LIBCPP_CXX03_LANG 2877 2878template <class _Tp> 2879inline 2880valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT 2881 : __begin_(__v.__begin_), 2882 __end_(__v.__end_) 2883{ 2884 __v.__begin_ = __v.__end_ = nullptr; 2885} 2886 2887template <class _Tp> 2888valarray<_Tp>::valarray(initializer_list<value_type> __il) 2889 : __begin_(nullptr), 2890 __end_(nullptr) 2891{ 2892 const size_t __n = __il.size(); 2893 if (__n) 2894 { 2895 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2896#ifndef _LIBCPP_NO_EXCEPTIONS 2897 try 2898 { 2899#endif // _LIBCPP_NO_EXCEPTIONS 2900 size_t __n_left = __n; 2901 for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) 2902 ::new ((void*)__end_) value_type(*__p); 2903#ifndef _LIBCPP_NO_EXCEPTIONS 2904 } 2905 catch (...) 2906 { 2907 __clear(__n); 2908 throw; 2909 } 2910#endif // _LIBCPP_NO_EXCEPTIONS 2911 } 2912} 2913 2914#endif // _LIBCPP_CXX03_LANG 2915 2916template <class _Tp> 2917valarray<_Tp>::valarray(const slice_array<value_type>& __sa) 2918 : __begin_(nullptr), 2919 __end_(nullptr) 2920{ 2921 const size_t __n = __sa.__size_; 2922 if (__n) 2923 { 2924 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2925#ifndef _LIBCPP_NO_EXCEPTIONS 2926 try 2927 { 2928#endif // _LIBCPP_NO_EXCEPTIONS 2929 size_t __n_left = __n; 2930 for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) 2931 ::new ((void*)__end_) value_type(*__p); 2932#ifndef _LIBCPP_NO_EXCEPTIONS 2933 } 2934 catch (...) 2935 { 2936 __clear(__n); 2937 throw; 2938 } 2939#endif // _LIBCPP_NO_EXCEPTIONS 2940 } 2941} 2942 2943template <class _Tp> 2944valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) 2945 : __begin_(nullptr), 2946 __end_(nullptr) 2947{ 2948 const size_t __n = __ga.__1d_.size(); 2949 if (__n) 2950 { 2951 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2952#ifndef _LIBCPP_NO_EXCEPTIONS 2953 try 2954 { 2955#endif // _LIBCPP_NO_EXCEPTIONS 2956 typedef const size_t* _Ip; 2957 const value_type* __s = __ga.__vp_; 2958 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; 2959 __i != __e; ++__i, ++__end_) 2960 ::new ((void*)__end_) value_type(__s[*__i]); 2961#ifndef _LIBCPP_NO_EXCEPTIONS 2962 } 2963 catch (...) 2964 { 2965 __clear(__n); 2966 throw; 2967 } 2968#endif // _LIBCPP_NO_EXCEPTIONS 2969 } 2970} 2971 2972template <class _Tp> 2973valarray<_Tp>::valarray(const mask_array<value_type>& __ma) 2974 : __begin_(nullptr), 2975 __end_(nullptr) 2976{ 2977 const size_t __n = __ma.__1d_.size(); 2978 if (__n) 2979 { 2980 __begin_ = __end_ = allocator<value_type>().allocate(__n); 2981#ifndef _LIBCPP_NO_EXCEPTIONS 2982 try 2983 { 2984#endif // _LIBCPP_NO_EXCEPTIONS 2985 typedef const size_t* _Ip; 2986 const value_type* __s = __ma.__vp_; 2987 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; 2988 __i != __e; ++__i, ++__end_) 2989 ::new ((void*)__end_) value_type(__s[*__i]); 2990#ifndef _LIBCPP_NO_EXCEPTIONS 2991 } 2992 catch (...) 2993 { 2994 __clear(__n); 2995 throw; 2996 } 2997#endif // _LIBCPP_NO_EXCEPTIONS 2998 } 2999} 3000 3001template <class _Tp> 3002valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) 3003 : __begin_(nullptr), 3004 __end_(nullptr) 3005{ 3006 const size_t __n = __ia.__1d_.size(); 3007 if (__n) 3008 { 3009 __begin_ = __end_ = allocator<value_type>().allocate(__n); 3010#ifndef _LIBCPP_NO_EXCEPTIONS 3011 try 3012 { 3013#endif // _LIBCPP_NO_EXCEPTIONS 3014 typedef const size_t* _Ip; 3015 const value_type* __s = __ia.__vp_; 3016 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; 3017 __i != __e; ++__i, ++__end_) 3018 ::new ((void*)__end_) value_type(__s[*__i]); 3019#ifndef _LIBCPP_NO_EXCEPTIONS 3020 } 3021 catch (...) 3022 { 3023 __clear(__n); 3024 throw; 3025 } 3026#endif // _LIBCPP_NO_EXCEPTIONS 3027 } 3028} 3029 3030template <class _Tp> 3031inline 3032valarray<_Tp>::~valarray() 3033{ 3034 __clear(size()); 3035} 3036 3037template <class _Tp> 3038valarray<_Tp>& 3039valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) 3040{ 3041 size_t __n = __l - __f; 3042 if (size() != __n) 3043 { 3044 __clear(size()); 3045 __begin_ = allocator<value_type>().allocate(__n); 3046 __end_ = __begin_ + __n; 3047 _VSTD::uninitialized_copy(__f, __l, __begin_); 3048 } else { 3049 _VSTD::copy(__f, __l, __begin_); 3050 } 3051 return *this; 3052} 3053 3054template <class _Tp> 3055valarray<_Tp>& 3056valarray<_Tp>::operator=(const valarray& __v) 3057{ 3058 if (this != _VSTD::addressof(__v)) 3059 return __assign_range(__v.__begin_, __v.__end_); 3060 return *this; 3061} 3062 3063#ifndef _LIBCPP_CXX03_LANG 3064 3065template <class _Tp> 3066inline 3067valarray<_Tp>& 3068valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT 3069{ 3070 __clear(size()); 3071 __begin_ = __v.__begin_; 3072 __end_ = __v.__end_; 3073 __v.__begin_ = nullptr; 3074 __v.__end_ = nullptr; 3075 return *this; 3076} 3077 3078template <class _Tp> 3079inline 3080valarray<_Tp>& 3081valarray<_Tp>::operator=(initializer_list<value_type> __il) 3082{ 3083 return __assign_range(__il.begin(), __il.end()); 3084} 3085 3086#endif // _LIBCPP_CXX03_LANG 3087 3088template <class _Tp> 3089inline 3090valarray<_Tp>& 3091valarray<_Tp>::operator=(const value_type& __x) 3092{ 3093 _VSTD::fill(__begin_, __end_, __x); 3094 return *this; 3095} 3096 3097template <class _Tp> 3098inline 3099valarray<_Tp>& 3100valarray<_Tp>::operator=(const slice_array<value_type>& __sa) 3101{ 3102 value_type* __t = __begin_; 3103 const value_type* __s = __sa.__vp_; 3104 for (size_t __n = __sa.__size_; __n; --__n, __s += __sa.__stride_, ++__t) 3105 *__t = *__s; 3106 return *this; 3107} 3108 3109template <class _Tp> 3110inline 3111valarray<_Tp>& 3112valarray<_Tp>::operator=(const gslice_array<value_type>& __ga) 3113{ 3114 typedef const size_t* _Ip; 3115 value_type* __t = __begin_; 3116 const value_type* __s = __ga.__vp_; 3117 for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; 3118 __i != __e; ++__i, ++__t) 3119 *__t = __s[*__i]; 3120 return *this; 3121} 3122 3123template <class _Tp> 3124inline 3125valarray<_Tp>& 3126valarray<_Tp>::operator=(const mask_array<value_type>& __ma) 3127{ 3128 typedef const size_t* _Ip; 3129 value_type* __t = __begin_; 3130 const value_type* __s = __ma.__vp_; 3131 for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; 3132 __i != __e; ++__i, ++__t) 3133 *__t = __s[*__i]; 3134 return *this; 3135} 3136 3137template <class _Tp> 3138inline 3139valarray<_Tp>& 3140valarray<_Tp>::operator=(const indirect_array<value_type>& __ia) 3141{ 3142 typedef const size_t* _Ip; 3143 value_type* __t = __begin_; 3144 const value_type* __s = __ia.__vp_; 3145 for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; 3146 __i != __e; ++__i, ++__t) 3147 *__t = __s[*__i]; 3148 return *this; 3149} 3150 3151template <class _Tp> 3152template <class _ValExpr> 3153inline 3154valarray<_Tp>& 3155valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) 3156{ 3157 size_t __n = __v.size(); 3158 if (size() != __n) 3159 resize(__n); 3160 value_type* __t = __begin_; 3161 for (size_t __i = 0; __i != __n; ++__t, ++__i) 3162 *__t = __result_type(__v[__i]); 3163 return *this; 3164} 3165 3166template <class _Tp> 3167inline 3168__val_expr<__slice_expr<const valarray<_Tp>&> > 3169valarray<_Tp>::operator[](slice __s) const 3170{ 3171 return __val_expr<__slice_expr<const valarray&> >(__slice_expr<const valarray&>(__s, *this)); 3172} 3173 3174template <class _Tp> 3175inline 3176slice_array<_Tp> 3177valarray<_Tp>::operator[](slice __s) 3178{ 3179 return slice_array<value_type>(__s, *this); 3180} 3181 3182template <class _Tp> 3183inline 3184__val_expr<__indirect_expr<const valarray<_Tp>&> > 3185valarray<_Tp>::operator[](const gslice& __gs) const 3186{ 3187 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__gs.__1d_, *this)); 3188} 3189 3190template <class _Tp> 3191inline 3192gslice_array<_Tp> 3193valarray<_Tp>::operator[](const gslice& __gs) 3194{ 3195 return gslice_array<value_type>(__gs, *this); 3196} 3197 3198#ifndef _LIBCPP_CXX03_LANG 3199 3200template <class _Tp> 3201inline 3202__val_expr<__indirect_expr<const valarray<_Tp>&> > 3203valarray<_Tp>::operator[](gslice&& __gs) const 3204{ 3205 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this)); 3206} 3207 3208template <class _Tp> 3209inline 3210gslice_array<_Tp> 3211valarray<_Tp>::operator[](gslice&& __gs) 3212{ 3213 return gslice_array<value_type>(move(__gs), *this); 3214} 3215 3216#endif // _LIBCPP_CXX03_LANG 3217 3218template <class _Tp> 3219inline 3220__val_expr<__mask_expr<const valarray<_Tp>&> > 3221valarray<_Tp>::operator[](const valarray<bool>& __vb) const 3222{ 3223 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(__vb, *this)); 3224} 3225 3226template <class _Tp> 3227inline 3228mask_array<_Tp> 3229valarray<_Tp>::operator[](const valarray<bool>& __vb) 3230{ 3231 return mask_array<value_type>(__vb, *this); 3232} 3233 3234#ifndef _LIBCPP_CXX03_LANG 3235 3236template <class _Tp> 3237inline 3238__val_expr<__mask_expr<const valarray<_Tp>&> > 3239valarray<_Tp>::operator[](valarray<bool>&& __vb) const 3240{ 3241 return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this)); 3242} 3243 3244template <class _Tp> 3245inline 3246mask_array<_Tp> 3247valarray<_Tp>::operator[](valarray<bool>&& __vb) 3248{ 3249 return mask_array<value_type>(move(__vb), *this); 3250} 3251 3252#endif // _LIBCPP_CXX03_LANG 3253 3254template <class _Tp> 3255inline 3256__val_expr<__indirect_expr<const valarray<_Tp>&> > 3257valarray<_Tp>::operator[](const valarray<size_t>& __vs) const 3258{ 3259 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(__vs, *this)); 3260} 3261 3262template <class _Tp> 3263inline 3264indirect_array<_Tp> 3265valarray<_Tp>::operator[](const valarray<size_t>& __vs) 3266{ 3267 return indirect_array<value_type>(__vs, *this); 3268} 3269 3270#ifndef _LIBCPP_CXX03_LANG 3271 3272template <class _Tp> 3273inline 3274__val_expr<__indirect_expr<const valarray<_Tp>&> > 3275valarray<_Tp>::operator[](valarray<size_t>&& __vs) const 3276{ 3277 return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this)); 3278} 3279 3280template <class _Tp> 3281inline 3282indirect_array<_Tp> 3283valarray<_Tp>::operator[](valarray<size_t>&& __vs) 3284{ 3285 return indirect_array<value_type>(move(__vs), *this); 3286} 3287 3288#endif // _LIBCPP_CXX03_LANG 3289 3290template <class _Tp> 3291valarray<_Tp> 3292valarray<_Tp>::operator+() const 3293{ 3294 valarray<value_type> __r; 3295 size_t __n = size(); 3296 if (__n) 3297 { 3298 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3299 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3300 ::new ((void*)__r.__end_) value_type(+*__p); 3301 } 3302 return __r; 3303} 3304 3305template <class _Tp> 3306valarray<_Tp> 3307valarray<_Tp>::operator-() const 3308{ 3309 valarray<value_type> __r; 3310 size_t __n = size(); 3311 if (__n) 3312 { 3313 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3314 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3315 ::new ((void*)__r.__end_) value_type(-*__p); 3316 } 3317 return __r; 3318} 3319 3320template <class _Tp> 3321valarray<_Tp> 3322valarray<_Tp>::operator~() const 3323{ 3324 valarray<value_type> __r; 3325 size_t __n = size(); 3326 if (__n) 3327 { 3328 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3329 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3330 ::new ((void*)__r.__end_) value_type(~*__p); 3331 } 3332 return __r; 3333} 3334 3335template <class _Tp> 3336valarray<bool> 3337valarray<_Tp>::operator!() const 3338{ 3339 valarray<bool> __r; 3340 size_t __n = size(); 3341 if (__n) 3342 { 3343 __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n); 3344 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3345 ::new ((void*)__r.__end_) bool(!*__p); 3346 } 3347 return __r; 3348} 3349 3350template <class _Tp> 3351inline 3352valarray<_Tp>& 3353valarray<_Tp>::operator*=(const value_type& __x) 3354{ 3355 for (value_type* __p = __begin_; __p != __end_; ++__p) 3356 *__p *= __x; 3357 return *this; 3358} 3359 3360template <class _Tp> 3361inline 3362valarray<_Tp>& 3363valarray<_Tp>::operator/=(const value_type& __x) 3364{ 3365 for (value_type* __p = __begin_; __p != __end_; ++__p) 3366 *__p /= __x; 3367 return *this; 3368} 3369 3370template <class _Tp> 3371inline 3372valarray<_Tp>& 3373valarray<_Tp>::operator%=(const value_type& __x) 3374{ 3375 for (value_type* __p = __begin_; __p != __end_; ++__p) 3376 *__p %= __x; 3377 return *this; 3378} 3379 3380template <class _Tp> 3381inline 3382valarray<_Tp>& 3383valarray<_Tp>::operator+=(const value_type& __x) 3384{ 3385 for (value_type* __p = __begin_; __p != __end_; ++__p) 3386 *__p += __x; 3387 return *this; 3388} 3389 3390template <class _Tp> 3391inline 3392valarray<_Tp>& 3393valarray<_Tp>::operator-=(const value_type& __x) 3394{ 3395 for (value_type* __p = __begin_; __p != __end_; ++__p) 3396 *__p -= __x; 3397 return *this; 3398} 3399 3400template <class _Tp> 3401inline 3402valarray<_Tp>& 3403valarray<_Tp>::operator^=(const value_type& __x) 3404{ 3405 for (value_type* __p = __begin_; __p != __end_; ++__p) 3406 *__p ^= __x; 3407 return *this; 3408} 3409 3410template <class _Tp> 3411inline 3412valarray<_Tp>& 3413valarray<_Tp>::operator&=(const value_type& __x) 3414{ 3415 for (value_type* __p = __begin_; __p != __end_; ++__p) 3416 *__p &= __x; 3417 return *this; 3418} 3419 3420template <class _Tp> 3421inline 3422valarray<_Tp>& 3423valarray<_Tp>::operator|=(const value_type& __x) 3424{ 3425 for (value_type* __p = __begin_; __p != __end_; ++__p) 3426 *__p |= __x; 3427 return *this; 3428} 3429 3430template <class _Tp> 3431inline 3432valarray<_Tp>& 3433valarray<_Tp>::operator<<=(const value_type& __x) 3434{ 3435 for (value_type* __p = __begin_; __p != __end_; ++__p) 3436 *__p <<= __x; 3437 return *this; 3438} 3439 3440template <class _Tp> 3441inline 3442valarray<_Tp>& 3443valarray<_Tp>::operator>>=(const value_type& __x) 3444{ 3445 for (value_type* __p = __begin_; __p != __end_; ++__p) 3446 *__p >>= __x; 3447 return *this; 3448} 3449 3450template <class _Tp> 3451template <class _Expr> 3452inline 3453typename enable_if 3454< 3455 __is_val_expr<_Expr>::value, 3456 valarray<_Tp>& 3457>::type 3458valarray<_Tp>::operator*=(const _Expr& __v) 3459{ 3460 size_t __i = 0; 3461 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3462 *__t *= __v[__i]; 3463 return *this; 3464} 3465 3466template <class _Tp> 3467template <class _Expr> 3468inline 3469typename enable_if 3470< 3471 __is_val_expr<_Expr>::value, 3472 valarray<_Tp>& 3473>::type 3474valarray<_Tp>::operator/=(const _Expr& __v) 3475{ 3476 size_t __i = 0; 3477 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3478 *__t /= __v[__i]; 3479 return *this; 3480} 3481 3482template <class _Tp> 3483template <class _Expr> 3484inline 3485typename enable_if 3486< 3487 __is_val_expr<_Expr>::value, 3488 valarray<_Tp>& 3489>::type 3490valarray<_Tp>::operator%=(const _Expr& __v) 3491{ 3492 size_t __i = 0; 3493 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3494 *__t %= __v[__i]; 3495 return *this; 3496} 3497 3498template <class _Tp> 3499template <class _Expr> 3500inline 3501typename enable_if 3502< 3503 __is_val_expr<_Expr>::value, 3504 valarray<_Tp>& 3505>::type 3506valarray<_Tp>::operator+=(const _Expr& __v) 3507{ 3508 size_t __i = 0; 3509 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3510 *__t += __v[__i]; 3511 return *this; 3512} 3513 3514template <class _Tp> 3515template <class _Expr> 3516inline 3517typename enable_if 3518< 3519 __is_val_expr<_Expr>::value, 3520 valarray<_Tp>& 3521>::type 3522valarray<_Tp>::operator-=(const _Expr& __v) 3523{ 3524 size_t __i = 0; 3525 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3526 *__t -= __v[__i]; 3527 return *this; 3528} 3529 3530template <class _Tp> 3531template <class _Expr> 3532inline 3533typename enable_if 3534< 3535 __is_val_expr<_Expr>::value, 3536 valarray<_Tp>& 3537>::type 3538valarray<_Tp>::operator^=(const _Expr& __v) 3539{ 3540 size_t __i = 0; 3541 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3542 *__t ^= __v[__i]; 3543 return *this; 3544} 3545 3546template <class _Tp> 3547template <class _Expr> 3548inline 3549typename enable_if 3550< 3551 __is_val_expr<_Expr>::value, 3552 valarray<_Tp>& 3553>::type 3554valarray<_Tp>::operator|=(const _Expr& __v) 3555{ 3556 size_t __i = 0; 3557 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3558 *__t |= __v[__i]; 3559 return *this; 3560} 3561 3562template <class _Tp> 3563template <class _Expr> 3564inline 3565typename enable_if 3566< 3567 __is_val_expr<_Expr>::value, 3568 valarray<_Tp>& 3569>::type 3570valarray<_Tp>::operator&=(const _Expr& __v) 3571{ 3572 size_t __i = 0; 3573 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3574 *__t &= __v[__i]; 3575 return *this; 3576} 3577 3578template <class _Tp> 3579template <class _Expr> 3580inline 3581typename enable_if 3582< 3583 __is_val_expr<_Expr>::value, 3584 valarray<_Tp>& 3585>::type 3586valarray<_Tp>::operator<<=(const _Expr& __v) 3587{ 3588 size_t __i = 0; 3589 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3590 *__t <<= __v[__i]; 3591 return *this; 3592} 3593 3594template <class _Tp> 3595template <class _Expr> 3596inline 3597typename enable_if 3598< 3599 __is_val_expr<_Expr>::value, 3600 valarray<_Tp>& 3601>::type 3602valarray<_Tp>::operator>>=(const _Expr& __v) 3603{ 3604 size_t __i = 0; 3605 for (value_type* __t = __begin_; __t != __end_ ; ++__t, ++__i) 3606 *__t >>= __v[__i]; 3607 return *this; 3608} 3609 3610template <class _Tp> 3611inline 3612void 3613valarray<_Tp>::swap(valarray& __v) _NOEXCEPT 3614{ 3615 _VSTD::swap(__begin_, __v.__begin_); 3616 _VSTD::swap(__end_, __v.__end_); 3617} 3618 3619template <class _Tp> 3620inline 3621_Tp 3622valarray<_Tp>::sum() const 3623{ 3624 if (__begin_ == __end_) 3625 return value_type(); 3626 const value_type* __p = __begin_; 3627 _Tp __r = *__p; 3628 for (++__p; __p != __end_; ++__p) 3629 __r += *__p; 3630 return __r; 3631} 3632 3633template <class _Tp> 3634inline 3635_Tp 3636valarray<_Tp>::min() const 3637{ 3638 if (__begin_ == __end_) 3639 return value_type(); 3640 return *_VSTD::min_element(__begin_, __end_); 3641} 3642 3643template <class _Tp> 3644inline 3645_Tp 3646valarray<_Tp>::max() const 3647{ 3648 if (__begin_ == __end_) 3649 return value_type(); 3650 return *_VSTD::max_element(__begin_, __end_); 3651} 3652 3653template <class _Tp> 3654valarray<_Tp> 3655valarray<_Tp>::shift(int __i) const 3656{ 3657 valarray<value_type> __r; 3658 size_t __n = size(); 3659 if (__n) 3660 { 3661 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3662 const value_type* __sb; 3663 value_type* __tb; 3664 value_type* __te; 3665 if (__i >= 0) 3666 { 3667 __i = _VSTD::min(__i, static_cast<int>(__n)); 3668 __sb = __begin_ + __i; 3669 __tb = __r.__begin_; 3670 __te = __r.__begin_ + (__n - __i); 3671 } 3672 else 3673 { 3674 __i = _VSTD::min(-__i, static_cast<int>(__n)); 3675 __sb = __begin_; 3676 __tb = __r.__begin_ + __i; 3677 __te = __r.__begin_ + __n; 3678 } 3679 for (; __r.__end_ != __tb; ++__r.__end_) 3680 ::new ((void*)__r.__end_) value_type(); 3681 for (; __r.__end_ != __te; ++__r.__end_, ++__sb) 3682 ::new ((void*)__r.__end_) value_type(*__sb); 3683 for (__te = __r.__begin_ + __n; __r.__end_ != __te; ++__r.__end_) 3684 ::new ((void*)__r.__end_) value_type(); 3685 } 3686 return __r; 3687} 3688 3689template <class _Tp> 3690valarray<_Tp> 3691valarray<_Tp>::cshift(int __i) const 3692{ 3693 valarray<value_type> __r; 3694 size_t __n = size(); 3695 if (__n) 3696 { 3697 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3698 __i %= static_cast<int>(__n); 3699 const value_type* __m = __i >= 0 ? __begin_ + __i : __end_ + __i; 3700 for (const value_type* __s = __m; __s != __end_; ++__r.__end_, ++__s) 3701 ::new ((void*)__r.__end_) value_type(*__s); 3702 for (const value_type* __s = __begin_; __s != __m; ++__r.__end_, ++__s) 3703 ::new ((void*)__r.__end_) value_type(*__s); 3704 } 3705 return __r; 3706} 3707 3708template <class _Tp> 3709valarray<_Tp> 3710valarray<_Tp>::apply(value_type __f(value_type)) const 3711{ 3712 valarray<value_type> __r; 3713 size_t __n = size(); 3714 if (__n) 3715 { 3716 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3717 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3718 ::new ((void*)__r.__end_) value_type(__f(*__p)); 3719 } 3720 return __r; 3721} 3722 3723template <class _Tp> 3724valarray<_Tp> 3725valarray<_Tp>::apply(value_type __f(const value_type&)) const 3726{ 3727 valarray<value_type> __r; 3728 size_t __n = size(); 3729 if (__n) 3730 { 3731 __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); 3732 for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) 3733 ::new ((void*)__r.__end_) value_type(__f(*__p)); 3734 } 3735 return __r; 3736} 3737 3738template <class _Tp> 3739inline 3740void valarray<_Tp>::__clear(size_t __capacity) 3741{ 3742 if (__begin_ != nullptr) 3743 { 3744 while (__end_ != __begin_) 3745 (--__end_)->~value_type(); 3746 allocator<value_type>().deallocate(__begin_, __capacity); 3747 __begin_ = __end_ = nullptr; 3748 } 3749} 3750 3751template <class _Tp> 3752void 3753valarray<_Tp>::resize(size_t __n, value_type __x) 3754{ 3755 __clear(size()); 3756 if (__n) 3757 { 3758 __begin_ = __end_ = allocator<value_type>().allocate(__n); 3759#ifndef _LIBCPP_NO_EXCEPTIONS 3760 try 3761 { 3762#endif // _LIBCPP_NO_EXCEPTIONS 3763 for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) 3764 ::new ((void*)__end_) value_type(__x); 3765#ifndef _LIBCPP_NO_EXCEPTIONS 3766 } 3767 catch (...) 3768 { 3769 __clear(__n); 3770 throw; 3771 } 3772#endif // _LIBCPP_NO_EXCEPTIONS 3773 } 3774} 3775 3776template<class _Tp> 3777inline _LIBCPP_INLINE_VISIBILITY 3778void 3779swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT 3780{ 3781 __x.swap(__y); 3782} 3783 3784template<class _Expr1, class _Expr2> 3785inline _LIBCPP_INLINE_VISIBILITY 3786typename enable_if 3787< 3788 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 3789 __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > 3790>::type 3791operator*(const _Expr1& __x, const _Expr2& __y) 3792{ 3793 typedef typename _Expr1::value_type value_type; 3794 typedef _BinaryOp<multiplies<value_type>, _Expr1, _Expr2> _Op; 3795 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); 3796} 3797 3798template<class _Expr> 3799inline _LIBCPP_INLINE_VISIBILITY 3800typename enable_if 3801< 3802 __is_val_expr<_Expr>::value, 3803 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, 3804 _Expr, __scalar_expr<typename _Expr::value_type> > > 3805>::type 3806operator*(const _Expr& __x, const typename _Expr::value_type& __y) 3807{ 3808 typedef typename _Expr::value_type value_type; 3809 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3810 return __val_expr<_Op>(_Op(multiplies<value_type>(), 3811 __x, __scalar_expr<value_type>(__y, __x.size()))); 3812} 3813 3814template<class _Expr> 3815inline _LIBCPP_INLINE_VISIBILITY 3816typename enable_if 3817< 3818 __is_val_expr<_Expr>::value, 3819 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, 3820 __scalar_expr<typename _Expr::value_type>, _Expr> > 3821>::type 3822operator*(const typename _Expr::value_type& __x, const _Expr& __y) 3823{ 3824 typedef typename _Expr::value_type value_type; 3825 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3826 return __val_expr<_Op>(_Op(multiplies<value_type>(), 3827 __scalar_expr<value_type>(__x, __y.size()), __y)); 3828} 3829 3830template<class _Expr1, class _Expr2> 3831inline _LIBCPP_INLINE_VISIBILITY 3832typename enable_if 3833< 3834 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 3835 __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > 3836>::type 3837operator/(const _Expr1& __x, const _Expr2& __y) 3838{ 3839 typedef typename _Expr1::value_type value_type; 3840 typedef _BinaryOp<divides<value_type>, _Expr1, _Expr2> _Op; 3841 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); 3842} 3843 3844template<class _Expr> 3845inline _LIBCPP_INLINE_VISIBILITY 3846typename enable_if 3847< 3848 __is_val_expr<_Expr>::value, 3849 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, 3850 _Expr, __scalar_expr<typename _Expr::value_type> > > 3851>::type 3852operator/(const _Expr& __x, const typename _Expr::value_type& __y) 3853{ 3854 typedef typename _Expr::value_type value_type; 3855 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3856 return __val_expr<_Op>(_Op(divides<value_type>(), 3857 __x, __scalar_expr<value_type>(__y, __x.size()))); 3858} 3859 3860template<class _Expr> 3861inline _LIBCPP_INLINE_VISIBILITY 3862typename enable_if 3863< 3864 __is_val_expr<_Expr>::value, 3865 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, 3866 __scalar_expr<typename _Expr::value_type>, _Expr> > 3867>::type 3868operator/(const typename _Expr::value_type& __x, const _Expr& __y) 3869{ 3870 typedef typename _Expr::value_type value_type; 3871 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3872 return __val_expr<_Op>(_Op(divides<value_type>(), 3873 __scalar_expr<value_type>(__x, __y.size()), __y)); 3874} 3875 3876template<class _Expr1, class _Expr2> 3877inline _LIBCPP_INLINE_VISIBILITY 3878typename enable_if 3879< 3880 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 3881 __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3882>::type 3883operator%(const _Expr1& __x, const _Expr2& __y) 3884{ 3885 typedef typename _Expr1::value_type value_type; 3886 typedef _BinaryOp<modulus<value_type>, _Expr1, _Expr2> _Op; 3887 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); 3888} 3889 3890template<class _Expr> 3891inline _LIBCPP_INLINE_VISIBILITY 3892typename enable_if 3893< 3894 __is_val_expr<_Expr>::value, 3895 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, 3896 _Expr, __scalar_expr<typename _Expr::value_type> > > 3897>::type 3898operator%(const _Expr& __x, const typename _Expr::value_type& __y) 3899{ 3900 typedef typename _Expr::value_type value_type; 3901 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3902 return __val_expr<_Op>(_Op(modulus<value_type>(), 3903 __x, __scalar_expr<value_type>(__y, __x.size()))); 3904} 3905 3906template<class _Expr> 3907inline _LIBCPP_INLINE_VISIBILITY 3908typename enable_if 3909< 3910 __is_val_expr<_Expr>::value, 3911 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, 3912 __scalar_expr<typename _Expr::value_type>, _Expr> > 3913>::type 3914operator%(const typename _Expr::value_type& __x, const _Expr& __y) 3915{ 3916 typedef typename _Expr::value_type value_type; 3917 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3918 return __val_expr<_Op>(_Op(modulus<value_type>(), 3919 __scalar_expr<value_type>(__x, __y.size()), __y)); 3920} 3921 3922template<class _Expr1, class _Expr2> 3923inline _LIBCPP_INLINE_VISIBILITY 3924typename enable_if 3925< 3926 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 3927 __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3928>::type 3929operator+(const _Expr1& __x, const _Expr2& __y) 3930{ 3931 typedef typename _Expr1::value_type value_type; 3932 typedef _BinaryOp<plus<value_type>, _Expr1, _Expr2> _Op; 3933 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); 3934} 3935 3936template<class _Expr> 3937inline _LIBCPP_INLINE_VISIBILITY 3938typename enable_if 3939< 3940 __is_val_expr<_Expr>::value, 3941 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, 3942 _Expr, __scalar_expr<typename _Expr::value_type> > > 3943>::type 3944operator+(const _Expr& __x, const typename _Expr::value_type& __y) 3945{ 3946 typedef typename _Expr::value_type value_type; 3947 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3948 return __val_expr<_Op>(_Op(plus<value_type>(), 3949 __x, __scalar_expr<value_type>(__y, __x.size()))); 3950} 3951 3952template<class _Expr> 3953inline _LIBCPP_INLINE_VISIBILITY 3954typename enable_if 3955< 3956 __is_val_expr<_Expr>::value, 3957 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, 3958 __scalar_expr<typename _Expr::value_type>, _Expr> > 3959>::type 3960operator+(const typename _Expr::value_type& __x, const _Expr& __y) 3961{ 3962 typedef typename _Expr::value_type value_type; 3963 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 3964 return __val_expr<_Op>(_Op(plus<value_type>(), 3965 __scalar_expr<value_type>(__x, __y.size()), __y)); 3966} 3967 3968template<class _Expr1, class _Expr2> 3969inline _LIBCPP_INLINE_VISIBILITY 3970typename enable_if 3971< 3972 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 3973 __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > 3974>::type 3975operator-(const _Expr1& __x, const _Expr2& __y) 3976{ 3977 typedef typename _Expr1::value_type value_type; 3978 typedef _BinaryOp<minus<value_type>, _Expr1, _Expr2> _Op; 3979 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); 3980} 3981 3982template<class _Expr> 3983inline _LIBCPP_INLINE_VISIBILITY 3984typename enable_if 3985< 3986 __is_val_expr<_Expr>::value, 3987 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, 3988 _Expr, __scalar_expr<typename _Expr::value_type> > > 3989>::type 3990operator-(const _Expr& __x, const typename _Expr::value_type& __y) 3991{ 3992 typedef typename _Expr::value_type value_type; 3993 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op; 3994 return __val_expr<_Op>(_Op(minus<value_type>(), 3995 __x, __scalar_expr<value_type>(__y, __x.size()))); 3996} 3997 3998template<class _Expr> 3999inline _LIBCPP_INLINE_VISIBILITY 4000typename enable_if 4001< 4002 __is_val_expr<_Expr>::value, 4003 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, 4004 __scalar_expr<typename _Expr::value_type>, _Expr> > 4005>::type 4006operator-(const typename _Expr::value_type& __x, const _Expr& __y) 4007{ 4008 typedef typename _Expr::value_type value_type; 4009 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4010 return __val_expr<_Op>(_Op(minus<value_type>(), 4011 __scalar_expr<value_type>(__x, __y.size()), __y)); 4012} 4013 4014template<class _Expr1, class _Expr2> 4015inline _LIBCPP_INLINE_VISIBILITY 4016typename enable_if 4017< 4018 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4019 __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > 4020>::type 4021operator^(const _Expr1& __x, const _Expr2& __y) 4022{ 4023 typedef typename _Expr1::value_type value_type; 4024 typedef _BinaryOp<bit_xor<value_type>, _Expr1, _Expr2> _Op; 4025 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); 4026} 4027 4028template<class _Expr> 4029inline _LIBCPP_INLINE_VISIBILITY 4030typename enable_if 4031< 4032 __is_val_expr<_Expr>::value, 4033 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, 4034 _Expr, __scalar_expr<typename _Expr::value_type> > > 4035>::type 4036operator^(const _Expr& __x, const typename _Expr::value_type& __y) 4037{ 4038 typedef typename _Expr::value_type value_type; 4039 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4040 return __val_expr<_Op>(_Op(bit_xor<value_type>(), 4041 __x, __scalar_expr<value_type>(__y, __x.size()))); 4042} 4043 4044template<class _Expr> 4045inline _LIBCPP_INLINE_VISIBILITY 4046typename enable_if 4047< 4048 __is_val_expr<_Expr>::value, 4049 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, 4050 __scalar_expr<typename _Expr::value_type>, _Expr> > 4051>::type 4052operator^(const typename _Expr::value_type& __x, const _Expr& __y) 4053{ 4054 typedef typename _Expr::value_type value_type; 4055 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4056 return __val_expr<_Op>(_Op(bit_xor<value_type>(), 4057 __scalar_expr<value_type>(__x, __y.size()), __y)); 4058} 4059 4060template<class _Expr1, class _Expr2> 4061inline _LIBCPP_INLINE_VISIBILITY 4062typename enable_if 4063< 4064 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4065 __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > 4066>::type 4067operator&(const _Expr1& __x, const _Expr2& __y) 4068{ 4069 typedef typename _Expr1::value_type value_type; 4070 typedef _BinaryOp<bit_and<value_type>, _Expr1, _Expr2> _Op; 4071 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); 4072} 4073 4074template<class _Expr> 4075inline _LIBCPP_INLINE_VISIBILITY 4076typename enable_if 4077< 4078 __is_val_expr<_Expr>::value, 4079 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, 4080 _Expr, __scalar_expr<typename _Expr::value_type> > > 4081>::type 4082operator&(const _Expr& __x, const typename _Expr::value_type& __y) 4083{ 4084 typedef typename _Expr::value_type value_type; 4085 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4086 return __val_expr<_Op>(_Op(bit_and<value_type>(), 4087 __x, __scalar_expr<value_type>(__y, __x.size()))); 4088} 4089 4090template<class _Expr> 4091inline _LIBCPP_INLINE_VISIBILITY 4092typename enable_if 4093< 4094 __is_val_expr<_Expr>::value, 4095 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, 4096 __scalar_expr<typename _Expr::value_type>, _Expr> > 4097>::type 4098operator&(const typename _Expr::value_type& __x, const _Expr& __y) 4099{ 4100 typedef typename _Expr::value_type value_type; 4101 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4102 return __val_expr<_Op>(_Op(bit_and<value_type>(), 4103 __scalar_expr<value_type>(__x, __y.size()), __y)); 4104} 4105 4106template<class _Expr1, class _Expr2> 4107inline _LIBCPP_INLINE_VISIBILITY 4108typename enable_if 4109< 4110 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4111 __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > 4112>::type 4113operator|(const _Expr1& __x, const _Expr2& __y) 4114{ 4115 typedef typename _Expr1::value_type value_type; 4116 typedef _BinaryOp<bit_or<value_type>, _Expr1, _Expr2> _Op; 4117 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); 4118} 4119 4120template<class _Expr> 4121inline _LIBCPP_INLINE_VISIBILITY 4122typename enable_if 4123< 4124 __is_val_expr<_Expr>::value, 4125 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, 4126 _Expr, __scalar_expr<typename _Expr::value_type> > > 4127>::type 4128operator|(const _Expr& __x, const typename _Expr::value_type& __y) 4129{ 4130 typedef typename _Expr::value_type value_type; 4131 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4132 return __val_expr<_Op>(_Op(bit_or<value_type>(), 4133 __x, __scalar_expr<value_type>(__y, __x.size()))); 4134} 4135 4136template<class _Expr> 4137inline _LIBCPP_INLINE_VISIBILITY 4138typename enable_if 4139< 4140 __is_val_expr<_Expr>::value, 4141 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, 4142 __scalar_expr<typename _Expr::value_type>, _Expr> > 4143>::type 4144operator|(const typename _Expr::value_type& __x, const _Expr& __y) 4145{ 4146 typedef typename _Expr::value_type value_type; 4147 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4148 return __val_expr<_Op>(_Op(bit_or<value_type>(), 4149 __scalar_expr<value_type>(__x, __y.size()), __y)); 4150} 4151 4152template<class _Expr1, class _Expr2> 4153inline _LIBCPP_INLINE_VISIBILITY 4154typename enable_if 4155< 4156 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4157 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > 4158>::type 4159operator<<(const _Expr1& __x, const _Expr2& __y) 4160{ 4161 typedef typename _Expr1::value_type value_type; 4162 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr1, _Expr2> _Op; 4163 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); 4164} 4165 4166template<class _Expr> 4167inline _LIBCPP_INLINE_VISIBILITY 4168typename enable_if 4169< 4170 __is_val_expr<_Expr>::value, 4171 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, 4172 _Expr, __scalar_expr<typename _Expr::value_type> > > 4173>::type 4174operator<<(const _Expr& __x, const typename _Expr::value_type& __y) 4175{ 4176 typedef typename _Expr::value_type value_type; 4177 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4178 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), 4179 __x, __scalar_expr<value_type>(__y, __x.size()))); 4180} 4181 4182template<class _Expr> 4183inline _LIBCPP_INLINE_VISIBILITY 4184typename enable_if 4185< 4186 __is_val_expr<_Expr>::value, 4187 __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, 4188 __scalar_expr<typename _Expr::value_type>, _Expr> > 4189>::type 4190operator<<(const typename _Expr::value_type& __x, const _Expr& __y) 4191{ 4192 typedef typename _Expr::value_type value_type; 4193 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4194 return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), 4195 __scalar_expr<value_type>(__x, __y.size()), __y)); 4196} 4197 4198template<class _Expr1, class _Expr2> 4199inline _LIBCPP_INLINE_VISIBILITY 4200typename enable_if 4201< 4202 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4203 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > 4204>::type 4205operator>>(const _Expr1& __x, const _Expr2& __y) 4206{ 4207 typedef typename _Expr1::value_type value_type; 4208 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr1, _Expr2> _Op; 4209 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); 4210} 4211 4212template<class _Expr> 4213inline _LIBCPP_INLINE_VISIBILITY 4214typename enable_if 4215< 4216 __is_val_expr<_Expr>::value, 4217 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, 4218 _Expr, __scalar_expr<typename _Expr::value_type> > > 4219>::type 4220operator>>(const _Expr& __x, const typename _Expr::value_type& __y) 4221{ 4222 typedef typename _Expr::value_type value_type; 4223 typedef _BinaryOp<__bit_shift_right<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4224 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), 4225 __x, __scalar_expr<value_type>(__y, __x.size()))); 4226} 4227 4228template<class _Expr> 4229inline _LIBCPP_INLINE_VISIBILITY 4230typename enable_if 4231< 4232 __is_val_expr<_Expr>::value, 4233 __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, 4234 __scalar_expr<typename _Expr::value_type>, _Expr> > 4235>::type 4236operator>>(const typename _Expr::value_type& __x, const _Expr& __y) 4237{ 4238 typedef typename _Expr::value_type value_type; 4239 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4240 return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), 4241 __scalar_expr<value_type>(__x, __y.size()), __y)); 4242} 4243 4244template<class _Expr1, class _Expr2> 4245inline _LIBCPP_INLINE_VISIBILITY 4246typename enable_if 4247< 4248 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4249 __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > 4250>::type 4251operator&&(const _Expr1& __x, const _Expr2& __y) 4252{ 4253 typedef typename _Expr1::value_type value_type; 4254 typedef _BinaryOp<logical_and<value_type>, _Expr1, _Expr2> _Op; 4255 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); 4256} 4257 4258template<class _Expr> 4259inline _LIBCPP_INLINE_VISIBILITY 4260typename enable_if 4261< 4262 __is_val_expr<_Expr>::value, 4263 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, 4264 _Expr, __scalar_expr<typename _Expr::value_type> > > 4265>::type 4266operator&&(const _Expr& __x, const typename _Expr::value_type& __y) 4267{ 4268 typedef typename _Expr::value_type value_type; 4269 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4270 return __val_expr<_Op>(_Op(logical_and<value_type>(), 4271 __x, __scalar_expr<value_type>(__y, __x.size()))); 4272} 4273 4274template<class _Expr> 4275inline _LIBCPP_INLINE_VISIBILITY 4276typename enable_if 4277< 4278 __is_val_expr<_Expr>::value, 4279 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, 4280 __scalar_expr<typename _Expr::value_type>, _Expr> > 4281>::type 4282operator&&(const typename _Expr::value_type& __x, const _Expr& __y) 4283{ 4284 typedef typename _Expr::value_type value_type; 4285 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4286 return __val_expr<_Op>(_Op(logical_and<value_type>(), 4287 __scalar_expr<value_type>(__x, __y.size()), __y)); 4288} 4289 4290template<class _Expr1, class _Expr2> 4291inline _LIBCPP_INLINE_VISIBILITY 4292typename enable_if 4293< 4294 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4295 __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > 4296>::type 4297operator||(const _Expr1& __x, const _Expr2& __y) 4298{ 4299 typedef typename _Expr1::value_type value_type; 4300 typedef _BinaryOp<logical_or<value_type>, _Expr1, _Expr2> _Op; 4301 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); 4302} 4303 4304template<class _Expr> 4305inline _LIBCPP_INLINE_VISIBILITY 4306typename enable_if 4307< 4308 __is_val_expr<_Expr>::value, 4309 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, 4310 _Expr, __scalar_expr<typename _Expr::value_type> > > 4311>::type 4312operator||(const _Expr& __x, const typename _Expr::value_type& __y) 4313{ 4314 typedef typename _Expr::value_type value_type; 4315 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4316 return __val_expr<_Op>(_Op(logical_or<value_type>(), 4317 __x, __scalar_expr<value_type>(__y, __x.size()))); 4318} 4319 4320template<class _Expr> 4321inline _LIBCPP_INLINE_VISIBILITY 4322typename enable_if 4323< 4324 __is_val_expr<_Expr>::value, 4325 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, 4326 __scalar_expr<typename _Expr::value_type>, _Expr> > 4327>::type 4328operator||(const typename _Expr::value_type& __x, const _Expr& __y) 4329{ 4330 typedef typename _Expr::value_type value_type; 4331 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4332 return __val_expr<_Op>(_Op(logical_or<value_type>(), 4333 __scalar_expr<value_type>(__x, __y.size()), __y)); 4334} 4335 4336template<class _Expr1, class _Expr2> 4337inline _LIBCPP_INLINE_VISIBILITY 4338typename enable_if 4339< 4340 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4341 __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > 4342>::type 4343operator==(const _Expr1& __x, const _Expr2& __y) 4344{ 4345 typedef typename _Expr1::value_type value_type; 4346 typedef _BinaryOp<equal_to<value_type>, _Expr1, _Expr2> _Op; 4347 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); 4348} 4349 4350template<class _Expr> 4351inline _LIBCPP_INLINE_VISIBILITY 4352typename enable_if 4353< 4354 __is_val_expr<_Expr>::value, 4355 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, 4356 _Expr, __scalar_expr<typename _Expr::value_type> > > 4357>::type 4358operator==(const _Expr& __x, const typename _Expr::value_type& __y) 4359{ 4360 typedef typename _Expr::value_type value_type; 4361 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4362 return __val_expr<_Op>(_Op(equal_to<value_type>(), 4363 __x, __scalar_expr<value_type>(__y, __x.size()))); 4364} 4365 4366template<class _Expr> 4367inline _LIBCPP_INLINE_VISIBILITY 4368typename enable_if 4369< 4370 __is_val_expr<_Expr>::value, 4371 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, 4372 __scalar_expr<typename _Expr::value_type>, _Expr> > 4373>::type 4374operator==(const typename _Expr::value_type& __x, const _Expr& __y) 4375{ 4376 typedef typename _Expr::value_type value_type; 4377 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4378 return __val_expr<_Op>(_Op(equal_to<value_type>(), 4379 __scalar_expr<value_type>(__x, __y.size()), __y)); 4380} 4381 4382template<class _Expr1, class _Expr2> 4383inline _LIBCPP_INLINE_VISIBILITY 4384typename enable_if 4385< 4386 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4387 __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > 4388>::type 4389operator!=(const _Expr1& __x, const _Expr2& __y) 4390{ 4391 typedef typename _Expr1::value_type value_type; 4392 typedef _BinaryOp<not_equal_to<value_type>, _Expr1, _Expr2> _Op; 4393 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); 4394} 4395 4396template<class _Expr> 4397inline _LIBCPP_INLINE_VISIBILITY 4398typename enable_if 4399< 4400 __is_val_expr<_Expr>::value, 4401 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, 4402 _Expr, __scalar_expr<typename _Expr::value_type> > > 4403>::type 4404operator!=(const _Expr& __x, const typename _Expr::value_type& __y) 4405{ 4406 typedef typename _Expr::value_type value_type; 4407 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4408 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), 4409 __x, __scalar_expr<value_type>(__y, __x.size()))); 4410} 4411 4412template<class _Expr> 4413inline _LIBCPP_INLINE_VISIBILITY 4414typename enable_if 4415< 4416 __is_val_expr<_Expr>::value, 4417 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, 4418 __scalar_expr<typename _Expr::value_type>, _Expr> > 4419>::type 4420operator!=(const typename _Expr::value_type& __x, const _Expr& __y) 4421{ 4422 typedef typename _Expr::value_type value_type; 4423 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4424 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), 4425 __scalar_expr<value_type>(__x, __y.size()), __y)); 4426} 4427 4428template<class _Expr1, class _Expr2> 4429inline _LIBCPP_INLINE_VISIBILITY 4430typename enable_if 4431< 4432 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4433 __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > 4434>::type 4435operator<(const _Expr1& __x, const _Expr2& __y) 4436{ 4437 typedef typename _Expr1::value_type value_type; 4438 typedef _BinaryOp<less<value_type>, _Expr1, _Expr2> _Op; 4439 return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); 4440} 4441 4442template<class _Expr> 4443inline _LIBCPP_INLINE_VISIBILITY 4444typename enable_if 4445< 4446 __is_val_expr<_Expr>::value, 4447 __val_expr<_BinaryOp<less<typename _Expr::value_type>, 4448 _Expr, __scalar_expr<typename _Expr::value_type> > > 4449>::type 4450operator<(const _Expr& __x, const typename _Expr::value_type& __y) 4451{ 4452 typedef typename _Expr::value_type value_type; 4453 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4454 return __val_expr<_Op>(_Op(less<value_type>(), 4455 __x, __scalar_expr<value_type>(__y, __x.size()))); 4456} 4457 4458template<class _Expr> 4459inline _LIBCPP_INLINE_VISIBILITY 4460typename enable_if 4461< 4462 __is_val_expr<_Expr>::value, 4463 __val_expr<_BinaryOp<less<typename _Expr::value_type>, 4464 __scalar_expr<typename _Expr::value_type>, _Expr> > 4465>::type 4466operator<(const typename _Expr::value_type& __x, const _Expr& __y) 4467{ 4468 typedef typename _Expr::value_type value_type; 4469 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4470 return __val_expr<_Op>(_Op(less<value_type>(), 4471 __scalar_expr<value_type>(__x, __y.size()), __y)); 4472} 4473 4474template<class _Expr1, class _Expr2> 4475inline _LIBCPP_INLINE_VISIBILITY 4476typename enable_if 4477< 4478 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4479 __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > 4480>::type 4481operator>(const _Expr1& __x, const _Expr2& __y) 4482{ 4483 typedef typename _Expr1::value_type value_type; 4484 typedef _BinaryOp<greater<value_type>, _Expr1, _Expr2> _Op; 4485 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); 4486} 4487 4488template<class _Expr> 4489inline _LIBCPP_INLINE_VISIBILITY 4490typename enable_if 4491< 4492 __is_val_expr<_Expr>::value, 4493 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, 4494 _Expr, __scalar_expr<typename _Expr::value_type> > > 4495>::type 4496operator>(const _Expr& __x, const typename _Expr::value_type& __y) 4497{ 4498 typedef typename _Expr::value_type value_type; 4499 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4500 return __val_expr<_Op>(_Op(greater<value_type>(), 4501 __x, __scalar_expr<value_type>(__y, __x.size()))); 4502} 4503 4504template<class _Expr> 4505inline _LIBCPP_INLINE_VISIBILITY 4506typename enable_if 4507< 4508 __is_val_expr<_Expr>::value, 4509 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, 4510 __scalar_expr<typename _Expr::value_type>, _Expr> > 4511>::type 4512operator>(const typename _Expr::value_type& __x, const _Expr& __y) 4513{ 4514 typedef typename _Expr::value_type value_type; 4515 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4516 return __val_expr<_Op>(_Op(greater<value_type>(), 4517 __scalar_expr<value_type>(__x, __y.size()), __y)); 4518} 4519 4520template<class _Expr1, class _Expr2> 4521inline _LIBCPP_INLINE_VISIBILITY 4522typename enable_if 4523< 4524 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4525 __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > 4526>::type 4527operator<=(const _Expr1& __x, const _Expr2& __y) 4528{ 4529 typedef typename _Expr1::value_type value_type; 4530 typedef _BinaryOp<less_equal<value_type>, _Expr1, _Expr2> _Op; 4531 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); 4532} 4533 4534template<class _Expr> 4535inline _LIBCPP_INLINE_VISIBILITY 4536typename enable_if 4537< 4538 __is_val_expr<_Expr>::value, 4539 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, 4540 _Expr, __scalar_expr<typename _Expr::value_type> > > 4541>::type 4542operator<=(const _Expr& __x, const typename _Expr::value_type& __y) 4543{ 4544 typedef typename _Expr::value_type value_type; 4545 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4546 return __val_expr<_Op>(_Op(less_equal<value_type>(), 4547 __x, __scalar_expr<value_type>(__y, __x.size()))); 4548} 4549 4550template<class _Expr> 4551inline _LIBCPP_INLINE_VISIBILITY 4552typename enable_if 4553< 4554 __is_val_expr<_Expr>::value, 4555 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, 4556 __scalar_expr<typename _Expr::value_type>, _Expr> > 4557>::type 4558operator<=(const typename _Expr::value_type& __x, const _Expr& __y) 4559{ 4560 typedef typename _Expr::value_type value_type; 4561 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4562 return __val_expr<_Op>(_Op(less_equal<value_type>(), 4563 __scalar_expr<value_type>(__x, __y.size()), __y)); 4564} 4565 4566template<class _Expr1, class _Expr2> 4567inline _LIBCPP_INLINE_VISIBILITY 4568typename enable_if 4569< 4570 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4571 __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > 4572>::type 4573operator>=(const _Expr1& __x, const _Expr2& __y) 4574{ 4575 typedef typename _Expr1::value_type value_type; 4576 typedef _BinaryOp<greater_equal<value_type>, _Expr1, _Expr2> _Op; 4577 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); 4578} 4579 4580template<class _Expr> 4581inline _LIBCPP_INLINE_VISIBILITY 4582typename enable_if 4583< 4584 __is_val_expr<_Expr>::value, 4585 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, 4586 _Expr, __scalar_expr<typename _Expr::value_type> > > 4587>::type 4588operator>=(const _Expr& __x, const typename _Expr::value_type& __y) 4589{ 4590 typedef typename _Expr::value_type value_type; 4591 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4592 return __val_expr<_Op>(_Op(greater_equal<value_type>(), 4593 __x, __scalar_expr<value_type>(__y, __x.size()))); 4594} 4595 4596template<class _Expr> 4597inline _LIBCPP_INLINE_VISIBILITY 4598typename enable_if 4599< 4600 __is_val_expr<_Expr>::value, 4601 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, 4602 __scalar_expr<typename _Expr::value_type>, _Expr> > 4603>::type 4604operator>=(const typename _Expr::value_type& __x, const _Expr& __y) 4605{ 4606 typedef typename _Expr::value_type value_type; 4607 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4608 return __val_expr<_Op>(_Op(greater_equal<value_type>(), 4609 __scalar_expr<value_type>(__x, __y.size()), __y)); 4610} 4611 4612template<class _Expr> 4613inline _LIBCPP_INLINE_VISIBILITY 4614typename enable_if 4615< 4616 __is_val_expr<_Expr>::value, 4617 __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > 4618>::type 4619abs(const _Expr& __x) 4620{ 4621 typedef typename _Expr::value_type value_type; 4622 typedef _UnaryOp<__abs_expr<value_type>, _Expr> _Op; 4623 return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); 4624} 4625 4626template<class _Expr> 4627inline _LIBCPP_INLINE_VISIBILITY 4628typename enable_if 4629< 4630 __is_val_expr<_Expr>::value, 4631 __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > 4632>::type 4633acos(const _Expr& __x) 4634{ 4635 typedef typename _Expr::value_type value_type; 4636 typedef _UnaryOp<__acos_expr<value_type>, _Expr> _Op; 4637 return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); 4638} 4639 4640template<class _Expr> 4641inline _LIBCPP_INLINE_VISIBILITY 4642typename enable_if 4643< 4644 __is_val_expr<_Expr>::value, 4645 __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > 4646>::type 4647asin(const _Expr& __x) 4648{ 4649 typedef typename _Expr::value_type value_type; 4650 typedef _UnaryOp<__asin_expr<value_type>, _Expr> _Op; 4651 return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); 4652} 4653 4654template<class _Expr> 4655inline _LIBCPP_INLINE_VISIBILITY 4656typename enable_if 4657< 4658 __is_val_expr<_Expr>::value, 4659 __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > 4660>::type 4661atan(const _Expr& __x) 4662{ 4663 typedef typename _Expr::value_type value_type; 4664 typedef _UnaryOp<__atan_expr<value_type>, _Expr> _Op; 4665 return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); 4666} 4667 4668template<class _Expr1, class _Expr2> 4669inline _LIBCPP_INLINE_VISIBILITY 4670typename enable_if 4671< 4672 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4673 __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > 4674>::type 4675atan2(const _Expr1& __x, const _Expr2& __y) 4676{ 4677 typedef typename _Expr1::value_type value_type; 4678 typedef _BinaryOp<__atan2_expr<value_type>, _Expr1, _Expr2> _Op; 4679 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); 4680} 4681 4682template<class _Expr> 4683inline _LIBCPP_INLINE_VISIBILITY 4684typename enable_if 4685< 4686 __is_val_expr<_Expr>::value, 4687 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, 4688 _Expr, __scalar_expr<typename _Expr::value_type> > > 4689>::type 4690atan2(const _Expr& __x, const typename _Expr::value_type& __y) 4691{ 4692 typedef typename _Expr::value_type value_type; 4693 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4694 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), 4695 __x, __scalar_expr<value_type>(__y, __x.size()))); 4696} 4697 4698template<class _Expr> 4699inline _LIBCPP_INLINE_VISIBILITY 4700typename enable_if 4701< 4702 __is_val_expr<_Expr>::value, 4703 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, 4704 __scalar_expr<typename _Expr::value_type>, _Expr> > 4705>::type 4706atan2(const typename _Expr::value_type& __x, const _Expr& __y) 4707{ 4708 typedef typename _Expr::value_type value_type; 4709 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4710 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), 4711 __scalar_expr<value_type>(__x, __y.size()), __y)); 4712} 4713 4714template<class _Expr> 4715inline _LIBCPP_INLINE_VISIBILITY 4716typename enable_if 4717< 4718 __is_val_expr<_Expr>::value, 4719 __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > 4720>::type 4721cos(const _Expr& __x) 4722{ 4723 typedef typename _Expr::value_type value_type; 4724 typedef _UnaryOp<__cos_expr<value_type>, _Expr> _Op; 4725 return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); 4726} 4727 4728template<class _Expr> 4729inline _LIBCPP_INLINE_VISIBILITY 4730typename enable_if 4731< 4732 __is_val_expr<_Expr>::value, 4733 __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > 4734>::type 4735cosh(const _Expr& __x) 4736{ 4737 typedef typename _Expr::value_type value_type; 4738 typedef _UnaryOp<__cosh_expr<value_type>, _Expr> _Op; 4739 return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); 4740} 4741 4742template<class _Expr> 4743inline _LIBCPP_INLINE_VISIBILITY 4744typename enable_if 4745< 4746 __is_val_expr<_Expr>::value, 4747 __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > 4748>::type 4749exp(const _Expr& __x) 4750{ 4751 typedef typename _Expr::value_type value_type; 4752 typedef _UnaryOp<__exp_expr<value_type>, _Expr> _Op; 4753 return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); 4754} 4755 4756template<class _Expr> 4757inline _LIBCPP_INLINE_VISIBILITY 4758typename enable_if 4759< 4760 __is_val_expr<_Expr>::value, 4761 __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > 4762>::type 4763log(const _Expr& __x) 4764{ 4765 typedef typename _Expr::value_type value_type; 4766 typedef _UnaryOp<__log_expr<value_type>, _Expr> _Op; 4767 return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); 4768} 4769 4770template<class _Expr> 4771inline _LIBCPP_INLINE_VISIBILITY 4772typename enable_if 4773< 4774 __is_val_expr<_Expr>::value, 4775 __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > 4776>::type 4777log10(const _Expr& __x) 4778{ 4779 typedef typename _Expr::value_type value_type; 4780 typedef _UnaryOp<__log10_expr<value_type>, _Expr> _Op; 4781 return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); 4782} 4783 4784template<class _Expr1, class _Expr2> 4785inline _LIBCPP_INLINE_VISIBILITY 4786typename enable_if 4787< 4788 __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, 4789 __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > 4790>::type 4791pow(const _Expr1& __x, const _Expr2& __y) 4792{ 4793 typedef typename _Expr1::value_type value_type; 4794 typedef _BinaryOp<__pow_expr<value_type>, _Expr1, _Expr2> _Op; 4795 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); 4796} 4797 4798template<class _Expr> 4799inline _LIBCPP_INLINE_VISIBILITY 4800typename enable_if 4801< 4802 __is_val_expr<_Expr>::value, 4803 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, 4804 _Expr, __scalar_expr<typename _Expr::value_type> > > 4805>::type 4806pow(const _Expr& __x, const typename _Expr::value_type& __y) 4807{ 4808 typedef typename _Expr::value_type value_type; 4809 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op; 4810 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), 4811 __x, __scalar_expr<value_type>(__y, __x.size()))); 4812} 4813 4814template<class _Expr> 4815inline _LIBCPP_INLINE_VISIBILITY 4816typename enable_if 4817< 4818 __is_val_expr<_Expr>::value, 4819 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, 4820 __scalar_expr<typename _Expr::value_type>, _Expr> > 4821>::type 4822pow(const typename _Expr::value_type& __x, const _Expr& __y) 4823{ 4824 typedef typename _Expr::value_type value_type; 4825 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op; 4826 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), 4827 __scalar_expr<value_type>(__x, __y.size()), __y)); 4828} 4829 4830template<class _Expr> 4831inline _LIBCPP_INLINE_VISIBILITY 4832typename enable_if 4833< 4834 __is_val_expr<_Expr>::value, 4835 __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > 4836>::type 4837sin(const _Expr& __x) 4838{ 4839 typedef typename _Expr::value_type value_type; 4840 typedef _UnaryOp<__sin_expr<value_type>, _Expr> _Op; 4841 return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); 4842} 4843 4844template<class _Expr> 4845inline _LIBCPP_INLINE_VISIBILITY 4846typename enable_if 4847< 4848 __is_val_expr<_Expr>::value, 4849 __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > 4850>::type 4851sinh(const _Expr& __x) 4852{ 4853 typedef typename _Expr::value_type value_type; 4854 typedef _UnaryOp<__sinh_expr<value_type>, _Expr> _Op; 4855 return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); 4856} 4857 4858template<class _Expr> 4859inline _LIBCPP_INLINE_VISIBILITY 4860typename enable_if 4861< 4862 __is_val_expr<_Expr>::value, 4863 __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > 4864>::type 4865sqrt(const _Expr& __x) 4866{ 4867 typedef typename _Expr::value_type value_type; 4868 typedef _UnaryOp<__sqrt_expr<value_type>, _Expr> _Op; 4869 return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); 4870} 4871 4872template<class _Expr> 4873inline _LIBCPP_INLINE_VISIBILITY 4874typename enable_if 4875< 4876 __is_val_expr<_Expr>::value, 4877 __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > 4878>::type 4879tan(const _Expr& __x) 4880{ 4881 typedef typename _Expr::value_type value_type; 4882 typedef _UnaryOp<__tan_expr<value_type>, _Expr> _Op; 4883 return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); 4884} 4885 4886template<class _Expr> 4887inline _LIBCPP_INLINE_VISIBILITY 4888typename enable_if 4889< 4890 __is_val_expr<_Expr>::value, 4891 __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > 4892>::type 4893tanh(const _Expr& __x) 4894{ 4895 typedef typename _Expr::value_type value_type; 4896 typedef _UnaryOp<__tanh_expr<value_type>, _Expr> _Op; 4897 return __val_expr<_Op>(_Op(__tanh_expr<value_type>(), __x)); 4898} 4899 4900template <class _Tp> 4901inline _LIBCPP_INLINE_VISIBILITY 4902_Tp* 4903begin(valarray<_Tp>& __v) 4904{ 4905 return __v.__begin_; 4906} 4907 4908template <class _Tp> 4909inline _LIBCPP_INLINE_VISIBILITY 4910const _Tp* 4911begin(const valarray<_Tp>& __v) 4912{ 4913 return __v.__begin_; 4914} 4915 4916template <class _Tp> 4917inline _LIBCPP_INLINE_VISIBILITY 4918_Tp* 4919end(valarray<_Tp>& __v) 4920{ 4921 return __v.__end_; 4922} 4923 4924template <class _Tp> 4925inline _LIBCPP_INLINE_VISIBILITY 4926const _Tp* 4927end(const valarray<_Tp>& __v) 4928{ 4929 return __v.__end_; 4930} 4931 4932_LIBCPP_END_NAMESPACE_STD 4933 4934_LIBCPP_POP_MACROS 4935 4936#endif // _LIBCPP_VALARRAY 4937