1.1 --- a/epoc32/include/stdapis/stlport/stl/_valarray.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_valarray.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,1791 @@
1.4 -_valarray.h
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + * Copyright (c) 1999
1.8 + * Silicon Graphics Computer Systems, Inc.
1.9 + *
1.10 + * Copyright (c) 1999
1.11 + * Boris Fomitchev
1.12 + *
1.13 + * This material is provided "as is", with absolutely no warranty expressed
1.14 + * or implied. Any use is at your own risk.
1.15 + *
1.16 + * Permission to use or copy this software for any purpose is hereby granted
1.17 + * without fee, provided the above notices are retained on all copies.
1.18 + * Permission to modify the code and to distribute modified code is granted,
1.19 + * provided the above notices are retained, and a notice that the code was
1.20 + * modified is included with the above copyright notice.
1.21 + *
1.22 + */
1.23 +
1.24 +#ifndef _STLP_VALARRAY_H
1.25 +#define _STLP_VALARRAY_H
1.26 +
1.27 +#ifndef _STLP_CMATH_H_HEADER
1.28 +#include <stl/_cmath.h>
1.29 +#endif
1.30 +#ifndef _STLP_INTERNAL_NEW_HEADER
1.31 +#include <stl/_new.h>
1.32 +#endif
1.33 +#ifndef _STLP_INTERNAL_ALGO_H
1.34 +#include <stl/_algo.h>
1.35 +#endif
1.36 +#ifndef _STLP_INTERNAL_NUMERIC_H
1.37 +#include <stl/_numeric.h>
1.38 +#endif
1.39 +#ifndef _STLP_LIMITS_H
1.40 +#include <limits>
1.41 +#endif
1.42 +
1.43 +//To resolve the unidentified identifier __THROW_BAD_ALLOC
1.44 +#include <stl/_alloc.h>
1.45 +
1.46 +_STLP_BEGIN_NAMESPACE
1.47 +
1.48 +class slice;
1.49 +class gslice;
1.50 +
1.51 +template <class _Tp> class valarray;
1.52 +typedef valarray<bool> _Valarray_bool;
1.53 +typedef valarray<size_t> _Valarray_size_t;
1.54 +
1.55 +template <class _Tp> class slice_array;
1.56 +template <class _Tp> class gslice_array;
1.57 +template <class _Tp> class mask_array;
1.58 +template <class _Tp> class indirect_array;
1.59 +
1.60 +//----------------------------------------------------------------------
1.61 +// class valarray
1.62 +
1.63 +// Base class to handle memory allocation and deallocation. We can't just
1.64 +// use vector<>, because vector<bool> would be unsuitable as an internal
1.65 +// representation for valarray<bool>.
1.66 +
1.67 +template <class _Tp>
1.68 +struct _Valarray_base
1.69 +{
1.70 + _Tp* _M_first;
1.71 + size_t _M_size;
1.72 +
1.73 + _Valarray_base() : _M_first(0), _M_size(0) {}
1.74 + _Valarray_base(size_t __n) : _M_first(0), _M_size(0) { _M_allocate(__n); }
1.75 + ~_Valarray_base() { _M_deallocate(); }
1.76 +
1.77 + void _M_allocate(size_t __n) {
1.78 + if (__n != 0) {
1.79 +#ifdef __SYMBIAN32__
1.80 + _M_first = ::new _Tp[__n];
1.81 +#else
1.82 + _M_first = __STATIC_CAST(_Tp*, (malloc(__n * sizeof(_Tp))));
1.83 +#endif
1.84 + _M_size = __n;
1.85 + if (_M_first == 0) {
1.86 + _M_size = 0;
1.87 + __THROW_BAD_ALLOC;
1.88 + }
1.89 + }
1.90 + else {
1.91 + _M_first = 0;
1.92 + _M_size = 0;
1.93 + }
1.94 + }
1.95 +
1.96 + void _M_deallocate() {
1.97 +#ifdef __SYMBIAN32__
1.98 + delete [] _M_first;
1.99 +#else
1.100 + free(_M_first);
1.101 +#endif
1.102 + _M_first = 0;
1.103 + _M_size = 0;
1.104 + }
1.105 +};
1.106 +
1.107 +template <class _Tp>
1.108 +class valarray : private _Valarray_base<_Tp>
1.109 +{
1.110 + friend class gslice;
1.111 +
1.112 +public:
1.113 + typedef _Tp value_type;
1.114 +
1.115 + // Basic constructors
1.116 + valarray() : _Valarray_base<_Tp>() {}
1.117 + valarray(size_t __n) : _Valarray_base<_Tp>(__n) {}
1.118 + valarray(const value_type& __x, size_t __n) : _Valarray_base<_Tp>(__n)
1.119 + { uninitialized_fill_n(this->_M_first, this->_M_size, __x); }
1.120 + valarray(const value_type* __p, size_t __n) : _Valarray_base<_Tp>(__n)
1.121 + { uninitialized_copy(__p, __p + __n, this->_M_first); }
1.122 + valarray(const valarray<_Tp>& __x) : _Valarray_base<_Tp>(__x._M_size) {
1.123 + uninitialized_copy(__x._M_first, __x._M_first + __x._M_size,
1.124 + this->_M_first);
1.125 + }
1.126 +
1.127 + // Constructors from auxiliary array types
1.128 + valarray(const slice_array<_Tp>&);
1.129 + valarray(const gslice_array<_Tp>&);
1.130 + valarray(const mask_array<_Tp>&);
1.131 + valarray(const indirect_array<_Tp>&);
1.132 +
1.133 + // Destructor
1.134 + ~valarray() { _STLP_STD::_Destroy(this->_M_first, this->_M_first + this->_M_size); }
1.135 +
1.136 + // Extension: constructor that doesn't initialize valarray elements to a
1.137 + // specific value. This is faster for types such as int and double.
1.138 +private:
1.139 + void _M_initialize(const __true_type&) {}
1.140 + void _M_initialize(const __false_type&)
1.141 + { uninitialized_fill_n(this->_M_first, this->_M_size, value_type()); }
1.142 +
1.143 +public:
1.144 + struct _NoInit {};
1.145 + valarray(size_t __n, _NoInit) : _Valarray_base<_Tp>(__n) {
1.146 + typedef typename __type_traits<_Tp>::has_trivial_default_constructor _Is_Trivial;
1.147 + _M_initialize(_Is_Trivial());
1.148 + }
1.149 +
1.150 +public: // Assignment
1.151 + // Basic assignment. Note that 'x = y' is undefined if x.size() != y.size()
1.152 + valarray<_Tp>& operator=(const valarray<_Tp>& __x) {
1.153 + _STLP_ASSERT(__x.size() == this->size())
1.154 + if (this != &__x)
1.155 + {
1.156 +#ifdef __SYMBIAN32__
1.157 + resize(__x._M_size);
1.158 +#endif
1.159 + copy(__x._M_first, __x._M_first + __x._M_size, this->_M_first);
1.160 + }
1.161 + return *this;
1.162 + }
1.163 +
1.164 + // Scalar assignment
1.165 + valarray<_Tp>& operator=(const value_type& __x) {
1.166 + fill_n(this->_M_first, this->_M_size, __x);
1.167 + return *this;
1.168 + }
1.169 +
1.170 + // Assignment of auxiliary array types
1.171 + valarray<_Tp>& operator=(const slice_array<_Tp>&);
1.172 + valarray<_Tp>& operator=(const gslice_array<_Tp>&);
1.173 + valarray<_Tp>& operator=(const mask_array<_Tp>&);
1.174 + valarray<_Tp>& operator=(const indirect_array<_Tp>&);
1.175 +
1.176 +public: // Element access
1.177 + value_type operator[](size_t __n) const { return this->_M_first[__n]; }
1.178 + value_type& operator[](size_t __n) { return this->_M_first[__n]; }
1.179 + size_t size() const { return this->_M_size; }
1.180 +
1.181 +public: // Subsetting operations with auxiliary type
1.182 + valarray<_Tp> operator[](slice) const;
1.183 + slice_array<_Tp> operator[](slice);
1.184 + valarray<_Tp> operator[](gslice) const;
1.185 + gslice_array<_Tp> operator[](const gslice&);
1.186 + valarray<_Tp> operator[](const _Valarray_bool&) const;
1.187 + mask_array<_Tp> operator[](const _Valarray_bool&);
1.188 + valarray<_Tp> operator[](const _Valarray_size_t&) const;
1.189 + indirect_array<_Tp> operator[](const _Valarray_size_t&);
1.190 +
1.191 +public: // Unary operators.
1.192 + valarray<_Tp> operator+() const { return *this; }
1.193 +
1.194 + valarray<_Tp> operator-() const {
1.195 + valarray<_Tp> __tmp(this->size(), _NoInit());
1.196 + for (size_t __i = 0; __i < this->size(); ++__i)
1.197 + __tmp[__i] = -(*this)[__i];
1.198 + return __tmp;
1.199 + }
1.200 +
1.201 + valarray<_Tp> operator~() const {
1.202 + valarray<_Tp> __tmp(this->size(), _NoInit());
1.203 + for (size_t __i = 0; __i < this->size(); ++__i)
1.204 + __tmp[__i] = ~(*this)[__i];
1.205 + return __tmp;
1.206 + }
1.207 +
1.208 + _Valarray_bool operator!() const;
1.209 +
1.210 +public: // Scalar computed assignment.
1.211 + valarray<_Tp>& operator*= (const value_type& __x) {
1.212 + for (size_t __i = 0; __i < this->size(); ++__i)
1.213 + (*this)[__i] *= __x;
1.214 + return *this;
1.215 + }
1.216 +
1.217 + valarray<_Tp>& operator/= (const value_type& __x) {
1.218 + for (size_t __i = 0; __i < this->size(); ++__i)
1.219 + (*this)[__i] /= __x;
1.220 + return *this;
1.221 + }
1.222 +
1.223 + valarray<_Tp>& operator%= (const value_type& __x) {
1.224 + for (size_t __i = 0; __i < this->size(); ++__i)
1.225 + (*this)[__i] %= __x;
1.226 + return *this;
1.227 + }
1.228 +
1.229 + valarray<_Tp>& operator+= (const value_type& __x) {
1.230 + for (size_t __i = 0; __i < this->size(); ++__i)
1.231 + (*this)[__i] += __x;
1.232 + return *this;
1.233 + }
1.234 +
1.235 + valarray<_Tp>& operator-= (const value_type& __x) {
1.236 + for (size_t __i = 0; __i < this->size(); ++__i)
1.237 + (*this)[__i] -= __x;
1.238 + return *this;
1.239 + }
1.240 +
1.241 + valarray<_Tp>& operator^= (const value_type& __x) {
1.242 + for (size_t __i = 0; __i < this->size(); ++__i)
1.243 + (*this)[__i] ^= __x;
1.244 + return *this;
1.245 + }
1.246 +
1.247 + valarray<_Tp>& operator&= (const value_type& __x) {
1.248 + for (size_t __i = 0; __i < this->size(); ++__i)
1.249 + (*this)[__i] &= __x;
1.250 + return *this;
1.251 + }
1.252 +
1.253 + valarray<_Tp>& operator|= (const value_type& __x) {
1.254 + for (size_t __i = 0; __i < this->size(); ++__i)
1.255 + (*this)[__i] |= __x;
1.256 + return *this;
1.257 + }
1.258 +
1.259 + valarray<_Tp>& operator<<= (const value_type& __x) {
1.260 + for (size_t __i = 0; __i < this->size(); ++__i)
1.261 + (*this)[__i] <<= __x;
1.262 + return *this;
1.263 + }
1.264 +
1.265 + valarray<_Tp>& operator>>= (const value_type& __x) {
1.266 + for (size_t __i = 0; __i < this->size(); ++__i)
1.267 + (*this)[__i] >>= __x;
1.268 + return *this;
1.269 + }
1.270 +
1.271 +public: // Array computed assignment.
1.272 + valarray<_Tp>& operator*= (const valarray<_Tp>& __x) {
1.273 + for (size_t __i = 0; __i < this->size(); ++__i)
1.274 + (*this)[__i] *= __x[__i];
1.275 + return *this;
1.276 + }
1.277 +
1.278 + valarray<_Tp>& operator/= (const valarray<_Tp>& __x) {
1.279 + for (size_t __i = 0; __i < this->size(); ++__i)
1.280 + (*this)[__i] /= __x[__i];
1.281 + return *this;
1.282 + }
1.283 +
1.284 + valarray<_Tp>& operator%= (const valarray<_Tp>& __x) {
1.285 + for (size_t __i = 0; __i < this->size(); ++__i)
1.286 + (*this)[__i] %= __x[__i];
1.287 + return *this;
1.288 + }
1.289 +
1.290 + valarray<_Tp>& operator+= (const valarray<_Tp>& __x) {
1.291 + for (size_t __i = 0; __i < this->size(); ++__i)
1.292 + (*this)[__i] += __x[__i];
1.293 + return *this;
1.294 + }
1.295 +
1.296 + valarray<_Tp>& operator-= (const valarray<_Tp>& __x) {
1.297 + for (size_t __i = 0; __i < this->size(); ++__i)
1.298 + (*this)[__i] -= __x[__i];
1.299 + return *this;
1.300 + }
1.301 +
1.302 + valarray<_Tp>& operator^= (const valarray<_Tp>& __x) {
1.303 + for (size_t __i = 0; __i < this->size(); ++__i)
1.304 + (*this)[__i] ^= __x[__i];
1.305 + return *this;
1.306 + }
1.307 +
1.308 + valarray<_Tp>& operator&= (const valarray<_Tp>& __x) {
1.309 + for (size_t __i = 0; __i < this->size(); ++__i)
1.310 + (*this)[__i] &= __x[__i];
1.311 + return *this;
1.312 + }
1.313 +
1.314 + valarray<_Tp>& operator|= (const valarray<_Tp>& __x) {
1.315 + for (size_t __i = 0; __i < this->size(); ++__i)
1.316 + (*this)[__i] |= __x[__i];
1.317 + return *this;
1.318 + }
1.319 +
1.320 + valarray<_Tp>& operator<<= (const valarray<_Tp>& __x) {
1.321 + for (size_t __i = 0; __i < this->size(); ++__i)
1.322 + (*this)[__i] <<= __x[__i];
1.323 + return *this;
1.324 + }
1.325 +
1.326 + valarray<_Tp>& operator>>= (const valarray<_Tp>& __x) {
1.327 + for (size_t __i = 0; __i < this->size(); ++__i)
1.328 + (*this)[__i] >>= __x[__i];
1.329 + return *this;
1.330 + }
1.331 +
1.332 +public: // Other member functions.
1.333 +
1.334 + // The result is undefined for zero-length arrays
1.335 + value_type sum() const {
1.336 + return accumulate(this->_M_first + 1, this->_M_first + this->_M_size,
1.337 + (*this)[0]);
1.338 + }
1.339 +
1.340 + // The result is undefined for zero-length arrays
1.341 + value_type (min) () const {
1.342 + return *min_element(this->_M_first + 0, this->_M_first + this->_M_size);
1.343 + }
1.344 +
1.345 + value_type (max) () const {
1.346 + return *max_element(this->_M_first + 0, this->_M_first + this->_M_size);
1.347 + }
1.348 +
1.349 + valarray<_Tp> shift(int __n) const;
1.350 + valarray<_Tp> cshift(int __n) const;
1.351 +
1.352 + valarray<_Tp> apply(value_type __f(value_type)) const {
1.353 + valarray<_Tp> __tmp(this->size());
1.354 + transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first,
1.355 + __f);
1.356 + return __tmp;
1.357 + }
1.358 + valarray<_Tp> apply(value_type __f(const value_type&)) const {
1.359 + valarray<_Tp> __tmp(this->size());
1.360 + transform(this->_M_first + 0, this->_M_first + this->_M_size, __tmp._M_first,
1.361 + __f);
1.362 + return __tmp;
1.363 + }
1.364 +
1.365 + void resize(size_t __n, value_type __x = value_type()) {
1.366 + _STLP_STD::_Destroy(this->_M_first, this->_M_first + this->_M_size);
1.367 + this->_Valarray_base<_Tp>::_M_deallocate();
1.368 + this->_Valarray_base<_Tp>::_M_allocate(__n);
1.369 + uninitialized_fill_n(this->_M_first, this->_M_size, __x);
1.370 + }
1.371 +};
1.372 +
1.373 +//----------------------------------------------------------------------
1.374 +// valarray non-member functions.
1.375 +
1.376 +// Binary arithmetic operations between two arrays. Behavior is
1.377 +// undefined if the two arrays do not have the same length.
1.378 +
1.379 +template <class _Tp>
1.380 +inline valarray<_Tp> _STLP_CALL operator*(const valarray<_Tp>& __x,
1.381 + const valarray<_Tp>& __y) {
1.382 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.383 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.384 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.385 + __tmp[__i] = __x[__i] * __y[__i];
1.386 + return __tmp;
1.387 +}
1.388 +
1.389 +template <class _Tp>
1.390 +inline valarray<_Tp> _STLP_CALL operator/(const valarray<_Tp>& __x,
1.391 + const valarray<_Tp>& __y) {
1.392 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.393 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.394 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.395 + __tmp[__i] = __x[__i] / __y[__i];
1.396 + return __tmp;
1.397 +}
1.398 +
1.399 +template <class _Tp>
1.400 +inline valarray<_Tp> _STLP_CALL operator%(const valarray<_Tp>& __x,
1.401 + const valarray<_Tp>& __y) {
1.402 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.403 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.404 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.405 + __tmp[__i] = __x[__i] % __y[__i];
1.406 + return __tmp;
1.407 +}
1.408 +
1.409 +template <class _Tp>
1.410 +inline valarray<_Tp> _STLP_CALL operator+(const valarray<_Tp>& __x,
1.411 + const valarray<_Tp>& __y) {
1.412 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.413 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.414 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.415 + __tmp[__i] = __x[__i] + __y[__i];
1.416 + return __tmp;
1.417 +}
1.418 +
1.419 +template <class _Tp>
1.420 +inline valarray<_Tp> _STLP_CALL operator-(const valarray<_Tp>& __x,
1.421 + const valarray<_Tp>& __y) {
1.422 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.423 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.424 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.425 + __tmp[__i] = __x[__i] - __y[__i];
1.426 + return __tmp;
1.427 +}
1.428 +
1.429 +template <class _Tp>
1.430 +inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x,
1.431 + const valarray<_Tp>& __y) {
1.432 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.433 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.434 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.435 + __tmp[__i] = __x[__i] ^ __y[__i];
1.436 + return __tmp;
1.437 +}
1.438 +
1.439 +template <class _Tp>
1.440 +inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x,
1.441 + const valarray<_Tp>& __y) {
1.442 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.443 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.444 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.445 + __tmp[__i] = __x[__i] & __y[__i];
1.446 + return __tmp;
1.447 +}
1.448 +
1.449 +template <class _Tp>
1.450 +inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x,
1.451 + const valarray<_Tp>& __y) {
1.452 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.453 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.454 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.455 + __tmp[__i] = __x[__i] | __y[__i];
1.456 + return __tmp;
1.457 +}
1.458 +
1.459 +template <class _Tp>
1.460 +inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x,
1.461 + const valarray<_Tp>& __y) {
1.462 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.463 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.464 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.465 + __tmp[__i] = __x[__i] << __y[__i];
1.466 + return __tmp;
1.467 +}
1.468 +
1.469 +template <class _Tp>
1.470 +inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x,
1.471 + const valarray<_Tp>& __y) {
1.472 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.473 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.474 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.475 + __tmp[__i] = __x[__i] >> __y[__i];
1.476 + return __tmp;
1.477 +}
1.478 +
1.479 +// Binary arithmetic operations between an array and a scalar.
1.480 +
1.481 +template <class _Tp>
1.482 +inline valarray<_Tp> _STLP_CALL operator*(const valarray<_Tp>& __x, const _Tp& __c) {
1.483 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.484 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.485 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.486 + __tmp[__i] = __x[__i] * __c;
1.487 + return __tmp;
1.488 +}
1.489 +
1.490 +template <class _Tp>
1.491 +inline valarray<_Tp> _STLP_CALL operator*(const _Tp& __c, const valarray<_Tp>& __x) {
1.492 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.493 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.494 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.495 + __tmp[__i] = __c * __x[__i];
1.496 + return __tmp;
1.497 +}
1.498 +
1.499 +template <class _Tp>
1.500 +inline valarray<_Tp> _STLP_CALL operator/(const valarray<_Tp>& __x, const _Tp& __c) {
1.501 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.502 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.503 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.504 + __tmp[__i] = __x[__i] / __c;
1.505 + return __tmp;
1.506 +}
1.507 +
1.508 +template <class _Tp>
1.509 +inline valarray<_Tp> _STLP_CALL operator/(const _Tp& __c, const valarray<_Tp>& __x) {
1.510 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.511 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.512 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.513 + __tmp[__i] = __c / __x[__i];
1.514 + return __tmp;
1.515 +}
1.516 +
1.517 +template <class _Tp>
1.518 +inline valarray<_Tp> _STLP_CALL operator%(const valarray<_Tp>& __x, const _Tp& __c) {
1.519 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.520 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.521 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.522 + __tmp[__i] = __x[__i] % __c;
1.523 + return __tmp;
1.524 +}
1.525 +
1.526 +template <class _Tp>
1.527 +inline valarray<_Tp> _STLP_CALL operator%(const _Tp& __c, const valarray<_Tp>& __x) {
1.528 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.529 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.530 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.531 + __tmp[__i] = __c % __x[__i];
1.532 + return __tmp;
1.533 +}
1.534 +
1.535 +template <class _Tp>
1.536 +inline valarray<_Tp> _STLP_CALL operator+(const valarray<_Tp>& __x, const _Tp& __c) {
1.537 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.538 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.539 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.540 + __tmp[__i] = __x[__i] + __c;
1.541 + return __tmp;
1.542 +}
1.543 +
1.544 +template <class _Tp>
1.545 +inline valarray<_Tp> _STLP_CALL operator+(const _Tp& __c, const valarray<_Tp>& __x) {
1.546 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.547 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.548 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.549 + __tmp[__i] = __c + __x[__i];
1.550 + return __tmp;
1.551 +}
1.552 +
1.553 +template <class _Tp>
1.554 +inline valarray<_Tp> _STLP_CALL operator-(const valarray<_Tp>& __x, const _Tp& __c) {
1.555 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.556 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.557 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.558 + __tmp[__i] = __x[__i] - __c;
1.559 + return __tmp;
1.560 +}
1.561 +
1.562 +template <class _Tp>
1.563 +inline valarray<_Tp> _STLP_CALL operator-(const _Tp& __c, const valarray<_Tp>& __x) {
1.564 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.565 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.566 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.567 + __tmp[__i] = __c - __x[__i];
1.568 + return __tmp;
1.569 +}
1.570 +
1.571 +template <class _Tp>
1.572 +inline valarray<_Tp> _STLP_CALL operator^(const valarray<_Tp>& __x, const _Tp& __c) {
1.573 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.574 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.575 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.576 + __tmp[__i] = __x[__i] ^ __c;
1.577 + return __tmp;
1.578 +}
1.579 +
1.580 +template <class _Tp>
1.581 +inline valarray<_Tp> _STLP_CALL operator^(const _Tp& __c, const valarray<_Tp>& __x) {
1.582 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.583 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.584 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.585 + __tmp[__i] = __c ^ __x[__i];
1.586 + return __tmp;
1.587 +}
1.588 +
1.589 +template <class _Tp>
1.590 +inline valarray<_Tp> _STLP_CALL operator&(const valarray<_Tp>& __x, const _Tp& __c) {
1.591 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.592 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.593 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.594 + __tmp[__i] = __x[__i] & __c;
1.595 + return __tmp;
1.596 +}
1.597 +
1.598 +template <class _Tp>
1.599 +inline valarray<_Tp> _STLP_CALL operator&(const _Tp& __c, const valarray<_Tp>& __x) {
1.600 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.601 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.602 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.603 + __tmp[__i] = __c & __x[__i];
1.604 + return __tmp;
1.605 +}
1.606 +
1.607 +template <class _Tp>
1.608 +inline valarray<_Tp> _STLP_CALL operator|(const valarray<_Tp>& __x, const _Tp& __c) {
1.609 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.610 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.611 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.612 + __tmp[__i] = __x[__i] | __c;
1.613 + return __tmp;
1.614 +}
1.615 +
1.616 +template <class _Tp>
1.617 +inline valarray<_Tp> _STLP_CALL operator|(const _Tp& __c, const valarray<_Tp>& __x) {
1.618 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.619 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.620 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.621 + __tmp[__i] = __c | __x[__i];
1.622 + return __tmp;
1.623 +}
1.624 +
1.625 +template <class _Tp>
1.626 +inline valarray<_Tp> _STLP_CALL operator<<(const valarray<_Tp>& __x, const _Tp& __c) {
1.627 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.628 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.629 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.630 + __tmp[__i] = __x[__i] << __c;
1.631 + return __tmp;
1.632 +}
1.633 +
1.634 +template <class _Tp>
1.635 +inline valarray<_Tp> _STLP_CALL operator<<(const _Tp& __c, const valarray<_Tp>& __x) {
1.636 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.637 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.638 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.639 + __tmp[__i] = __c << __x[__i];
1.640 + return __tmp;
1.641 +}
1.642 +
1.643 +template <class _Tp>
1.644 +inline valarray<_Tp> _STLP_CALL operator>>(const valarray<_Tp>& __x, const _Tp& __c) {
1.645 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.646 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.647 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.648 + __tmp[__i] = __x[__i] >> __c;
1.649 + return __tmp;
1.650 +}
1.651 +
1.652 +template <class _Tp>
1.653 +inline valarray<_Tp> _STLP_CALL operator>>(const _Tp& __c, const valarray<_Tp>& __x) {
1.654 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.655 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.656 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.657 + __tmp[__i] = __c >> __x[__i];
1.658 + return __tmp;
1.659 +}
1.660 +
1.661 +// Binary logical operations between two arrays. Behavior is undefined
1.662 +// if the two arrays have different lengths. Note that operator== does
1.663 +// not do what you might at first expect.
1.664 +
1.665 +template <class _Tp>
1.666 +inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x,
1.667 + const valarray<_Tp>& __y)
1.668 +{
1.669 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.670 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.671 + __tmp[__i] = __x[__i] == __y[__i];
1.672 + return __tmp;
1.673 +}
1.674 +
1.675 +template <class _Tp>
1.676 +inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x,
1.677 + const valarray<_Tp>& __y)
1.678 +{
1.679 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.680 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.681 + __tmp[__i] = __x[__i] < __y[__i];
1.682 + return __tmp;
1.683 +}
1.684 +
1.685 +#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
1.686 +
1.687 +template <class _Tp>
1.688 +inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x,
1.689 + const valarray<_Tp>& __y)
1.690 +{
1.691 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.692 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.693 + __tmp[__i] = __x[__i] != __y[__i];
1.694 + return __tmp;
1.695 +}
1.696 +
1.697 +template <class _Tp>
1.698 +inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x,
1.699 + const valarray<_Tp>& __y)
1.700 +{
1.701 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.702 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.703 + __tmp[__i] = __x[__i] > __y[__i];
1.704 + return __tmp;
1.705 +}
1.706 +
1.707 +template <class _Tp>
1.708 +inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x,
1.709 + const valarray<_Tp>& __y)
1.710 +{
1.711 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.712 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.713 + __tmp[__i] = __x[__i] <= __y[__i];
1.714 + return __tmp;
1.715 +}
1.716 +
1.717 +template <class _Tp>
1.718 +inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x,
1.719 + const valarray<_Tp>& __y)
1.720 +{
1.721 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.722 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.723 + __tmp[__i] = __x[__i] >= __y[__i];
1.724 + return __tmp;
1.725 +}
1.726 +
1.727 +#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
1.728 +// fbp : swap ?
1.729 +
1.730 +template <class _Tp>
1.731 +inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x,
1.732 + const valarray<_Tp>& __y)
1.733 +{
1.734 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.735 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.736 + __tmp[__i] = __x[__i] && __y[__i];
1.737 + return __tmp;
1.738 +}
1.739 +
1.740 +template <class _Tp>
1.741 +inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x,
1.742 + const valarray<_Tp>& __y)
1.743 +{
1.744 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.745 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.746 + __tmp[__i] = __x[__i] || __y[__i];
1.747 + return __tmp;
1.748 +}
1.749 +
1.750 +// Logical operations between an array and a scalar.
1.751 +
1.752 +template <class _Tp>
1.753 +inline _Valarray_bool _STLP_CALL operator==(const valarray<_Tp>& __x, const _Tp& __c)
1.754 +{
1.755 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.756 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.757 + __tmp[__i] = __x[__i] == __c;
1.758 + return __tmp;
1.759 +}
1.760 +
1.761 +template <class _Tp>
1.762 +inline _Valarray_bool _STLP_CALL operator==(const _Tp& __c, const valarray<_Tp>& __x)
1.763 +{
1.764 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.765 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.766 + __tmp[__i] = __c == __x[__i];
1.767 + return __tmp;
1.768 +}
1.769 +
1.770 +template <class _Tp>
1.771 +inline _Valarray_bool _STLP_CALL operator!=(const valarray<_Tp>& __x, const _Tp& __c)
1.772 +{
1.773 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.774 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.775 + __tmp[__i] = __x[__i] != __c;
1.776 + return __tmp;
1.777 +}
1.778 +
1.779 +template <class _Tp>
1.780 +inline _Valarray_bool _STLP_CALL operator!=(const _Tp& __c, const valarray<_Tp>& __x)
1.781 +{
1.782 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.783 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.784 + __tmp[__i] = __c != __x[__i];
1.785 + return __tmp;
1.786 +}
1.787 +
1.788 +template <class _Tp>
1.789 +inline _Valarray_bool _STLP_CALL operator<(const valarray<_Tp>& __x, const _Tp& __c)
1.790 +{
1.791 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.792 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.793 + __tmp[__i] = __x[__i] < __c;
1.794 + return __tmp;
1.795 +}
1.796 +
1.797 +template <class _Tp>
1.798 +inline _Valarray_bool _STLP_CALL operator<(const _Tp& __c, const valarray<_Tp>& __x)
1.799 +{
1.800 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.801 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.802 + __tmp[__i] = __c < __x[__i];
1.803 + return __tmp;
1.804 +}
1.805 +
1.806 +template <class _Tp>
1.807 +inline _Valarray_bool _STLP_CALL operator>(const valarray<_Tp>& __x, const _Tp& __c)
1.808 +{
1.809 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.810 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.811 + __tmp[__i] = __x[__i] > __c;
1.812 + return __tmp;
1.813 +}
1.814 +
1.815 +template <class _Tp>
1.816 +inline _Valarray_bool _STLP_CALL operator>(const _Tp& __c, const valarray<_Tp>& __x)
1.817 +{
1.818 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.819 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.820 + __tmp[__i] = __c > __x[__i];
1.821 + return __tmp;
1.822 +}
1.823 +
1.824 +template <class _Tp>
1.825 +inline _Valarray_bool _STLP_CALL operator<=(const valarray<_Tp>& __x, const _Tp& __c)
1.826 +{
1.827 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.828 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.829 + __tmp[__i] = __x[__i] <= __c;
1.830 + return __tmp;
1.831 +}
1.832 +
1.833 +template <class _Tp>
1.834 +inline _Valarray_bool _STLP_CALL operator<=(const _Tp& __c, const valarray<_Tp>& __x)
1.835 +{
1.836 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.837 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.838 + __tmp[__i] = __c <= __x[__i];
1.839 + return __tmp;
1.840 +}
1.841 +
1.842 +template <class _Tp>
1.843 +inline _Valarray_bool _STLP_CALL operator>=(const valarray<_Tp>& __x, const _Tp& __c)
1.844 +{
1.845 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.846 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.847 + __tmp[__i] = __x[__i] >= __c;
1.848 + return __tmp;
1.849 +}
1.850 +
1.851 +template <class _Tp>
1.852 +inline _Valarray_bool _STLP_CALL operator>=(const _Tp& __c, const valarray<_Tp>& __x)
1.853 +{
1.854 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.855 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.856 + __tmp[__i] = __c >= __x[__i];
1.857 + return __tmp;
1.858 +}
1.859 +
1.860 +template <class _Tp>
1.861 +inline _Valarray_bool _STLP_CALL operator&&(const valarray<_Tp>& __x, const _Tp& __c)
1.862 +{
1.863 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.864 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.865 + __tmp[__i] = __x[__i] && __c;
1.866 + return __tmp;
1.867 +}
1.868 +
1.869 +template <class _Tp>
1.870 +inline _Valarray_bool _STLP_CALL operator&&(const _Tp& __c, const valarray<_Tp>& __x)
1.871 +{
1.872 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.873 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.874 + __tmp[__i] = __c && __x[__i];
1.875 + return __tmp;
1.876 +}
1.877 +
1.878 +template <class _Tp>
1.879 +inline _Valarray_bool _STLP_CALL operator||(const valarray<_Tp>& __x, const _Tp& __c)
1.880 +{
1.881 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.882 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.883 + __tmp[__i] = __x[__i] || __c;
1.884 + return __tmp;
1.885 +}
1.886 +
1.887 +template <class _Tp>
1.888 +inline _Valarray_bool _STLP_CALL operator||(const _Tp& __c, const valarray<_Tp>& __x)
1.889 +{
1.890 + _Valarray_bool __tmp(__x.size(), _Valarray_bool::_NoInit());
1.891 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.892 + __tmp[__i] = __c || __x[__i];
1.893 + return __tmp;
1.894 +}
1.895 +
1.896 +// valarray "transcendentals" (the list includes abs and sqrt, which,
1.897 +// of course, are not transcendental).
1.898 +
1.899 +template <class _Tp>
1.900 +inline valarray<_Tp> abs(const valarray<_Tp>& __x) {
1.901 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.902 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.903 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.904 + __tmp[__i] = _STLP_DO_ABS(_Tp)(__x[__i]);
1.905 + return __tmp;
1.906 +}
1.907 +
1.908 +template <class _Tp>
1.909 +inline valarray<_Tp> acos(const valarray<_Tp>& __x) {
1.910 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.911 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.912 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.913 + __tmp[__i] = _STLP_DO_ACOS(_Tp)(__x[__i]);
1.914 + return __tmp;
1.915 +}
1.916 +
1.917 +template <class _Tp>
1.918 +inline valarray<_Tp> asin(const valarray<_Tp>& __x) {
1.919 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.920 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.921 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.922 + __tmp[__i] = _STLP_DO_ASIN(_Tp)(__x[__i]);
1.923 + return __tmp;
1.924 +}
1.925 +
1.926 +template <class _Tp>
1.927 +inline valarray<_Tp> atan(const valarray<_Tp>& __x) {
1.928 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.929 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.930 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.931 + __tmp[__i] = _STLP_DO_ATAN(_Tp)(__x[__i]);
1.932 + return __tmp;
1.933 +}
1.934 +
1.935 +template <class _Tp>
1.936 +inline valarray<_Tp> atan2(const valarray<_Tp>& __x,
1.937 + const valarray<_Tp>& __y) {
1.938 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.939 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.940 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.941 + __tmp[__i] = _STLP_DO_ATAN2(_Tp)(__x[__i], __y[__i]);
1.942 + return __tmp;
1.943 +}
1.944 +
1.945 +template <class _Tp>
1.946 +inline valarray<_Tp> atan2(const valarray<_Tp>& __x, const _Tp& __c) {
1.947 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.948 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.949 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.950 + __tmp[__i] = _STLP_DO_ATAN2(_Tp)(__x[__i], __c);
1.951 + return __tmp;
1.952 +}
1.953 +
1.954 +template <class _Tp>
1.955 +inline valarray<_Tp> atan2(const _Tp& __c, const valarray<_Tp>& __x) {
1.956 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.957 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.958 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.959 + __tmp[__i] = _STLP_DO_ATAN2(_Tp)(__c, __x[__i]);
1.960 + return __tmp;
1.961 +}
1.962 +
1.963 +template <class _Tp>
1.964 +inline valarray<_Tp> cos(const valarray<_Tp>& __x) {
1.965 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.966 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.967 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.968 + __tmp[__i] = _STLP_DO_COS(_Tp)(__x[__i]);
1.969 + return __tmp;
1.970 +}
1.971 +
1.972 +template <class _Tp>
1.973 +inline valarray<_Tp> cosh(const valarray<_Tp>& __x) {
1.974 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.975 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.976 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.977 + __tmp[__i] = _STLP_DO_COSH(_Tp)(__x[__i]);
1.978 + return __tmp;
1.979 +}
1.980 +
1.981 +template <class _Tp>
1.982 +inline valarray<_Tp> exp(const valarray<_Tp>& __x) {
1.983 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.984 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.985 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.986 + __tmp[__i] = _STLP_DO_EXP(_Tp)(__x[__i]);
1.987 + return __tmp;
1.988 +}
1.989 +
1.990 +template <class _Tp>
1.991 +inline valarray<_Tp> log(const valarray<_Tp>& __x) {
1.992 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.993 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.994 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.995 + __tmp[__i] = _STLP_DO_LOG(_Tp)(__x[__i]);
1.996 + return __tmp;
1.997 +}
1.998 +
1.999 +template <class _Tp>
1.1000 +inline valarray<_Tp> log10(const valarray<_Tp>& __x) {
1.1001 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1002 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1003 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1004 + __tmp[__i] = _STLP_DO_LOG10(_Tp)(__x[__i]);
1.1005 + return __tmp;
1.1006 +}
1.1007 +
1.1008 +template <class _Tp>
1.1009 +inline valarray<_Tp> pow(const valarray<_Tp>& __x,
1.1010 + const valarray<_Tp>& __y) {
1.1011 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1012 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1013 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1014 + __tmp[__i] = _STLP_DO_POW(_Tp)(__x[__i], __y[__i]);
1.1015 + return __tmp;
1.1016 +}
1.1017 +
1.1018 +template <class _Tp>
1.1019 +inline valarray<_Tp> pow(const valarray<_Tp>& __x, const _Tp& __c) {
1.1020 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1021 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1022 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1023 + __tmp[__i] = _STLP_DO_POW(_Tp)(__x[__i], __c);
1.1024 + return __tmp;
1.1025 +}
1.1026 +
1.1027 +template <class _Tp>
1.1028 +inline valarray<_Tp> pow(const _Tp& __c, const valarray<_Tp>& __x) {
1.1029 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1030 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1031 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1032 + __tmp[__i] = _STLP_DO_POW(_Tp)(__c, __x[__i]);
1.1033 + return __tmp;
1.1034 +}
1.1035 +
1.1036 +template <class _Tp>
1.1037 +inline valarray<_Tp> sin(const valarray<_Tp>& __x) {
1.1038 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1039 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1040 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1041 + __tmp[__i] = _STLP_DO_SIN(_Tp)(__x[__i]);
1.1042 + return __tmp;
1.1043 +}
1.1044 +
1.1045 +template <class _Tp>
1.1046 +inline valarray<_Tp> sinh(const valarray<_Tp>& __x) {
1.1047 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1048 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1049 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1050 + __tmp[__i] = _STLP_DO_SINH(_Tp)(__x[__i]);
1.1051 + return __tmp;
1.1052 +}
1.1053 +
1.1054 +template <class _Tp>
1.1055 +inline valarray<_Tp> sqrt(const valarray<_Tp>& __x) {
1.1056 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1057 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1058 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1059 + __tmp[__i] = _STLP_DO_SQRT(_Tp)(__x[__i]);
1.1060 + return __tmp;
1.1061 +}
1.1062 +
1.1063 +template <class _Tp>
1.1064 +inline valarray<_Tp> tan(const valarray<_Tp>& __x) {
1.1065 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1066 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1067 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1068 + __tmp[__i] = _STLP_DO_TAN(_Tp)(__x[__i]);
1.1069 + return __tmp;
1.1070 +}
1.1071 +
1.1072 +template <class _Tp>
1.1073 +inline valarray<_Tp> tanh(const valarray<_Tp>& __x) {
1.1074 + typedef typename valarray<_Tp>::_NoInit _NoInit;
1.1075 + valarray<_Tp> __tmp(__x.size(), _NoInit());
1.1076 + for (size_t __i = 0; __i < __x.size(); ++__i)
1.1077 + __tmp[__i] = _STLP_DO_TANH(_Tp)(__x[__i]);
1.1078 + return __tmp;
1.1079 +}
1.1080 +
1.1081 +//----------------------------------------------------------------------
1.1082 +// slice and slice_array
1.1083 +
1.1084 +class slice {
1.1085 +public:
1.1086 + slice() : _M_start(0), _M_length(0), _M_stride(0) {}
1.1087 + slice(size_t __start, size_t __length, size_t __stride)
1.1088 + : _M_start(__start), _M_length(__length), _M_stride(__stride)
1.1089 + {}
1.1090 + __TRIVIAL_DESTRUCTOR(slice)
1.1091 +
1.1092 + size_t start() const { return _M_start; }
1.1093 + size_t size() const { return _M_length; }
1.1094 + size_t stride() const { return _M_stride; }
1.1095 +
1.1096 +
1.1097 +private:
1.1098 + size_t _M_start;
1.1099 + size_t _M_length;
1.1100 + size_t _M_stride;
1.1101 +};
1.1102 +
1.1103 +template <class _Tp>
1.1104 +class slice_array {
1.1105 + friend class valarray<_Tp>;
1.1106 +public:
1.1107 + typedef _Tp value_type;
1.1108 +
1.1109 + void operator=(const valarray<value_type>& __x) const {
1.1110 + size_t __index = _M_slice.start();
1.1111 + for (size_t __i = 0;
1.1112 + __i < _M_slice.size();
1.1113 + ++__i, __index += _M_slice.stride())
1.1114 +#ifdef __SYMBIAN32__
1.1115 + (*_M_array)[__index] = __x[__i];
1.1116 +#else
1.1117 + _M_array[__index] = __x[__i];
1.1118 +#endif
1.1119 + }
1.1120 +
1.1121 + void operator*=(const valarray<value_type>& __x) const {
1.1122 + size_t __index = _M_slice.start();
1.1123 + for (size_t __i = 0;
1.1124 + __i < _M_slice.size();
1.1125 + ++__i, __index += _M_slice.stride())
1.1126 +#ifdef __SYMBIAN32__
1.1127 + (*_M_array)[__index] *= __x[__i];
1.1128 +#else
1.1129 + _M_array[__index] *= __x[__i];
1.1130 +#endif
1.1131 + }
1.1132 +
1.1133 + void operator/=(const valarray<value_type>& __x) const {
1.1134 + size_t __index = _M_slice.start();
1.1135 + for (size_t __i = 0;
1.1136 + __i < _M_slice.size();
1.1137 + ++__i, __index += _M_slice.stride())
1.1138 +#ifdef __SYMBIAN32__
1.1139 + (*_M_array)[__index] /= __x[__i];
1.1140 +#else
1.1141 + _M_array[__index] /= __x[__i];
1.1142 +#endif
1.1143 + }
1.1144 +
1.1145 + void operator%=(const valarray<value_type>& __x) const {
1.1146 + size_t __index = _M_slice.start();
1.1147 + for (size_t __i = 0;
1.1148 + __i < _M_slice.size();
1.1149 + ++__i, __index += _M_slice.stride())
1.1150 +#ifdef __SYMBIAN32__
1.1151 + (*_M_array)[__index] %= __x[__i];
1.1152 +#else
1.1153 + _M_array[__index] %= __x[__i];
1.1154 +#endif
1.1155 + }
1.1156 +
1.1157 + void operator+=(const valarray<value_type>& __x) const {
1.1158 + size_t __index = _M_slice.start();
1.1159 + for (size_t __i = 0;
1.1160 + __i < _M_slice.size();
1.1161 + ++__i, __index += _M_slice.stride())
1.1162 +#ifdef __SYMBIAN32__
1.1163 + (*_M_array)[__index] += __x[__i];
1.1164 +#else
1.1165 + _M_array[__index] += __x[__i];
1.1166 +#endif
1.1167 + }
1.1168 +
1.1169 + void operator-=(const valarray<value_type>& __x) const {
1.1170 + size_t __index = _M_slice.start();
1.1171 + for (size_t __i = 0;
1.1172 + __i < _M_slice.size();
1.1173 + ++__i, __index += _M_slice.stride())
1.1174 +#ifdef __SYMBIAN32__
1.1175 + (*_M_array)[__index] -= __x[__i];
1.1176 +#else
1.1177 + _M_array[__index] -= __x[__i];
1.1178 +#endif
1.1179 + }
1.1180 +
1.1181 + void operator^=(const valarray<value_type>& __x) const {
1.1182 + size_t __index = _M_slice.start();
1.1183 + for (size_t __i = 0;
1.1184 + __i < _M_slice.size();
1.1185 + ++__i, __index += _M_slice.stride())
1.1186 +#ifdef __SYMBIAN32__
1.1187 + (*_M_array)[__index] ^= __x[__i];
1.1188 +#else
1.1189 + _M_array[__index] ^= __x[__i];
1.1190 +#endif
1.1191 + }
1.1192 +
1.1193 + void operator&=(const valarray<value_type>& __x) const {
1.1194 + size_t __index = _M_slice.start();
1.1195 + for (size_t __i = 0;
1.1196 + __i < _M_slice.size();
1.1197 + ++__i, __index += _M_slice.stride())
1.1198 +#ifdef __SYMBIAN32__
1.1199 + (*_M_array)[__index] &= __x[__i];
1.1200 +#else
1.1201 + _M_array[__index] &= __x[__i];
1.1202 +#endif
1.1203 + }
1.1204 +
1.1205 + void operator|=(const valarray<value_type>& __x) const {
1.1206 + size_t __index = _M_slice.start();
1.1207 + for (size_t __i = 0;
1.1208 + __i < _M_slice.size();
1.1209 + ++__i, __index += _M_slice.stride())
1.1210 +#ifdef __SYMBIAN32__
1.1211 + (*_M_array)[__index] |= __x[__i];
1.1212 +#else
1.1213 + _M_array[__index] |= __x[__i];
1.1214 +#endif
1.1215 + }
1.1216 +
1.1217 + void operator<<=(const valarray<value_type>& __x) const {
1.1218 + size_t __index = _M_slice.start();
1.1219 + for (size_t __i = 0;
1.1220 + __i < _M_slice.size();
1.1221 + ++__i, __index += _M_slice.stride())
1.1222 +#ifdef __SYMBIAN32__
1.1223 + (*_M_array)[__index] <<= __x[__i];
1.1224 +#else
1.1225 + _M_array[__index] <<= __x[__i];
1.1226 +#endif
1.1227 + }
1.1228 +
1.1229 + void operator>>=(const valarray<value_type>& __x) const {
1.1230 + size_t __index = _M_slice.start();
1.1231 + for (size_t __i = 0;
1.1232 + __i < _M_slice.size();
1.1233 + ++__i, __index += _M_slice.stride())
1.1234 +#ifdef __SYMBIAN32__
1.1235 + (*_M_array)[__index] >>= __x[__i];
1.1236 +#else
1.1237 + _M_array[__index] >>= __x[__i];
1.1238 +#endif
1.1239 + }
1.1240 +
1.1241 + void operator=(const value_type& __c) {
1.1242 + size_t __index = _M_slice.start();
1.1243 + for (size_t __i = 0;
1.1244 + __i < _M_slice.size();
1.1245 + ++__i, __index += _M_slice.stride())
1.1246 +#ifdef __SYMBIAN32__
1.1247 + (*_M_array)[__index] = __c;
1.1248 +#else
1.1249 + _M_array[__index] = __c;
1.1250 +#endif
1.1251 + }
1.1252 +
1.1253 + slice_array<_Tp>&
1.1254 + operator=(const slice_array<_Tp>& __a)
1.1255 + {
1.1256 + size_t __index = _M_slice.start();
1.1257 + for (size_t __i = __a._M_slice.start();
1.1258 + __i < _M_slice.size();
1.1259 + __i += __a._M_slice.stride(), __index += _M_slice.stride())
1.1260 + _M_array[__index] = __a._M_array[__index][__i];
1.1261 + return *this;
1.1262 + }
1.1263 +
1.1264 + slice_array(const slice_array<_Tp>& a)
1.1265 + : _M_slice(a._M_slice), _M_array(a._M_array){}
1.1266 +
1.1267 + ~slice_array() {}
1.1268 +
1.1269 +private:
1.1270 + slice_array(const slice& __slice, valarray<_Tp>* __array)
1.1271 + : _M_slice(__slice), _M_array(__array)
1.1272 + {}
1.1273 +
1.1274 + slice _M_slice;
1.1275 + valarray<_Tp>* _M_array;
1.1276 +
1.1277 +private: // Disable assignment and default constructor
1.1278 + slice_array();
1.1279 +};
1.1280 +
1.1281 +// valarray member functions dealing with slice and slice_array
1.1282 +
1.1283 +template <class _Tp>
1.1284 +inline valarray<_Tp>::valarray(const slice_array<_Tp>& __x)
1.1285 + : _Valarray_base<_Tp>(__x._M_slice.size())
1.1286 +{
1.1287 + typedef typename __type_traits<_Tp>::has_trivial_default_constructor
1.1288 + _Is_Trivial;
1.1289 + _M_initialize(_Is_Trivial());
1.1290 + *this = __x;
1.1291 +}
1.1292 +
1.1293 +
1.1294 +template <class _Tp>
1.1295 +inline slice_array<_Tp> valarray<_Tp>::operator[](slice __slice) {
1.1296 + return slice_array<_Tp>(__slice, this);
1.1297 +}
1.1298 +
1.1299 +//----------------------------------------------------------------------
1.1300 +// gslice and gslice_array
1.1301 +
1.1302 +template <class _Size>
1.1303 +struct _Gslice_Iter_tmpl;
1.1304 +
1.1305 +class gslice {
1.1306 + friend struct _Gslice_Iter_tmpl<size_t>;
1.1307 +public:
1.1308 + gslice() : _M_start(0), _M_lengths(0), _M_strides(0) {}
1.1309 + gslice(size_t __start,
1.1310 + const _Valarray_size_t& __lengths, const _Valarray_size_t& __strides)
1.1311 + : _M_start(__start), _M_lengths(__lengths), _M_strides(__strides)
1.1312 + {}
1.1313 + __TRIVIAL_DESTRUCTOR(gslice)
1.1314 +
1.1315 + size_t start() const { return _M_start; }
1.1316 + _Valarray_size_t size() const { return _M_lengths; }
1.1317 + _Valarray_size_t stride() const { return _M_strides; }
1.1318 +
1.1319 + // Extension: check for an empty gslice.
1.1320 + bool _M_empty() const { return _M_lengths.size() == 0; }
1.1321 +
1.1322 + // Extension: number of indices this gslice represents. (For a degenerate
1.1323 + // gslice, they're not necessarily all distinct.)
1.1324 + size_t _M_size() const {
1.1325 + return !this->_M_empty()
1.1326 + ? accumulate(_M_lengths._M_first + 1,
1.1327 + _M_lengths._M_first + _M_lengths._M_size,
1.1328 + _M_lengths[0],
1.1329 + multiplies<size_t>())
1.1330 + : 0;
1.1331 + }
1.1332 +
1.1333 +# ifndef __HP_aCC
1.1334 +private:
1.1335 +# endif
1.1336 +
1.1337 + size_t _M_start;
1.1338 + _Valarray_size_t _M_lengths;
1.1339 + _Valarray_size_t _M_strides;
1.1340 +};
1.1341 +
1.1342 +// This is not an STL iterator. It is constructed from a gslice, and it
1.1343 +// steps through the gslice indices in sequence. See 23.3.6 of the C++
1.1344 +// standard, paragraphs 2-3, for an explanation of the sequence. At
1.1345 +// each step we get two things: the ordinal (i.e. number of steps taken),
1.1346 +// and the one-dimensional index.
1.1347 +
1.1348 +template <class _Size>
1.1349 +struct _Gslice_Iter_tmpl {
1.1350 + _Gslice_Iter_tmpl(const gslice& __gslice)
1.1351 + : _M_step(0), _M_1d_idx(__gslice.start()),
1.1352 + _M_indices(size_t(0), __gslice._M_lengths.size()),
1.1353 + _M_gslice(__gslice)
1.1354 + {}
1.1355 +
1.1356 + bool _M_done() const { return _M_indices[0] == _M_gslice._M_lengths[0]; }
1.1357 +
1.1358 + bool _M_incr();
1.1359 +
1.1360 + _Size _M_step;
1.1361 + _Size _M_1d_idx;
1.1362 +
1.1363 + valarray<_Size> _M_indices;
1.1364 + const gslice& _M_gslice;
1.1365 +};
1.1366 +
1.1367 +typedef _Gslice_Iter_tmpl<size_t> _Gslice_Iter;
1.1368 +
1.1369 +template <class _Tp>
1.1370 +class gslice_array {
1.1371 + friend class valarray<_Tp>;
1.1372 +public:
1.1373 + typedef _Tp value_type;
1.1374 +
1.1375 + void operator= (const valarray<value_type>& __x) const {
1.1376 + if (!_M_gslice._M_empty()) {
1.1377 + _Gslice_Iter __i(_M_gslice);
1.1378 + do _M_array[__i._M_1d_idx] = __x[__i._M_step]; while(__i._M_incr());
1.1379 + }
1.1380 + }
1.1381 +
1.1382 + void operator*= (const valarray<value_type>& __x) const {
1.1383 + if (!_M_gslice._M_empty()) {
1.1384 + _Gslice_Iter __i(_M_gslice);
1.1385 + do _M_array[__i._M_1d_idx] *= __x[__i._M_step]; while(__i._M_incr());
1.1386 + }
1.1387 + }
1.1388 +
1.1389 + void operator/= (const valarray<value_type>& __x) const {
1.1390 + if (!_M_gslice._M_empty()) {
1.1391 + _Gslice_Iter __i(_M_gslice);
1.1392 + do _M_array[__i._M_1d_idx] /= __x[__i._M_step]; while(__i._M_incr());
1.1393 + }
1.1394 + }
1.1395 +
1.1396 + void operator%= (const valarray<value_type>& __x) const {
1.1397 + if (!_M_gslice._M_empty()) {
1.1398 + _Gslice_Iter __i(_M_gslice);
1.1399 + do _M_array[__i._M_1d_idx] %= __x[__i._M_step]; while(__i._M_incr());
1.1400 + }
1.1401 + }
1.1402 +
1.1403 + void operator+= (const valarray<value_type>& __x) const {
1.1404 + if (!_M_gslice._M_empty()) {
1.1405 + _Gslice_Iter __i(_M_gslice);
1.1406 + do _M_array[__i._M_1d_idx] += __x[__i._M_step]; while(__i._M_incr());
1.1407 + }
1.1408 + }
1.1409 +
1.1410 + void operator-= (const valarray<value_type>& __x) const {
1.1411 + if (!_M_gslice._M_empty()) {
1.1412 + _Gslice_Iter __i(_M_gslice);
1.1413 + do _M_array[__i._M_1d_idx] -= __x[__i._M_step]; while(__i._M_incr());
1.1414 + }
1.1415 + }
1.1416 +
1.1417 + void operator^= (const valarray<value_type>& __x) const {
1.1418 + if (!_M_gslice._M_empty()) {
1.1419 + _Gslice_Iter __i(_M_gslice);
1.1420 + do _M_array[__i._M_1d_idx] ^= __x[__i._M_step]; while(__i._M_incr());
1.1421 + }
1.1422 + }
1.1423 +
1.1424 + void operator&= (const valarray<value_type>& __x) const {
1.1425 + if (!_M_gslice._M_empty()) {
1.1426 + _Gslice_Iter __i(_M_gslice);
1.1427 + do _M_array[__i._M_1d_idx] &= __x[__i._M_step]; while(__i._M_incr());
1.1428 + }
1.1429 + }
1.1430 +
1.1431 + void operator|= (const valarray<value_type>& __x) const {
1.1432 + if (!_M_gslice._M_empty()) {
1.1433 + _Gslice_Iter __i(_M_gslice);
1.1434 + do _M_array[__i._M_1d_idx] |= __x[__i._M_step]; while(__i._M_incr());
1.1435 + }
1.1436 + }
1.1437 +
1.1438 + void operator<<= (const valarray<value_type>& __x) const {
1.1439 + if (!_M_gslice._M_empty()) {
1.1440 + _Gslice_Iter __i(_M_gslice);
1.1441 + do _M_array[__i._M_1d_idx] <<= __x[__i._M_step]; while(__i._M_incr());
1.1442 + }
1.1443 + }
1.1444 +
1.1445 + void operator>>= (const valarray<value_type>& __x) const {
1.1446 + if (!_M_gslice._M_empty()) {
1.1447 + _Gslice_Iter __i(_M_gslice);
1.1448 + do _M_array[__i._M_1d_idx] >>= __x[__i._M_step]; while(__i._M_incr());
1.1449 + }
1.1450 + }
1.1451 +
1.1452 + void operator= (const value_type& __c) {
1.1453 + if (!_M_gslice._M_empty()) {
1.1454 + _Gslice_Iter __i(_M_gslice);
1.1455 + do _M_array[__i._M_1d_idx] = __c; while(__i._M_incr());
1.1456 + }
1.1457 + }
1.1458 +
1.1459 + ~gslice_array() {}
1.1460 +
1.1461 +private:
1.1462 + gslice_array(gslice __gslice, valarray<_Tp>& __array)
1.1463 + : _M_gslice(__gslice), _M_array(__array)
1.1464 + {}
1.1465 +
1.1466 + gslice _M_gslice;
1.1467 + valarray<value_type>& _M_array;
1.1468 +
1.1469 +private: // Disable assignment
1.1470 + void operator=(const gslice_array<_Tp>&);
1.1471 +};
1.1472 +
1.1473 +// valarray member functions dealing with gslice and gslice_array. Note
1.1474 +// that it is illegal (behavior is undefined) to construct a gslice_array
1.1475 +// from a degenerate gslice.
1.1476 +
1.1477 +template <class _Tp>
1.1478 +inline valarray<_Tp>::valarray(const gslice_array<_Tp>& __x)
1.1479 + : _Valarray_base<_Tp>(__x._M_gslice._M_size())
1.1480 +{
1.1481 + typedef typename __type_traits<_Tp>::has_trivial_default_constructor
1.1482 + _Is_Trivial;
1.1483 + _M_initialize(_Is_Trivial());
1.1484 + *this = __x;
1.1485 +}
1.1486 +
1.1487 +template <class _Tp>
1.1488 +inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __slice) {
1.1489 + return gslice_array<_Tp>(__slice, *this);
1.1490 +}
1.1491 +
1.1492 +
1.1493 +//----------------------------------------------------------------------
1.1494 +// mask_array
1.1495 +
1.1496 +template <class _Tp>
1.1497 +class mask_array {
1.1498 + friend class valarray<_Tp>;
1.1499 +public:
1.1500 + typedef _Tp value_type;
1.1501 +
1.1502 + void operator=(const valarray<value_type>& __x) const {
1.1503 + size_t __idx = 0;
1.1504 +#ifdef __SYMBIAN32__
1.1505 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1506 +#else
1.1507 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1508 +#endif // __SYMBIAN32__
1.1509 + if (_M_mask[__i]) _M_array[__i] = __x[__idx++];
1.1510 + }
1.1511 +
1.1512 + void operator*=(const valarray<value_type>& __x) const {
1.1513 + size_t __idx = 0;
1.1514 +#ifdef __SYMBIAN32__
1.1515 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1516 +#else
1.1517 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1518 +#endif // __SYMBIAN32__
1.1519 + if (_M_mask[__i]) _M_array[__i] *= __x[__idx++];
1.1520 + }
1.1521 +
1.1522 + void operator/=(const valarray<value_type>& __x) const {
1.1523 + size_t __idx = 0;
1.1524 +#ifdef __SYMBIAN32__
1.1525 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1526 +#else
1.1527 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1528 +#endif //__SYMBIAN32__
1.1529 + if (_M_mask[__i]) _M_array[__i] /= __x[__idx++];
1.1530 + }
1.1531 +
1.1532 + void operator%=(const valarray<value_type>& __x) const {
1.1533 + size_t __idx = 0;
1.1534 +#ifdef __SYMBIAN32__
1.1535 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1536 +#else
1.1537 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1538 +#endif
1.1539 + if (_M_mask[__i]) _M_array[__i] %= __x[__idx++];
1.1540 + }
1.1541 +
1.1542 + void operator+=(const valarray<value_type>& __x) const {
1.1543 + size_t __idx = 0;
1.1544 +#ifdef __SYMBIAN32__
1.1545 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1546 +#else
1.1547 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1548 +#endif
1.1549 + if (_M_mask[__i]) _M_array[__i] += __x[__idx++];
1.1550 + }
1.1551 +
1.1552 + void operator-=(const valarray<value_type>& __x) const {
1.1553 + size_t __idx = 0;
1.1554 +#ifdef __SYMBIAN32__
1.1555 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1556 +#else
1.1557 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1558 +#endif //__SYMBIAN32__
1.1559 + if (_M_mask[__i]) _M_array[__i] -= __x[__idx++];
1.1560 + }
1.1561 +
1.1562 + void operator^=(const valarray<value_type>& __x) const {
1.1563 + size_t __idx = 0;
1.1564 +#ifdef __SYMBIAN32__
1.1565 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1566 +#else
1.1567 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1568 +#endif // __SYMBIAN32__
1.1569 + if (_M_mask[__i]) _M_array[__i] ^= __x[__idx++];
1.1570 + }
1.1571 +
1.1572 + void operator&=(const valarray<value_type>& __x) const {
1.1573 + size_t __idx = 0;
1.1574 +#ifdef __SYMBIAN32__
1.1575 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1576 +#else
1.1577 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1578 +#endif // __SYMBIAN32__
1.1579 + if (_M_mask[__i]) _M_array[__i] &= __x[__idx++];
1.1580 + }
1.1581 +
1.1582 + void operator|=(const valarray<value_type>& __x) const {
1.1583 + size_t __idx = 0;
1.1584 +#ifdef __SYMBIAN32__
1.1585 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1586 +#else
1.1587 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1588 +#endif // __SYMBIAN32__
1.1589 + if (_M_mask[__i]) _M_array[__i] |= __x[__idx++];
1.1590 + }
1.1591 +
1.1592 + void operator<<=(const valarray<value_type>& __x) const {
1.1593 + size_t __idx = 0;
1.1594 +#ifdef __SYMBIAN32__
1.1595 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1596 +#else
1.1597 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1598 +#endif // __SYMBIAN32__
1.1599 + if (_M_mask[__i]) _M_array[__i] <<= __x[__idx++];
1.1600 + }
1.1601 +
1.1602 + void operator>>=(const valarray<value_type>& __x) const {
1.1603 + size_t __idx = 0;
1.1604 +#ifdef __SYMBIAN32__
1.1605 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1606 +#else
1.1607 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1608 +#endif // __SYMBIAN32__
1.1609 + if (_M_mask[__i]) _M_array[__i] >>= __x[__idx++];
1.1610 + }
1.1611 +
1.1612 + void operator=(const value_type& __c) const {
1.1613 +#ifdef __SYMBIAN32__
1.1614 + for (size_t __i = 0; __i < _M_array.size() && __i < _M_mask.size(); ++__i)
1.1615 +#else
1.1616 + for (size_t __i = 0; __i < _M_array.size(); ++__i)
1.1617 +#endif // __SYMBIAN32__
1.1618 + if (_M_mask[__i]) _M_array[__i] = __c;
1.1619 + }
1.1620 +
1.1621 + ~mask_array() {}
1.1622 +
1.1623 + // Extension: number of true values in the mask
1.1624 + size_t _M_num_true() const {
1.1625 + size_t __result = 0;
1.1626 + for (size_t __i = 0; __i < _M_mask.size(); ++__i)
1.1627 + if (_M_mask[__i]) ++__result;
1.1628 + return __result;
1.1629 + }
1.1630 +
1.1631 +private:
1.1632 + mask_array(const _Valarray_bool& __mask, valarray<_Tp>& __array)
1.1633 + : _M_mask(__mask), _M_array(__array)
1.1634 + {}
1.1635 +
1.1636 + _Valarray_bool _M_mask;
1.1637 + valarray<_Tp>& _M_array;
1.1638 +
1.1639 +private: // Disable assignment
1.1640 + void operator=(const mask_array<_Tp>&);
1.1641 +};
1.1642 +
1.1643 +// valarray member functions dealing with mask_array
1.1644 +
1.1645 +template <class _Tp>
1.1646 +inline valarray<_Tp>::valarray(const mask_array<_Tp>& __x)
1.1647 + : _Valarray_base<_Tp>(__x._M_num_true())
1.1648 +{
1.1649 + typedef typename __type_traits<_Tp>::has_trivial_default_constructor
1.1650 + _Is_Trivial;
1.1651 + _M_initialize(_Is_Trivial());
1.1652 + *this = __x;
1.1653 +}
1.1654 +
1.1655 +// Behavior is undefined if __x._M_num_true() != this->size()
1.1656 +template <class _Tp>
1.1657 +inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array<_Tp>& __x) {
1.1658 + size_t __idx = 0;
1.1659 + for (size_t __i = 0; __i < __x._M_array.size(); ++__i)
1.1660 + if (__x._M_mask[__i])
1.1661 + {
1.1662 +#ifdef __SYMBIAN32__
1.1663 + if(__idx < this->_M_size)
1.1664 + (*this)[__idx++] = __x._M_array[__i];
1.1665 + else
1.1666 + break;
1.1667 +#else
1.1668 + (*this)[__idx++] = __x._M_array[__i];
1.1669 +#endif
1.1670 + }
1.1671 + return *this;
1.1672 +}
1.1673 +
1.1674 +template <class _Tp>
1.1675 +inline mask_array<_Tp> valarray<_Tp>::operator[](const _Valarray_bool& __mask)
1.1676 +{
1.1677 + return mask_array<_Tp>(__mask, *this);
1.1678 +}
1.1679 +
1.1680 +
1.1681 +//----------------------------------------------------------------------
1.1682 +// indirect_array
1.1683 +
1.1684 +template <class _Tp>
1.1685 +class indirect_array {
1.1686 + friend class valarray<_Tp>;
1.1687 +public:
1.1688 + typedef _Tp value_type;
1.1689 +
1.1690 + void operator=(const valarray<value_type>& __x) const {
1.1691 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1692 + _M_array[_M_addr[__i]] = __x[__i];
1.1693 + }
1.1694 +
1.1695 + void operator*=(const valarray<value_type>& __x) const {
1.1696 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1697 + _M_array[_M_addr[__i]] *= __x[__i];
1.1698 + }
1.1699 +
1.1700 + void operator/=(const valarray<value_type>& __x) const {
1.1701 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1702 + _M_array[_M_addr[__i]] /= __x[__i];
1.1703 + }
1.1704 +
1.1705 + void operator%=(const valarray<value_type>& __x) const {
1.1706 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1707 + _M_array[_M_addr[__i]] %= __x[__i];
1.1708 + }
1.1709 +
1.1710 + void operator+=(const valarray<value_type>& __x) const {
1.1711 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1712 + _M_array[_M_addr[__i]] += __x[__i];
1.1713 + }
1.1714 +
1.1715 + void operator-=(const valarray<value_type>& __x) const {
1.1716 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1717 + _M_array[_M_addr[__i]] -= __x[__i];
1.1718 + }
1.1719 +
1.1720 + void operator^=(const valarray<value_type>& __x) const {
1.1721 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1722 + _M_array[_M_addr[__i]] ^= __x[__i];
1.1723 + }
1.1724 +
1.1725 + void operator&=(const valarray<value_type>& __x) const {
1.1726 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1727 + _M_array[_M_addr[__i]] &= __x[__i];
1.1728 + }
1.1729 +
1.1730 + void operator|=(const valarray<value_type>& __x) const {
1.1731 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1732 + _M_array[_M_addr[__i]] |= __x[__i];
1.1733 + }
1.1734 +
1.1735 + void operator<<=(const valarray<value_type>& __x) const {
1.1736 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1737 + _M_array[_M_addr[__i]] <<= __x[__i];
1.1738 + }
1.1739 +
1.1740 + void operator>>=(const valarray<value_type>& __x) const {
1.1741 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1742 + _M_array[_M_addr[__i]] >>= __x[__i];
1.1743 + }
1.1744 +
1.1745 + void operator=(const value_type& __c) const {
1.1746 + for (size_t __i = 0; __i < _M_addr.size(); ++__i)
1.1747 + _M_array[_M_addr[__i]] = __c;
1.1748 + }
1.1749 +
1.1750 + ~indirect_array() {}
1.1751 +
1.1752 +private:
1.1753 + indirect_array(const _Valarray_size_t& __addr, valarray<_Tp>& __array)
1.1754 + : _M_addr(__addr), _M_array(__array)
1.1755 + {}
1.1756 +
1.1757 + _Valarray_size_t _M_addr;
1.1758 + valarray<_Tp>& _M_array;
1.1759 +
1.1760 +private: // Disable assignment
1.1761 + void operator=(const indirect_array<_Tp>&);
1.1762 +};
1.1763 +
1.1764 +// valarray member functions dealing with indirect_array
1.1765 +
1.1766 +template <class _Tp>
1.1767 +inline valarray<_Tp>::valarray(const indirect_array<_Tp>& __x)
1.1768 + : _Valarray_base<_Tp>(__x._M_addr.size())
1.1769 +{
1.1770 + typedef typename __type_traits<_Tp>::has_trivial_default_constructor
1.1771 + _Is_Trivial;
1.1772 + _M_initialize(_Is_Trivial());
1.1773 + *this = __x;
1.1774 +}
1.1775 +
1.1776 +
1.1777 +template <class _Tp>
1.1778 +inline indirect_array<_Tp>
1.1779 +valarray<_Tp>::operator[](const _Valarray_size_t& __addr)
1.1780 +{
1.1781 + return indirect_array<_Tp>(__addr, *this);
1.1782 +}
1.1783 +
1.1784 +_STLP_END_NAMESPACE
1.1785 +
1.1786 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.1787 +# include <stl/_valarray.c>
1.1788 +# endif
1.1789 +
1.1790 +#endif /* _STLP_VALARRAY */
1.1791 +
1.1792 +
1.1793 +// Local Variables:
1.1794 +// mode:C++
1.1795 +// End: