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