epoc32/include/stdapis/stlportv5/stl/_valarray.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Copyright (c) 1999
     3  * Silicon Graphics Computer Systems, Inc.
     4  *
     5  * Copyright (c) 1999
     6  * Boris Fomitchev
     7  *
     8  * This material is provided "as is", with absolutely no warranty expressed
     9  * or implied. Any use is at your own risk.
    10  *
    11  * Permission to use or copy this software for any purpose is hereby granted
    12  * without fee, provided the above notices are retained on all copies.
    13  * Permission to modify the code and to distribute modified code is granted,
    14  * provided the above notices are retained, and a notice that the code was
    15  * modified is included with the above copyright notice.
    16  *
    17  */
    18 
    19 #ifndef _STLP_VALARRAY_H
    20 #define _STLP_VALARRAY_H
    21 
    22 #ifndef _STLP_INTERNAL_CMATH
    23 #  include <stl/_cmath.h>
    24 #endif
    25 
    26 #ifndef _STLP_INTERNAL_NEW
    27 #  include <stl/_new.h>
    28 #endif
    29 
    30 #ifndef _STLP_INTERNAL_ALGO_H
    31 #  include <stl/_algo.h>
    32 #endif
    33 
    34 #ifndef _STLP_INTERNAL_NUMERIC_H
    35 #  include <stl/_numeric.h>
    36 #endif
    37 
    38 #ifndef _STLP_INTERNAL_LIMITS
    39 #  include <stl/_limits.h>
    40 #endif
    41 
    42 /* As we only need the _STLP_ASSERT macro from _debug.h we test it to include _debug.h */
    43 #ifndef _STLP_ASSERT
    44 #  include <stl/debug/_debug.h>
    45 #endif
    46 
    47 _STLP_BEGIN_NAMESPACE
    48 
    49 class slice;
    50 class gslice;
    51 
    52 template <class _Tp> class valarray;
    53 typedef valarray<bool>    _Valarray_bool;
    54 typedef valarray<size_t>  _Valarray_size_t;
    55 
    56 template <class _Tp> class slice_array;
    57 template <class _Tp> class gslice_array;
    58 template <class _Tp> class mask_array;
    59 template <class _Tp> class indirect_array;
    60 
    61 //----------------------------------------------------------------------
    62 // class valarray
    63 
    64 // Base class to handle memory allocation and deallocation.  We can't just
    65 // use vector<>, because vector<bool> would be unsuitable as an internal
    66 // representation for valarray<bool>.
    67 
    68 template <class _Tp>
    69 struct _Valarray_base
    70 {
    71   _Tp*   _M_first;
    72   size_t _M_size;
    73 
    74   _Valarray_base() : _M_first(0), _M_size(0) {}
    75   _Valarray_base(size_t __n) : _M_first(0), _M_size(0) { _M_allocate(__n); }
    76   ~_Valarray_base() { _M_deallocate(); }
    77 
    78   void _M_allocate(size_t __n) {
    79     if (__n != 0) {
    80       _M_first = __STATIC_CAST(_Tp*, (malloc(__n * sizeof(_Tp))));
    81       _M_size  = __n;
    82 #if !defined(_STLP_NO_BAD_ALLOC) && defined(_STLP_USE_EXCEPTIONS)
    83       if (_M_first == 0) {
    84         _M_size = 0;
    85         throw _STLP_STD::bad_alloc();
    86       }
    87 #endif
    88     }
    89     else {
    90       _M_first = 0;
    91       _M_size = 0;
    92     }
    93   }
    94 
    95   void _M_deallocate() {
    96     free(_M_first);
    97     _M_first = 0;
    98     _M_size = 0;
    99   }
   100 };
   101 
   102 template <class _Tp>
   103 class valarray : private _Valarray_base<_Tp>
   104 {
   105   friend class gslice;
   106 
   107 public:
   108   typedef _Tp value_type;
   109 
   110   // Basic constructors
   111   valarray() : _Valarray_base<_Tp>() {}
   112   explicit valarray(size_t __n) : _Valarray_base<_Tp>(__n)
   113     { uninitialized_fill_n(this->_M_first, this->_M_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
   114   valarray(const value_type& __x, size_t __n) : _Valarray_base<_Tp>(__n)
   115     { uninitialized_fill_n(this->_M_first, this->_M_size, __x); }
   116   valarray(const value_type* __p, size_t __n) : _Valarray_base<_Tp>(__n)
   117     { uninitialized_copy(__p, __p + __n, this->_M_first); }
   118   valarray(const valarray<_Tp>& __x) : _Valarray_base<_Tp>(__x._M_size) {
   119     uninitialized_copy(__x._M_first, __x._M_first + __x._M_size,
   120                        this->_M_first);
   121   }
   122 
   123   // Constructors from auxiliary array types
   124   valarray(const slice_array<_Tp>&);
   125   valarray(const gslice_array<_Tp>&);
   126   valarray(const mask_array<_Tp>&);
   127   valarray(const indirect_array<_Tp>&);
   128 
   129   // Destructor
   130   ~valarray() { _STLP_STD::_Destroy_Range(this->_M_first, this->_M_first + this->_M_size); }
   131 
   132   // Extension: constructor that doesn't initialize valarray elements to a
   133   // specific value.  This is faster for types such as int and double.
   134 private:
   135   void _M_initialize(const __true_type&) {}
   136   void _M_initialize(const __false_type&)
   137     { uninitialized_fill_n(this->_M_first, this->_M_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
   138 
   139 public:
   140   struct _NoInit {};
   141   valarray(size_t __n, _NoInit) : _Valarray_base<_Tp>(__n) {
   142     typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Is_Trivial;
   143     _M_initialize(_Is_Trivial());
   144   }
   145 
   146 public:                         // Assignment
   147   // Basic assignment.  Note that 'x = y' is undefined if x.size() != y.size()
   148   valarray<_Tp>& operator=(const valarray<_Tp>& __x) {
   149     _STLP_ASSERT(__x.size() == this->size())
   150     if (this != &__x)
   151 	{
   152 #ifdef __SYMBIAN32__
   153       /* Eventhough the behavior is undefined when the sizes are different,
   154          copying the data correspoding to the minimum of both the lengths 
   155          will prevent a crash */ 
   156       if( this->size() < __x._M_size )
   157     	  copy(__x._M_first, __x._M_first + this->size(), this->_M_first);
   158       else
   159     	  copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first);
   160     
   161 #else /* __SYMBIAN32__ */
   162       copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first);
   163       
   164 #endif /* __SYMBIAN32__ */
   165      }
   166       
   167     return *this;
   168   }
   169 
   170   // Scalar assignment
   171   valarray<_Tp>& operator=(const value_type& __x) {
   172     fill_n(this->_M_first, this->_M_size, __x);
   173     return *this;
   174   }
   175 
   176   // Assignment of auxiliary array types
   177   valarray<_Tp>& operator=(const slice_array<_Tp>&);
   178   valarray<_Tp>& operator=(const gslice_array<_Tp>&);
   179   valarray<_Tp>& operator=(const mask_array<_Tp>&);
   180   valarray<_Tp>& operator=(const indirect_array<_Tp>&);
   181 
   182 public:                         // Element access
   183   value_type  operator[](size_t __n) const { return this->_M_first[__n]; }
   184   value_type& operator[](size_t __n)       { return this->_M_first[__n]; }
   185   size_t size() const { return this->_M_size; }
   186 
   187 public:                         // Subsetting operations with auxiliary type
   188   valarray<_Tp>            operator[](slice) const;
   189   slice_array<_Tp>    operator[](slice);
   190   valarray<_Tp>            operator[](const gslice&) const;
   191   gslice_array<_Tp>   operator[](const gslice&);
   192   valarray<_Tp>            operator[](const _Valarray_bool&) const;
   193   mask_array<_Tp>     operator[](const _Valarray_bool&);
   194   valarray<_Tp>            operator[](const _Valarray_size_t&) const;
   195   indirect_array<_Tp> operator[](const _Valarray_size_t&);
   196 
   197 public:                         // Unary operators.
   198   valarray<_Tp> operator+() const { return *this; }
   199 
   200   valarray<_Tp> operator-() const {
   201     valarray<_Tp> __tmp(this->size(), _NoInit());
   202     for (size_t __i = 0; __i < this->size(); ++__i)
   203       __tmp[__i] = -(*this)[__i];
   204     return __tmp;
   205   }
   206 
   207   valarray<_Tp> operator~() const {
   208     valarray<_Tp> __tmp(this->size(), _NoInit());
   209     for (size_t __i = 0; __i < this->size(); ++__i)
   210       __tmp[__i] = ~(*this)[__i];
   211     return __tmp;
   212   }
   213 
   214   _Valarray_bool operator!() const;
   215 
   216 public:                         // Scalar computed assignment.
   217   valarray<_Tp>& operator*= (const value_type& __x) {
   218     for (size_t __i = 0; __i < this->size(); ++__i)
   219       (*this)[__i] *= __x;
   220     return *this;
   221   }
   222 
   223   valarray<_Tp>& operator/= (const value_type& __x) {
   224     for (size_t __i = 0; __i < this->size(); ++__i)
   225       (*this)[__i] /= __x;
   226     return *this;
   227   }
   228 
   229   valarray<_Tp>& operator%= (const value_type& __x) {
   230     for (size_t __i = 0; __i < this->size(); ++__i)
   231       (*this)[__i] %= __x;
   232     return *this;
   233   }
   234 
   235   valarray<_Tp>& operator+= (const value_type& __x) {
   236     for (size_t __i = 0; __i < this->size(); ++__i)
   237       (*this)[__i] += __x;
   238     return *this;
   239   }
   240 
   241   valarray<_Tp>& operator-= (const value_type& __x) {
   242     for (size_t __i = 0; __i < this->size(); ++__i)
   243       (*this)[__i] -= __x;
   244     return *this;
   245   }
   246 
   247   valarray<_Tp>& operator^= (const value_type& __x) {
   248     for (size_t __i = 0; __i < this->size(); ++__i)
   249       (*this)[__i] ^= __x;
   250     return *this;
   251   }
   252 
   253   valarray<_Tp>& operator&= (const value_type& __x) {
   254     for (size_t __i = 0; __i < this->size(); ++__i)
   255       (*this)[__i] &= __x;
   256     return *this;
   257   }
   258 
   259   valarray<_Tp>& operator|= (const value_type& __x) {
   260     for (size_t __i = 0; __i < this->size(); ++__i)
   261       (*this)[__i] |= __x;
   262     return *this;
   263   }
   264 
   265   valarray<_Tp>& operator<<= (const value_type& __x) {
   266     for (size_t __i = 0; __i < this->size(); ++__i)
   267       (*this)[__i] <<= __x;
   268     return *this;
   269   }
   270 
   271   valarray<_Tp>& operator>>= (const value_type& __x) {
   272     for (size_t __i = 0; __i < this->size(); ++__i)
   273       (*this)[__i] >>= __x;
   274     return *this;
   275   }
   276 
   277 public:                         // Array computed assignment.
   278   valarray<_Tp>& operator*= (const valarray<_Tp>& __x) {
   279     for (size_t __i = 0; __i < this->size(); ++__i)
   280       (*this)[__i] *= __x[__i];
   281     return *this;
   282   }
   283 
   284   valarray<_Tp>& operator/= (const valarray<_Tp>& __x) {
   285     for (size_t __i = 0; __i < this->size(); ++__i)
   286       (*this)[__i] /= __x[__i];
   287     return *this;
   288   }
   289 
   290   valarray<_Tp>& operator%= (const valarray<_Tp>& __x) {
   291     for (size_t __i = 0; __i < this->size(); ++__i)
   292       (*this)[__i] %= __x[__i];
   293     return *this;
   294   }
   295 
   296   valarray<_Tp>& operator+= (const valarray<_Tp>& __x) {
   297     for (size_t __i = 0; __i < this->size(); ++__i)
   298       (*this)[__i] += __x[__i];
   299     return *this;
   300   }
   301 
   302   valarray<_Tp>& operator-= (const valarray<_Tp>& __x) {
   303     for (size_t __i = 0; __i < this->size(); ++__i)
   304       (*this)[__i] -= __x[__i];
   305     return *this;
   306   }
   307 
   308   valarray<_Tp>& operator^= (const valarray<_Tp>& __x) {
   309     for (size_t __i = 0; __i < this->size(); ++__i)
   310       (*this)[__i] ^= __x[__i];
   311     return *this;
   312   }
   313 
   314   valarray<_Tp>& operator&= (const valarray<_Tp>& __x) {
   315     for (size_t __i = 0; __i < this->size(); ++__i)
   316       (*this)[__i] &= __x[__i];
   317     return *this;
   318   }
   319 
   320   valarray<_Tp>& operator|= (const valarray<_Tp>& __x) {
   321     for (size_t __i = 0; __i < this->size(); ++__i)
   322       (*this)[__i] |= __x[__i];
   323     return *this;
   324   }
   325 
   326   valarray<_Tp>& operator<<= (const valarray<_Tp>& __x) {
   327     for (size_t __i = 0; __i < this->size(); ++__i)
   328       (*this)[__i] <<= __x[__i];
   329     return *this;
   330   }
   331 
   332   valarray<_Tp>& operator>>= (const valarray<_Tp>& __x) {
   333     for (size_t __i = 0; __i < this->size(); ++__i)
   334       (*this)[__i] >>= __x[__i];
   335     return *this;
   336   }
   337 
   338 public:                         // Other member functions.
   339 
   340   // The result is undefined for zero-length arrays
   341   value_type sum() const {
   342     return accumulate(this->_M_first + 1, this->_M_first + this->_M_size,
   343                       (*this)[0]);
   344   }
   345 
   346   // The result is undefined for zero-length arrays
   347   value_type (min) () const {
   348     return *min_element(this->_M_first + 0, this->_M_first + this->_M_size);
   349   }
   350 
   351   value_type (max) () const {
   352     return *max_element(this->_M_first + 0, this->_M_first + this->_M_size);
   353   }
   354 
   355   valarray<_Tp> shift(int __n) const;
   356   valarray<_Tp> cshift(int __n) const;
   357 
   358   valarray<_Tp> apply(value_type __f(value_type)) const {
   359     valarray<_Tp> __tmp(this->size());
   360     transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first,
   361               __f);
   362     return __tmp;
   363   }
   364   valarray<_Tp> apply(value_type __f(const value_type&)) const {
   365     valarray<_Tp> __tmp(this->size());
   366     transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first,
   367               __f);
   368     return __tmp;
   369   }
   370 
   371   void resize(size_t __n, value_type __x = value_type()) {
   372     _STLP_STD::_Destroy_Range(this->_M_first, this->_M_first + this->_M_size);
   373     _Valarray_base<_Tp>::_M_deallocate();
   374     _Valarray_base<_Tp>::_M_allocate(__n);
   375     uninitialized_fill_n(this->_M_first, this->_M_size, __x);
   376   }
   377 };
   378 
   379 //----------------------------------------------------------------------
   380 // valarray non-member functions.
   381 
   382 // Binary arithmetic operations between two arrays.  Behavior is
   383 // undefined if the two arrays do not have the same length.
   384 
   385 template <class _Tp>
   386 inline valarray<_Tp>  _STLP_CALL operator*(const valarray<_Tp>& __x,
   387                                            const valarray<_Tp>& __y) {
   388   typedef typename valarray<_Tp>::_NoInit _NoInit;
   389   valarray<_Tp> __tmp(__x.size(), _NoInit());
   390   for (size_t __i = 0; __i < __x.size(); ++__i)
   391     __tmp[__i] = __x[__i] * __y[__i];
   392   return __tmp;
   393 }
   394 
   395 template <class _Tp>
   396 inline valarray<_Tp>  _STLP_CALL operator/(const valarray<_Tp>& __x,
   397                                            const valarray<_Tp>& __y) {
   398   typedef typename valarray<_Tp>::_NoInit _NoInit;
   399   valarray<_Tp> __tmp(__x.size(), _NoInit());
   400   for (size_t __i = 0; __i < __x.size(); ++__i)
   401     __tmp[__i] = __x[__i] / __y[__i];
   402   return __tmp;
   403 }
   404 
   405 template <class _Tp>
   406 inline valarray<_Tp>  _STLP_CALL operator%(const valarray<_Tp>& __x,
   407                                            const valarray<_Tp>& __y) {
   408   typedef typename valarray<_Tp>::_NoInit _NoInit;
   409   valarray<_Tp> __tmp(__x.size(), _NoInit());
   410   for (size_t __i = 0; __i < __x.size(); ++__i)
   411     __tmp[__i] = __x[__i] % __y[__i];
   412   return __tmp;
   413 }
   414 
   415 template <class _Tp>
   416 inline valarray<_Tp>  _STLP_CALL operator+(const valarray<_Tp>& __x,
   417                                            const valarray<_Tp>& __y) {
   418   typedef typename valarray<_Tp>::_NoInit _NoInit;
   419   valarray<_Tp> __tmp(__x.size(), _NoInit());
   420   for (size_t __i = 0; __i < __x.size(); ++__i)
   421     __tmp[__i] = __x[__i] + __y[__i];
   422   return __tmp;
   423 }
   424 
   425 template <class _Tp>
   426 inline valarray<_Tp>  _STLP_CALL operator-(const valarray<_Tp>& __x,
   427                                            const valarray<_Tp>& __y) {
   428   typedef typename valarray<_Tp>::_NoInit _NoInit;
   429   valarray<_Tp> __tmp(__x.size(), _NoInit());
   430   for (size_t __i = 0; __i < __x.size(); ++__i)
   431     __tmp[__i] = __x[__i] - __y[__i];
   432   return __tmp;
   433 }
   434 
   435 template <class _Tp>
   436 inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x,
   437                                const valarray<_Tp>& __y) {
   438   typedef typename valarray<_Tp>::_NoInit _NoInit;
   439   valarray<_Tp> __tmp(__x.size(), _NoInit());
   440   for (size_t __i = 0; __i < __x.size(); ++__i)
   441     __tmp[__i] = __x[__i] ^ __y[__i];
   442   return __tmp;
   443 }
   444 
   445 template <class _Tp>
   446 inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x,
   447                                const valarray<_Tp>& __y) {
   448   typedef typename valarray<_Tp>::_NoInit _NoInit;
   449   valarray<_Tp> __tmp(__x.size(), _NoInit());
   450   for (size_t __i = 0; __i < __x.size(); ++__i)
   451     __tmp[__i] = __x[__i] & __y[__i];
   452   return __tmp;
   453 }
   454 
   455 template <class _Tp>
   456 inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x,
   457                                const valarray<_Tp>& __y) {
   458   typedef typename valarray<_Tp>::_NoInit _NoInit;
   459   valarray<_Tp> __tmp(__x.size(), _NoInit());
   460   for (size_t __i = 0; __i < __x.size(); ++__i)
   461     __tmp[__i] = __x[__i] | __y[__i];
   462   return __tmp;
   463 }
   464 
   465 template <class _Tp>
   466 inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x,
   467                                const valarray<_Tp>& __y) {
   468   typedef typename valarray<_Tp>::_NoInit _NoInit;
   469   valarray<_Tp> __tmp(__x.size(), _NoInit());
   470   for (size_t __i = 0; __i < __x.size(); ++__i)
   471     __tmp[__i] = __x[__i] << __y[__i];
   472   return __tmp;
   473 }
   474 
   475 template <class _Tp>
   476 inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x,
   477                                const valarray<_Tp>& __y) {
   478   typedef typename valarray<_Tp>::_NoInit _NoInit;
   479   valarray<_Tp> __tmp(__x.size(), _NoInit());
   480   for (size_t __i = 0; __i < __x.size(); ++__i)
   481     __tmp[__i] = __x[__i] >> __y[__i];
   482   return __tmp;
   483 }
   484 
   485 // Binary arithmetic operations between an array and a scalar.
   486 
   487 template <class _Tp>
   488 inline valarray<_Tp> _STLP_CALL operator*(const valarray<_Tp>& __x, const _Tp& __c) {
   489   typedef typename valarray<_Tp>::_NoInit _NoInit;
   490   valarray<_Tp> __tmp(__x.size(), _NoInit());
   491   for (size_t __i = 0; __i < __x.size(); ++__i)
   492     __tmp[__i] = __x[__i]  * __c;
   493   return __tmp;
   494 }
   495 
   496 template <class _Tp>
   497 inline valarray<_Tp> _STLP_CALL operator*(const _Tp& __c, const valarray<_Tp>& __x) {
   498   typedef typename valarray<_Tp>::_NoInit _NoInit;
   499   valarray<_Tp> __tmp(__x.size(), _NoInit());
   500   for (size_t __i = 0; __i < __x.size(); ++__i)
   501     __tmp[__i] = __c * __x[__i];
   502   return __tmp;
   503 }
   504 
   505 template <class _Tp>
   506 inline valarray<_Tp> _STLP_CALL operator/(const valarray<_Tp>& __x, const _Tp& __c) {
   507   typedef typename valarray<_Tp>::_NoInit _NoInit;
   508   valarray<_Tp> __tmp(__x.size(), _NoInit());
   509   for (size_t __i = 0; __i < __x.size(); ++__i)
   510     __tmp[__i] = __x[__i]  / __c;
   511   return __tmp;
   512 }
   513 
   514 template <class _Tp>
   515 inline valarray<_Tp> _STLP_CALL operator/(const _Tp& __c, const valarray<_Tp>& __x) {
   516   typedef typename valarray<_Tp>::_NoInit _NoInit;
   517   valarray<_Tp> __tmp(__x.size(), _NoInit());
   518   for (size_t __i = 0; __i < __x.size(); ++__i)
   519     __tmp[__i] = __c / __x[__i];
   520   return __tmp;
   521 }
   522 
   523 template <class _Tp>
   524 inline valarray<_Tp> _STLP_CALL operator%(const valarray<_Tp>& __x, const _Tp& __c) {
   525   typedef typename valarray<_Tp>::_NoInit _NoInit;
   526   valarray<_Tp> __tmp(__x.size(), _NoInit());
   527   for (size_t __i = 0; __i < __x.size(); ++__i)
   528     __tmp[__i] = __x[__i]  % __c;
   529   return __tmp;
   530 }
   531 
   532 template <class _Tp>
   533 inline valarray<_Tp> _STLP_CALL operator%(const _Tp& __c, const valarray<_Tp>& __x) {
   534   typedef typename valarray<_Tp>::_NoInit _NoInit;
   535   valarray<_Tp> __tmp(__x.size(), _NoInit());
   536   for (size_t __i = 0; __i < __x.size(); ++__i)
   537     __tmp[__i] = __c % __x[__i];
   538   return __tmp;
   539 }
   540 
   541 template <class _Tp>
   542 inline valarray<_Tp> _STLP_CALL operator+(const valarray<_Tp>& __x, const _Tp& __c) {
   543   typedef typename valarray<_Tp>::_NoInit _NoInit;
   544   valarray<_Tp> __tmp(__x.size(), _NoInit());
   545   for (size_t __i = 0; __i < __x.size(); ++__i)
   546     __tmp[__i] = __x[__i]  + __c;
   547   return __tmp;
   548 }
   549 
   550 template <class _Tp>
   551 inline valarray<_Tp> _STLP_CALL operator+(const _Tp& __c, const valarray<_Tp>& __x) {
   552   typedef typename valarray<_Tp>::_NoInit _NoInit;
   553   valarray<_Tp> __tmp(__x.size(), _NoInit());
   554   for (size_t __i = 0; __i < __x.size(); ++__i)
   555     __tmp[__i] = __c + __x[__i];
   556   return __tmp;
   557 }
   558 
   559 template <class _Tp>
   560 inline valarray<_Tp> _STLP_CALL operator-(const valarray<_Tp>& __x, const _Tp& __c) {
   561   typedef typename valarray<_Tp>::_NoInit _NoInit;
   562   valarray<_Tp> __tmp(__x.size(), _NoInit());
   563   for (size_t __i = 0; __i < __x.size(); ++__i)
   564     __tmp[__i] = __x[__i]  - __c;
   565   return __tmp;
   566 }
   567 
   568 template <class _Tp>
   569 inline valarray<_Tp> _STLP_CALL operator-(const _Tp& __c, const valarray<_Tp>& __x) {
   570   typedef typename valarray<_Tp>::_NoInit _NoInit;
   571   valarray<_Tp> __tmp(__x.size(), _NoInit());
   572   for (size_t __i = 0; __i < __x.size(); ++__i)
   573     __tmp[__i] = __c - __x[__i];
   574   return __tmp;
   575 }
   576 
   577 template <class _Tp>
   578 inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x, const _Tp& __c) {
   579   typedef typename valarray<_Tp>::_NoInit _NoInit;
   580   valarray<_Tp> __tmp(__x.size(), _NoInit());
   581   for (size_t __i = 0; __i < __x.size(); ++__i)
   582     __tmp[__i] = __x[__i]  ^ __c;
   583   return __tmp;
   584 }
   585 
   586 template <class _Tp>
   587 inline valarray<_Tp> _STLP_CALL operator^(const _Tp& __c, const valarray<_Tp>& __x) {
   588   typedef typename valarray<_Tp>::_NoInit _NoInit;
   589   valarray<_Tp> __tmp(__x.size(), _NoInit());
   590   for (size_t __i = 0; __i < __x.size(); ++__i)
   591     __tmp[__i] = __c ^ __x[__i];
   592   return __tmp;
   593 }
   594 
   595 template <class _Tp>
   596 inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x, const _Tp& __c) {
   597   typedef typename valarray<_Tp>::_NoInit _NoInit;
   598   valarray<_Tp> __tmp(__x.size(), _NoInit());
   599   for (size_t __i = 0; __i < __x.size(); ++__i)
   600     __tmp[__i] = __x[__i]  & __c;
   601   return __tmp;
   602 }
   603 
   604 template <class _Tp>
   605 inline valarray<_Tp> _STLP_CALL operator&(const _Tp& __c, const valarray<_Tp>& __x) {
   606   typedef typename valarray<_Tp>::_NoInit _NoInit;
   607   valarray<_Tp> __tmp(__x.size(), _NoInit());
   608   for (size_t __i = 0; __i < __x.size(); ++__i)
   609     __tmp[__i] = __c & __x[__i];
   610   return __tmp;
   611 }
   612 
   613 template <class _Tp>
   614 inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x, const _Tp& __c) {
   615   typedef typename valarray<_Tp>::_NoInit _NoInit;
   616   valarray<_Tp> __tmp(__x.size(), _NoInit());
   617   for (size_t __i = 0; __i < __x.size(); ++__i)
   618     __tmp[__i] = __x[__i]  | __c;
   619   return __tmp;
   620 }
   621 
   622 template <class _Tp>
   623 inline valarray<_Tp> _STLP_CALL operator|(const _Tp& __c, const valarray<_Tp>& __x) {
   624   typedef typename valarray<_Tp>::_NoInit _NoInit;
   625   valarray<_Tp> __tmp(__x.size(), _NoInit());
   626   for (size_t __i = 0; __i < __x.size(); ++__i)
   627     __tmp[__i] = __c | __x[__i];
   628   return __tmp;
   629 }
   630 
   631 template <class _Tp>
   632 inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x, const _Tp& __c) {
   633   typedef typename valarray<_Tp>::_NoInit _NoInit;
   634   valarray<_Tp> __tmp(__x.size(), _NoInit());
   635   for (size_t __i = 0; __i < __x.size(); ++__i)
   636     __tmp[__i] = __x[__i]  << __c;
   637   return __tmp;
   638 }
   639 
   640 template <class _Tp>
   641 inline valarray<_Tp> _STLP_CALL operator<<(const _Tp& __c, const valarray<_Tp>& __x) {
   642   typedef typename valarray<_Tp>::_NoInit _NoInit;
   643   valarray<_Tp> __tmp(__x.size(), _NoInit());
   644   for (size_t __i = 0; __i < __x.size(); ++__i)
   645     __tmp[__i] = __c << __x[__i];
   646   return __tmp;
   647 }
   648 
   649 template <class _Tp>
   650 inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x, const _Tp& __c) {
   651   typedef typename valarray<_Tp>::_NoInit _NoInit;
   652   valarray<_Tp> __tmp(__x.size(), _NoInit());
   653   for (size_t __i = 0; __i < __x.size(); ++__i)
   654     __tmp[__i] = __x[__i]  >> __c;
   655   return __tmp;
   656 }
   657 
   658 template <class _Tp>
   659 inline valarray<_Tp> _STLP_CALL operator>>(const _Tp& __c, const valarray<_Tp>& __x) {
   660   typedef typename valarray<_Tp>::_NoInit _NoInit;
   661   valarray<_Tp> __tmp(__x.size(), _NoInit());
   662   for (size_t __i = 0; __i < __x.size(); ++__i)
   663     __tmp[__i] = __c >> __x[__i];
   664   return __tmp;
   665 }
   666 
   667 // Binary logical operations between two arrays.  Behavior is undefined
   668 // if the two arrays have different lengths.  Note that operator== does
   669 // not do what you might at first expect.
   670 
   671 template <class _Tp>
   672 inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x,
   673                                  const valarray<_Tp>& __y)
   674 {
   675   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   676   for (size_t __i = 0; __i < __x.size(); ++__i)
   677     __tmp[__i] = __x[__i] == __y[__i];
   678   return __tmp;
   679 }
   680 
   681 template <class _Tp>
   682 inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x,
   683                                 const valarray<_Tp>& __y)
   684 {
   685   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   686   for (size_t __i = 0; __i < __x.size(); ++__i)
   687     __tmp[__i] = __x[__i] < __y[__i];
   688   return __tmp;
   689 }
   690 
   691 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   692 
   693 template <class _Tp>
   694 inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x,
   695                                  const valarray<_Tp>& __y)
   696 {
   697   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   698   for (size_t __i = 0; __i < __x.size(); ++__i)
   699     __tmp[__i] = __x[__i] != __y[__i];
   700   return __tmp;
   701 }
   702 
   703 template <class _Tp>
   704 inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x,
   705                                 const valarray<_Tp>& __y)
   706 {
   707   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   708   for (size_t __i = 0; __i < __x.size(); ++__i)
   709     __tmp[__i] = __x[__i] > __y[__i];
   710   return __tmp;
   711 }
   712 
   713 template <class _Tp>
   714 inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x,
   715                                  const valarray<_Tp>& __y)
   716 {
   717   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   718   for (size_t __i = 0; __i < __x.size(); ++__i)
   719     __tmp[__i] = __x[__i] <= __y[__i];
   720   return __tmp;
   721 }
   722 
   723 template <class _Tp>
   724 inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x,
   725                                  const valarray<_Tp>& __y)
   726 {
   727   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   728   for (size_t __i = 0; __i < __x.size(); ++__i)
   729     __tmp[__i] = __x[__i] >= __y[__i];
   730   return __tmp;
   731 }
   732 
   733 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   734 // fbp : swap ?
   735 
   736 template <class _Tp>
   737 inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x,
   738                                  const valarray<_Tp>& __y)
   739 {
   740   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   741   for (size_t __i = 0; __i < __x.size(); ++__i)
   742     __tmp[__i] = __x[__i] && __y[__i];
   743   return __tmp;
   744 }
   745 
   746 template <class _Tp>
   747 inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x,
   748                                  const valarray<_Tp>& __y)
   749 {
   750   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   751   for (size_t __i = 0; __i < __x.size(); ++__i)
   752     __tmp[__i] = __x[__i] || __y[__i];
   753   return __tmp;
   754 }
   755 
   756 // Logical operations between an array and a scalar.
   757 
   758 template <class _Tp>
   759 inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x, const _Tp& __c)
   760 {
   761   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   762   for (size_t __i = 0; __i < __x.size(); ++__i)
   763     __tmp[__i] = __x[__i] == __c;
   764   return __tmp;
   765 }
   766 
   767 template <class _Tp>
   768 inline _Valarray_bool _STLP_CALL operator==(const _Tp& __c, const valarray<_Tp>& __x)
   769 {
   770   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   771   for (size_t __i = 0; __i < __x.size(); ++__i)
   772     __tmp[__i] = __c == __x[__i];
   773   return __tmp;
   774 }
   775 
   776 template <class _Tp>
   777 inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x, const _Tp& __c)
   778 {
   779   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   780   for (size_t __i = 0; __i < __x.size(); ++__i)
   781     __tmp[__i] = __x[__i] != __c;
   782   return __tmp;
   783 }
   784 
   785 template <class _Tp>
   786 inline _Valarray_bool _STLP_CALL operator!=(const _Tp& __c, const valarray<_Tp>& __x)
   787 {
   788   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   789   for (size_t __i = 0; __i < __x.size(); ++__i)
   790     __tmp[__i] = __c != __x[__i];
   791   return __tmp;
   792 }
   793 
   794 template <class _Tp>
   795 inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x, const _Tp& __c)
   796 {
   797   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   798   for (size_t __i = 0; __i < __x.size(); ++__i)
   799     __tmp[__i] = __x[__i] < __c;
   800   return __tmp;
   801 }
   802 
   803 template <class _Tp>
   804 inline _Valarray_bool _STLP_CALL operator<(const _Tp& __c, const valarray<_Tp>& __x)
   805 {
   806   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   807   for (size_t __i = 0; __i < __x.size(); ++__i)
   808     __tmp[__i] = __c < __x[__i];
   809   return __tmp;
   810 }
   811 
   812 template <class _Tp>
   813 inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x, const _Tp& __c)
   814 {
   815   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   816   for (size_t __i = 0; __i < __x.size(); ++__i)
   817     __tmp[__i] = __x[__i] > __c;
   818   return __tmp;
   819 }
   820 
   821 template <class _Tp>
   822 inline _Valarray_bool _STLP_CALL operator>(const _Tp& __c, const valarray<_Tp>& __x)
   823 {
   824   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   825   for (size_t __i = 0; __i < __x.size(); ++__i)
   826     __tmp[__i] = __c > __x[__i];
   827   return __tmp;
   828 }
   829 
   830 template <class _Tp>
   831 inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x, const _Tp& __c)
   832 {
   833   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   834   for (size_t __i = 0; __i < __x.size(); ++__i)
   835     __tmp[__i] = __x[__i]  <= __c;
   836   return __tmp;
   837 }
   838 
   839 template <class _Tp>
   840 inline _Valarray_bool _STLP_CALL operator<=(const _Tp& __c, const valarray<_Tp>& __x)
   841 {
   842   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   843   for (size_t __i = 0; __i < __x.size(); ++__i)
   844     __tmp[__i] = __c <= __x[__i];
   845   return __tmp;
   846 }
   847 
   848 template <class _Tp>
   849 inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x, const _Tp& __c)
   850 {
   851   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   852   for (size_t __i = 0; __i < __x.size(); ++__i)
   853     __tmp[__i] = __x[__i] >= __c;
   854   return __tmp;
   855 }
   856 
   857 template <class _Tp>
   858 inline _Valarray_bool _STLP_CALL operator>=(const _Tp& __c, const valarray<_Tp>& __x)
   859 {
   860   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   861   for (size_t __i = 0; __i < __x.size(); ++__i)
   862     __tmp[__i] = __c >= __x[__i];
   863   return __tmp;
   864 }
   865 
   866 template <class _Tp>
   867 inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x, const _Tp& __c)
   868 {
   869   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   870   for (size_t __i = 0; __i < __x.size(); ++__i)
   871     __tmp[__i] = __x[__i] && __c;
   872   return __tmp;
   873 }
   874 
   875 template <class _Tp>
   876 inline _Valarray_bool _STLP_CALL operator&&(const _Tp& __c, const valarray<_Tp>& __x)
   877 {
   878   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   879   for (size_t __i = 0; __i < __x.size(); ++__i)
   880     __tmp[__i] = __c && __x[__i];
   881   return __tmp;
   882 }
   883 
   884 template <class _Tp>
   885 inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x, const _Tp& __c)
   886 {
   887   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   888   for (size_t __i = 0; __i < __x.size(); ++__i)
   889     __tmp[__i] = __x[__i] || __c;
   890   return __tmp;
   891 }
   892 
   893 template <class _Tp>
   894 inline _Valarray_bool _STLP_CALL operator||(const _Tp& __c, const valarray<_Tp>& __x)
   895 {
   896   _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
   897   for (size_t __i = 0; __i < __x.size(); ++__i)
   898     __tmp[__i] = __c || __x[__i];
   899   return __tmp;
   900 }
   901 
   902 // valarray "transcendentals" (the list includes abs and sqrt, which,
   903 // of course, are not transcendental).
   904 
   905 template <class _Tp>
   906 inline valarray<_Tp> abs(const valarray<_Tp>& __x) {
   907   typedef typename valarray<_Tp>::_NoInit _NoInit;
   908   valarray<_Tp> __tmp(__x.size(), _NoInit());
   909   for (size_t __i = 0; __i < __x.size(); ++__i)
   910     __tmp[__i] = ::abs(__x[__i]);
   911   return __tmp;
   912 }
   913 
   914 template <class _Tp>
   915 inline valarray<_Tp> acos(const valarray<_Tp>& __x) {
   916   typedef typename valarray<_Tp>::_NoInit _NoInit;
   917   valarray<_Tp> __tmp(__x.size(), _NoInit());
   918   for (size_t __i = 0; __i < __x.size(); ++__i)
   919     __tmp[__i] = ::acos(__x[__i]);
   920   return __tmp;
   921 }
   922 
   923 template <class _Tp>
   924 inline valarray<_Tp> asin(const valarray<_Tp>& __x) {
   925   typedef typename valarray<_Tp>::_NoInit _NoInit;
   926   valarray<_Tp> __tmp(__x.size(), _NoInit());
   927   for (size_t __i = 0; __i < __x.size(); ++__i)
   928     __tmp[__i] = ::asin(__x[__i]);
   929   return __tmp;
   930 }
   931 
   932 template <class _Tp>
   933 inline valarray<_Tp> atan(const valarray<_Tp>& __x) {
   934   typedef typename valarray<_Tp>::_NoInit _NoInit;
   935   valarray<_Tp> __tmp(__x.size(), _NoInit());
   936   for (size_t __i = 0; __i < __x.size(); ++__i)
   937     __tmp[__i] = ::atan(__x[__i]);
   938   return __tmp;
   939 }
   940 
   941 template <class _Tp>
   942 inline valarray<_Tp> atan2(const valarray<_Tp>& __x,
   943                            const valarray<_Tp>& __y) {
   944   typedef typename valarray<_Tp>::_NoInit _NoInit;
   945   valarray<_Tp> __tmp(__x.size(), _NoInit());
   946   for (size_t __i = 0; __i < __x.size(); ++__i)
   947     __tmp[__i] = ::atan2(__x[__i], __y[__i]);
   948   return __tmp;
   949 }
   950 
   951 template <class _Tp>
   952 inline valarray<_Tp> atan2(const valarray<_Tp>& __x, const _Tp& __c) {
   953   typedef typename valarray<_Tp>::_NoInit _NoInit;
   954   valarray<_Tp> __tmp(__x.size(), _NoInit());
   955   for (size_t __i = 0; __i < __x.size(); ++__i)
   956     __tmp[__i] = ::atan2(__x[__i], __c);
   957   return __tmp;
   958 }
   959 
   960 template <class _Tp>
   961 inline valarray<_Tp> atan2(const _Tp& __c, const valarray<_Tp>& __x) {
   962   typedef typename valarray<_Tp>::_NoInit _NoInit;
   963   valarray<_Tp> __tmp(__x.size(), _NoInit());
   964   for (size_t __i = 0; __i < __x.size(); ++__i)
   965     __tmp[__i] = ::atan2(__c, __x[__i]);
   966   return __tmp;
   967 }
   968 
   969 template <class _Tp>
   970 inline valarray<_Tp> cos(const valarray<_Tp>& __x) {
   971   typedef typename valarray<_Tp>::_NoInit _NoInit;
   972   valarray<_Tp> __tmp(__x.size(), _NoInit());
   973   for (size_t __i = 0; __i < __x.size(); ++__i)
   974     __tmp[__i] = ::cos(__x[__i]);
   975   return __tmp;
   976 }
   977 
   978 template <class _Tp>
   979 inline valarray<_Tp> cosh(const valarray<_Tp>& __x) {
   980   typedef typename valarray<_Tp>::_NoInit _NoInit;
   981   valarray<_Tp> __tmp(__x.size(), _NoInit());
   982   for (size_t __i = 0; __i < __x.size(); ++__i)
   983     __tmp[__i] = ::cosh(__x[__i]);
   984   return __tmp;
   985 }
   986 
   987 template <class _Tp>
   988 inline valarray<_Tp> exp(const valarray<_Tp>& __x) {
   989   typedef typename valarray<_Tp>::_NoInit _NoInit;
   990   valarray<_Tp> __tmp(__x.size(), _NoInit());
   991   for (size_t __i = 0; __i < __x.size(); ++__i)
   992     __tmp[__i] = ::exp(__x[__i]);
   993   return __tmp;
   994 }
   995 
   996 template <class _Tp>
   997 inline valarray<_Tp> log(const valarray<_Tp>& __x) {
   998   typedef typename valarray<_Tp>::_NoInit _NoInit;
   999   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1000   for (size_t __i = 0; __i < __x.size(); ++__i)
  1001     __tmp[__i] = ::log(__x[__i]);
  1002   return __tmp;
  1003 }
  1004 
  1005 template <class _Tp>
  1006 inline valarray<_Tp> log10(const valarray<_Tp>& __x) {
  1007   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1008   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1009   for (size_t __i = 0; __i < __x.size(); ++__i)
  1010     __tmp[__i] = ::log10(__x[__i]);
  1011   return __tmp;
  1012 }
  1013 
  1014 template <class _Tp>
  1015 inline valarray<_Tp> pow(const valarray<_Tp>& __x,
  1016                          const valarray<_Tp>& __y) {
  1017   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1018   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1019   for (size_t __i = 0; __i < __x.size(); ++__i)
  1020     __tmp[__i] = ::pow(__x[__i], __y[__i]);
  1021   return __tmp;
  1022 }
  1023 
  1024 template <class _Tp>
  1025 inline valarray<_Tp> pow(const valarray<_Tp>& __x, const _Tp& __c) {
  1026   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1027   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1028   for (size_t __i = 0; __i < __x.size(); ++__i)
  1029     __tmp[__i] = ::pow(__x[__i], __c);
  1030   return __tmp;
  1031 }
  1032 
  1033 template <class _Tp>
  1034 inline valarray<_Tp> pow(const _Tp& __c, const valarray<_Tp>& __x) {
  1035   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1036   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1037   for (size_t __i = 0; __i < __x.size(); ++__i)
  1038     __tmp[__i] = ::pow(__c, __x[__i]);
  1039   return __tmp;
  1040 }
  1041 
  1042 template <class _Tp>
  1043 inline valarray<_Tp> sin(const valarray<_Tp>& __x) {
  1044   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1045   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1046   for (size_t __i = 0; __i < __x.size(); ++__i)
  1047     __tmp[__i] = ::sin(__x[__i]);
  1048   return __tmp;
  1049 }
  1050 
  1051 template <class _Tp>
  1052 inline valarray<_Tp> sinh(const valarray<_Tp>& __x) {
  1053   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1054   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1055   for (size_t __i = 0; __i < __x.size(); ++__i)
  1056     __tmp[__i] = ::sinh(__x[__i]);
  1057   return __tmp;
  1058 }
  1059 
  1060 template <class _Tp>
  1061 inline valarray<_Tp> sqrt(const valarray<_Tp>& __x) {
  1062   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1063   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1064   for (size_t __i = 0; __i < __x.size(); ++__i)
  1065     __tmp[__i] = ::sqrt(__x[__i]);
  1066   return __tmp;
  1067 }
  1068 
  1069 template <class _Tp>
  1070 inline valarray<_Tp> tan(const valarray<_Tp>& __x) {
  1071   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1072   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1073   for (size_t __i = 0; __i < __x.size(); ++__i)
  1074     __tmp[__i] = ::tan(__x[__i]);
  1075   return __tmp;
  1076 }
  1077 
  1078 template <class _Tp>
  1079 inline valarray<_Tp> tanh(const valarray<_Tp>& __x) {
  1080   typedef typename valarray<_Tp>::_NoInit _NoInit;
  1081   valarray<_Tp> __tmp(__x.size(), _NoInit());
  1082   for (size_t __i = 0; __i < __x.size(); ++__i)
  1083     __tmp[__i] = ::tanh(__x[__i]);
  1084   return __tmp;
  1085 }
  1086 
  1087 //----------------------------------------------------------------------
  1088 // slice and slice_array
  1089 
  1090 class slice {
  1091 public:
  1092   slice() : _M_start(0), _M_length(0), _M_stride(0) {}
  1093   slice(size_t __start, size_t __length, size_t __stride)
  1094     : _M_start(__start), _M_length(__length), _M_stride(__stride)
  1095     {}
  1096   __TRIVIAL_DESTRUCTOR(slice)
  1097 
  1098   size_t start()  const { return _M_start; }
  1099   size_t size()   const { return _M_length; }
  1100   size_t stride() const { return _M_stride; }
  1101 
  1102 private:
  1103   size_t _M_start;
  1104   size_t _M_length;
  1105   size_t _M_stride;
  1106 };
  1107 
  1108 template <class _Tp>
  1109 class slice_array {
  1110   friend class valarray<_Tp>;
  1111 public:
  1112   typedef _Tp value_type;
  1113 
  1114   void operator=(const valarray<value_type>& __x) const {
  1115     size_t __index = _M_slice.start();
  1116     for (size_t __i = 0;
  1117          __i < _M_slice.size();
  1118          ++__i, __index += _M_slice.stride())
  1119       _M_array[__index] = __x[__i];
  1120   }
  1121 
  1122   void operator*=(const valarray<value_type>& __x) const {
  1123     size_t __index = _M_slice.start();
  1124     for (size_t __i = 0;
  1125          __i < _M_slice.size();
  1126          ++__i, __index += _M_slice.stride())
  1127       _M_array[__index] *= __x[__i];
  1128   }
  1129 
  1130   void operator/=(const valarray<value_type>& __x) const {
  1131     size_t __index = _M_slice.start();
  1132     for (size_t __i = 0;
  1133          __i < _M_slice.size();
  1134          ++__i, __index += _M_slice.stride())
  1135       _M_array[__index] /= __x[__i];
  1136   }
  1137 
  1138   void operator%=(const valarray<value_type>& __x) const {
  1139     size_t __index = _M_slice.start();
  1140     for (size_t __i = 0;
  1141          __i < _M_slice.size();
  1142          ++__i, __index += _M_slice.stride())
  1143       _M_array[__index] %= __x[__i];
  1144   }
  1145 
  1146   void operator+=(const valarray<value_type>& __x) const {
  1147     size_t __index = _M_slice.start();
  1148     for (size_t __i = 0;
  1149          __i < _M_slice.size();
  1150          ++__i, __index += _M_slice.stride())
  1151       _M_array[__index] += __x[__i];
  1152   }
  1153 
  1154   void operator-=(const valarray<value_type>& __x) const {
  1155     size_t __index = _M_slice.start();
  1156     for (size_t __i = 0;
  1157          __i < _M_slice.size();
  1158          ++__i, __index += _M_slice.stride())
  1159       _M_array[__index] -= __x[__i];
  1160   }
  1161 
  1162   void operator^=(const valarray<value_type>& __x) const {
  1163     size_t __index = _M_slice.start();
  1164     for (size_t __i = 0;
  1165          __i < _M_slice.size();
  1166          ++__i, __index += _M_slice.stride())
  1167       _M_array[__index] ^= __x[__i];
  1168   }
  1169 
  1170   void operator&=(const valarray<value_type>& __x) const {
  1171     size_t __index = _M_slice.start();
  1172     for (size_t __i = 0;
  1173          __i < _M_slice.size();
  1174          ++__i, __index += _M_slice.stride())
  1175       _M_array[__index] &= __x[__i];
  1176   }
  1177 
  1178   void operator|=(const valarray<value_type>& __x) const {
  1179     size_t __index = _M_slice.start();
  1180     for (size_t __i = 0;
  1181          __i < _M_slice.size();
  1182          ++__i, __index += _M_slice.stride())
  1183       _M_array[__index] |= __x[__i];
  1184   }
  1185 
  1186   void operator<<=(const valarray<value_type>& __x) const {
  1187     size_t __index = _M_slice.start();
  1188     for (size_t __i = 0;
  1189          __i < _M_slice.size();
  1190          ++__i, __index += _M_slice.stride())
  1191       _M_array[__index] <<= __x[__i];
  1192   }
  1193 
  1194   void operator>>=(const valarray<value_type>& __x) const {
  1195     size_t __index = _M_slice.start();
  1196     for (size_t __i = 0;
  1197          __i < _M_slice.size();
  1198          ++__i, __index += _M_slice.stride())
  1199       _M_array[__index] >>= __x[__i];
  1200   }
  1201 
  1202   void operator=(const value_type& __c) /*const could be const but standard says NO (26.3.5.4-1)*/ {
  1203     size_t __index = _M_slice.start();
  1204     for (size_t __i = 0;
  1205          __i < _M_slice.size();
  1206          ++__i, __index += _M_slice.stride())
  1207       _M_array[__index] = __c;
  1208   }
  1209 
  1210   ~slice_array() {}
  1211 
  1212 private:
  1213   slice_array(const slice& __slice, valarray<_Tp>& __array)
  1214     : _M_slice(__slice), _M_array(__array)
  1215     {}
  1216 
  1217   slice          _M_slice;
  1218   valarray<_Tp>& _M_array;
  1219 
  1220 private:                        // Disable assignment and default constructor
  1221   slice_array();
  1222   slice_array(const slice_array&);
  1223   slice_array& operator=(const slice_array&);
  1224 };
  1225 
  1226 // valarray member functions dealing with slice and slice_array
  1227 
  1228 template <class _Tp>
  1229 inline valarray<_Tp>::valarray(const slice_array<_Tp>& __x)
  1230   : _Valarray_base<_Tp>(__x._M_slice.size()) {
  1231   typedef typename __type_traits<_Tp>::has_trivial_default_constructor
  1232           _Is_Trivial;
  1233   _M_initialize(_Is_Trivial());
  1234   *this = __x;
  1235 }
  1236 
  1237 
  1238 template <class _Tp>
  1239 inline slice_array<_Tp> valarray<_Tp>::operator[](slice __slice) {
  1240   return slice_array<_Tp>(__slice, *this);
  1241 }
  1242 
  1243 //----------------------------------------------------------------------
  1244 // gslice and gslice_array
  1245 
  1246 template <class _Size>
  1247 struct _Gslice_Iter_tmpl;
  1248 
  1249 class gslice {
  1250   friend struct _Gslice_Iter_tmpl<size_t>;
  1251 public:
  1252   gslice() : _M_start(0), _M_lengths(0), _M_strides(0) {}
  1253   gslice(size_t __start,
  1254          const _Valarray_size_t& __lengths, const _Valarray_size_t& __strides)
  1255     : _M_start(__start), _M_lengths(__lengths), _M_strides(__strides)
  1256     {}
  1257   __TRIVIAL_DESTRUCTOR(gslice)
  1258 
  1259   size_t start()            const { return _M_start; }
  1260   _Valarray_size_t size()   const { return _M_lengths; }
  1261   _Valarray_size_t stride() const { return _M_strides; }
  1262 
  1263   // Extension: check for an empty gslice.
  1264   bool _M_empty() const { return _M_lengths.size() == 0; }
  1265 
  1266   // Extension: number of indices this gslice represents.  (For a degenerate
  1267   // gslice, they're not necessarily all distinct.)
  1268   size_t _M_size() const {
  1269     return !this->_M_empty()
  1270       ? accumulate(_M_lengths._M_first + 1,
  1271                    _M_lengths._M_first + _M_lengths._M_size,
  1272                    _M_lengths[0],
  1273                    multiplies<size_t>())
  1274       : 0;
  1275   }
  1276 
  1277 # ifndef __HP_aCC
  1278 private:
  1279 # endif
  1280 
  1281   size_t _M_start;
  1282   _Valarray_size_t _M_lengths;
  1283   _Valarray_size_t _M_strides;
  1284 };
  1285 
  1286 // This is not an STL iterator.  It is constructed from a gslice, and it
  1287 // steps through the gslice indices in sequence.  See 23.3.6 of the C++
  1288 // standard, paragraphs 2-3, for an explanation of the sequence.  At
  1289 // each step we get two things: the ordinal (i.e. number of steps taken),
  1290 // and the one-dimensional index.
  1291 
  1292 template <class _Size>
  1293 struct _Gslice_Iter_tmpl {
  1294   _Gslice_Iter_tmpl(const gslice& __gslice)
  1295     : _M_step(0), _M_1d_idx(__gslice.start()),
  1296       _M_indices(size_t(0), __gslice._M_lengths.size()),
  1297       _M_gslice(__gslice)
  1298     {}
  1299 
  1300   bool _M_done() const { return _M_indices[0] == _M_gslice._M_lengths[0]; }
  1301 
  1302   bool _M_incr();
  1303 
  1304   _Size _M_step;
  1305   _Size _M_1d_idx;
  1306 
  1307   valarray<_Size> _M_indices;
  1308   const gslice& _M_gslice;
  1309 };
  1310 
  1311 typedef _Gslice_Iter_tmpl<size_t> _Gslice_Iter;
  1312 
  1313 template <class _Tp>
  1314 class gslice_array {
  1315   friend class valarray<_Tp>;
  1316 public:
  1317   typedef _Tp value_type;
  1318 
  1319   void operator= (const valarray<value_type>& __x) const {
  1320     if (!_M_gslice._M_empty()) {
  1321       _Gslice_Iter __i(_M_gslice);
  1322       do _M_array[__i._M_1d_idx] = __x[__i._M_step]; while(__i._M_incr());
  1323     }
  1324   }
  1325 
  1326   void operator*= (const valarray<value_type>& __x) const {
  1327     if (!_M_gslice._M_empty()) {
  1328       _Gslice_Iter __i(_M_gslice);
  1329       do _M_array[__i._M_1d_idx] *= __x[__i._M_step]; while(__i._M_incr());
  1330     }
  1331   }
  1332 
  1333   void operator/= (const valarray<value_type>& __x) const {
  1334     if (!_M_gslice._M_empty()) {
  1335       _Gslice_Iter __i(_M_gslice);
  1336       do _M_array[__i._M_1d_idx] /= __x[__i._M_step]; while(__i._M_incr());
  1337     }
  1338   }
  1339 
  1340   void operator%= (const valarray<value_type>& __x) const {
  1341     if (!_M_gslice._M_empty()) {
  1342       _Gslice_Iter __i(_M_gslice);
  1343       do _M_array[__i._M_1d_idx] %= __x[__i._M_step]; while(__i._M_incr());
  1344     }
  1345   }
  1346 
  1347   void operator+= (const valarray<value_type>& __x) const {
  1348     if (!_M_gslice._M_empty()) {
  1349       _Gslice_Iter __i(_M_gslice);
  1350       do _M_array[__i._M_1d_idx] += __x[__i._M_step]; while(__i._M_incr());
  1351     }
  1352   }
  1353 
  1354   void operator-= (const valarray<value_type>& __x) const {
  1355     if (!_M_gslice._M_empty()) {
  1356       _Gslice_Iter __i(_M_gslice);
  1357       do _M_array[__i._M_1d_idx] -= __x[__i._M_step]; while(__i._M_incr());
  1358     }
  1359   }
  1360 
  1361   void operator^= (const valarray<value_type>& __x) const {
  1362     if (!_M_gslice._M_empty()) {
  1363       _Gslice_Iter __i(_M_gslice);
  1364       do _M_array[__i._M_1d_idx] ^= __x[__i._M_step]; while(__i._M_incr());
  1365     }
  1366   }
  1367 
  1368   void operator&= (const valarray<value_type>& __x) const {
  1369     if (!_M_gslice._M_empty()) {
  1370       _Gslice_Iter __i(_M_gslice);
  1371       do _M_array[__i._M_1d_idx] &= __x[__i._M_step]; while(__i._M_incr());
  1372     }
  1373   }
  1374 
  1375   void operator|= (const valarray<value_type>& __x) const {
  1376     if (!_M_gslice._M_empty()) {
  1377       _Gslice_Iter __i(_M_gslice);
  1378       do _M_array[__i._M_1d_idx] |= __x[__i._M_step]; while(__i._M_incr());
  1379     }
  1380   }
  1381 
  1382   void operator<<= (const valarray<value_type>& __x) const {
  1383     if (!_M_gslice._M_empty()) {
  1384       _Gslice_Iter __i(_M_gslice);
  1385       do _M_array[__i._M_1d_idx] <<= __x[__i._M_step]; while(__i._M_incr());
  1386     }
  1387   }
  1388 
  1389   void operator>>= (const valarray<value_type>& __x) const {
  1390     if (!_M_gslice._M_empty()) {
  1391       _Gslice_Iter __i(_M_gslice);
  1392       do _M_array[__i._M_1d_idx] >>= __x[__i._M_step]; while(__i._M_incr());
  1393     }
  1394   }
  1395 
  1396   void operator= (const value_type& __c) /*const could be const but standard says NO (26.3.7.4-1)*/ {
  1397     if (!_M_gslice._M_empty()) {
  1398       _Gslice_Iter __i(_M_gslice);
  1399       do _M_array[__i._M_1d_idx] = __c; while(__i._M_incr());
  1400     }
  1401   }
  1402 
  1403   ~gslice_array() {}
  1404 
  1405 private:
  1406   gslice_array(const gslice& __gslice, valarray<_Tp>& __array)
  1407     : _M_gslice(__gslice), _M_array(__array)
  1408     {}
  1409 
  1410   gslice                _M_gslice;
  1411   valarray<value_type>& _M_array;
  1412 
  1413 private:                        // Disable assignment
  1414   void operator=(const gslice_array<_Tp>&);
  1415 };
  1416 
  1417 // valarray member functions dealing with gslice and gslice_array.  Note
  1418 // that it is illegal (behavior is undefined) to construct a gslice_array
  1419 // from a degenerate gslice.
  1420 
  1421 template <class _Tp>
  1422 inline valarray<_Tp>::valarray(const gslice_array<_Tp>& __x)
  1423   : _Valarray_base<_Tp>(__x._M_gslice._M_size()) {
  1424   typedef typename __type_traits<_Tp>::has_trivial_default_constructor
  1425           _Is_Trivial;
  1426   _M_initialize(_Is_Trivial());
  1427   *this = __x;
  1428 }
  1429 
  1430 template <class _Tp>
  1431 inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __slice) {
  1432   return gslice_array<_Tp>(__slice, *this);
  1433 }
  1434 
  1435 
  1436 //----------------------------------------------------------------------
  1437 // mask_array
  1438 
  1439 template <class _Tp>
  1440 class mask_array {
  1441   friend class valarray<_Tp>;
  1442 public:
  1443   typedef _Tp value_type;
  1444 
  1445   void operator=(const valarray<value_type>& __x) const {
  1446     size_t __idx = 0;
  1447     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1448       if (_M_mask[__i]) _M_array[__i] = __x[__idx++];
  1449   }
  1450 
  1451   void operator*=(const valarray<value_type>& __x) const {
  1452     size_t __idx = 0;
  1453     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1454       if (_M_mask[__i]) _M_array[__i] *= __x[__idx++];
  1455   }
  1456 
  1457   void operator/=(const valarray<value_type>& __x) const {
  1458     size_t __idx = 0;
  1459     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1460       if (_M_mask[__i]) _M_array[__i] /= __x[__idx++];
  1461   }
  1462 
  1463   void operator%=(const valarray<value_type>& __x) const {
  1464     size_t __idx = 0;
  1465     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1466       if (_M_mask[__i]) _M_array[__i] %= __x[__idx++];
  1467   }
  1468 
  1469   void operator+=(const valarray<value_type>& __x) const {
  1470     size_t __idx = 0;
  1471     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1472       if (_M_mask[__i]) _M_array[__i] += __x[__idx++];
  1473   }
  1474 
  1475   void operator-=(const valarray<value_type>& __x) const {
  1476     size_t __idx = 0;
  1477     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1478       if (_M_mask[__i]) _M_array[__i] -= __x[__idx++];
  1479   }
  1480 
  1481   void operator^=(const valarray<value_type>& __x) const {
  1482     size_t __idx = 0;
  1483     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1484       if (_M_mask[__i]) _M_array[__i] ^= __x[__idx++];
  1485   }
  1486 
  1487   void operator&=(const valarray<value_type>& __x) const {
  1488     size_t __idx = 0;
  1489     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1490       if (_M_mask[__i]) _M_array[__i] &= __x[__idx++];
  1491   }
  1492 
  1493   void operator|=(const valarray<value_type>& __x) const {
  1494     size_t __idx = 0;
  1495     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1496       if (_M_mask[__i]) _M_array[__i] |= __x[__idx++];
  1497   }
  1498 
  1499   void operator<<=(const valarray<value_type>& __x) const {
  1500     size_t __idx = 0;
  1501     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1502       if (_M_mask[__i]) _M_array[__i] <<= __x[__idx++];
  1503   }
  1504 
  1505   void operator>>=(const valarray<value_type>& __x) const {
  1506     size_t __idx = 0;
  1507     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1508       if (_M_mask[__i]) _M_array[__i] >>= __x[__idx++];
  1509   }
  1510 
  1511   void operator=(const value_type& __c) const {
  1512     for (size_t __i = 0; __i < _M_array.size(); ++__i)
  1513       if (_M_mask[__i]) _M_array[__i] = __c;
  1514   }
  1515 
  1516   ~mask_array() {}
  1517 
  1518   // Extension: number of true values in the mask
  1519   size_t _M_num_true() const {
  1520     size_t __result = 0;
  1521     for (size_t __i = 0; __i < _M_mask.size(); ++__i)
  1522       if (_M_mask[__i]) ++__result;
  1523     return __result;
  1524   }
  1525 
  1526 private:
  1527   mask_array(const _Valarray_bool& __mask, valarray<_Tp>& __array)
  1528     : _M_mask(__mask), _M_array(__array)
  1529     {}
  1530 
  1531   _Valarray_bool _M_mask;
  1532   valarray<_Tp>& _M_array;
  1533 
  1534 private:                        // Disable assignment
  1535   void operator=(const mask_array<_Tp>&);
  1536 };
  1537 
  1538 // valarray member functions dealing with mask_array
  1539 
  1540 template <class _Tp>
  1541 inline valarray<_Tp>::valarray(const mask_array<_Tp>& __x)
  1542   : _Valarray_base<_Tp>(__x._M_num_true())
  1543 {
  1544   typedef typename __type_traits<_Tp>::has_trivial_default_constructor
  1545           _Is_Trivial;
  1546   _M_initialize(_Is_Trivial());
  1547   *this = __x;
  1548 }
  1549 
  1550 // Behavior is undefined if __x._M_num_true() != this->size()
  1551 template <class _Tp>
  1552 inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __x) {
  1553   size_t __idx = 0;
  1554   for (size_t __i = 0; __i < __x._M_array.size(); ++__i)
  1555     if (__x._M_mask[__i]) (*this)[__idx++] = __x._M_array[__i];
  1556   return *this;
  1557 }
  1558 
  1559 template <class _Tp>
  1560 inline mask_array<_Tp> valarray<_Tp>::operator[](const _Valarray_bool& __mask)
  1561 {
  1562   return mask_array<_Tp>(__mask, *this);
  1563 }
  1564 
  1565 
  1566 //----------------------------------------------------------------------
  1567 // indirect_array
  1568 
  1569 template <class _Tp>
  1570 class indirect_array {
  1571   friend class valarray<_Tp>;
  1572 public:
  1573   typedef _Tp value_type;
  1574 
  1575   void operator=(const valarray<value_type>& __x) const {
  1576     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1577       _M_array[_M_addr[__i]] = __x[__i];
  1578   }
  1579 
  1580   void operator*=(const valarray<value_type>& __x) const {
  1581     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1582       _M_array[_M_addr[__i]] *= __x[__i];
  1583   }
  1584 
  1585   void operator/=(const valarray<value_type>& __x) const {
  1586     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1587       _M_array[_M_addr[__i]] /= __x[__i];
  1588   }
  1589 
  1590   void operator%=(const valarray<value_type>& __x) const {
  1591     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1592       _M_array[_M_addr[__i]] %= __x[__i];
  1593   }
  1594 
  1595   void operator+=(const valarray<value_type>& __x) const {
  1596     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1597       _M_array[_M_addr[__i]] += __x[__i];
  1598   }
  1599 
  1600   void operator-=(const valarray<value_type>& __x) const {
  1601     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1602       _M_array[_M_addr[__i]] -= __x[__i];
  1603   }
  1604 
  1605   void operator^=(const valarray<value_type>& __x) const {
  1606     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1607       _M_array[_M_addr[__i]] ^= __x[__i];
  1608   }
  1609 
  1610   void operator&=(const valarray<value_type>& __x) const {
  1611     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1612       _M_array[_M_addr[__i]] &= __x[__i];
  1613   }
  1614 
  1615   void operator|=(const valarray<value_type>& __x) const {
  1616     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1617       _M_array[_M_addr[__i]] |= __x[__i];
  1618   }
  1619 
  1620   void operator<<=(const valarray<value_type>& __x) const {
  1621     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1622       _M_array[_M_addr[__i]] <<= __x[__i];
  1623   }
  1624 
  1625   void operator>>=(const valarray<value_type>& __x) const {
  1626     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1627       _M_array[_M_addr[__i]] >>= __x[__i];
  1628   }
  1629 
  1630   void operator=(const value_type& __c) const {
  1631     for (size_t __i = 0; __i < _M_addr.size(); ++__i)
  1632       _M_array[_M_addr[__i]] = __c;
  1633   }
  1634 
  1635   ~indirect_array() {}
  1636 
  1637 private:
  1638   indirect_array(const _Valarray_size_t& __addr, valarray<_Tp>& __array)
  1639     : _M_addr(__addr), _M_array(__array)
  1640     {}
  1641 
  1642   _Valarray_size_t _M_addr;
  1643   valarray<_Tp>&   _M_array;
  1644 
  1645 private:                        // Disable assignment
  1646   void operator=(const indirect_array<_Tp>&);
  1647 };
  1648 
  1649 // valarray member functions dealing with indirect_array
  1650 
  1651 template <class _Tp>
  1652 inline valarray<_Tp>::valarray(const indirect_array<_Tp>& __x)
  1653   : _Valarray_base<_Tp>(__x._M_addr.size())
  1654 {
  1655   typedef typename __type_traits<_Tp>::has_trivial_default_constructor
  1656           _Is_Trivial;
  1657   _M_initialize(_Is_Trivial());
  1658   *this = __x;
  1659 }
  1660 
  1661 
  1662 template <class _Tp>
  1663 inline indirect_array<_Tp>
  1664 valarray<_Tp>::operator[](const _Valarray_size_t& __addr)
  1665 {
  1666   return indirect_array<_Tp>(__addr, *this);
  1667 }
  1668 
  1669 _STLP_END_NAMESPACE
  1670 
  1671 # if !defined (_STLP_LINK_TIME_INSTANTIATION)
  1672 #  include <stl/_valarray.c>
  1673 # endif
  1674 
  1675 #endif /* _STLP_VALARRAY */
  1676 
  1677 
  1678 // Local Variables:
  1679 // mode:C++
  1680 // End: