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