Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
3 * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
6 * Hewlett-Packard Company
8 * Copyright (c) 1996,1997
9 * Silicon Graphics Computer Systems, Inc.
12 * Moscow Center for SPARC Technology
17 * This material is provided "as is", with absolutely no warranty expressed
18 * or implied. Any use is at your own risk.
20 * Permission to use or copy this software for any purpose is hereby granted
21 * without fee, provided the above notices are retained on all copies.
22 * Permission to modify the code and to distribute modified code is granted,
23 * provided the above notices are retained, and a notice that the code was
24 * modified is included with the above copyright notice.
27 #ifndef _STLP_VALARRAY_C
28 #define _STLP_VALARRAY_C
30 #ifndef _STLP_VALARRAY_H
31 # include <stl/_valarray.h>
37 _Valarray_bool valarray<_Tp>:: operator!() const {
38 _Valarray_bool __tmp(this->size(), _Valarray_bool::_NoInit());
39 for (size_t __i = 0; __i < this->size(); ++__i)
40 __tmp[__i] = !(*this)[__i];
44 // Behavior is undefined if __x and *this have different sizes
46 valarray<_Tp>& valarray<_Tp>::operator=(const slice_array<_Tp>& __x)
48 size_t __index = __x._M_slice.start();
50 __i < __x._M_slice.size();
51 ++__i, __index += __x._M_slice.stride())
52 (*this)[__i] = (*(__x._M_array))[__index];
57 valarray<_Tp> valarray<_Tp>::operator[](slice __slice) const {
58 valarray<_Tp> __tmp(__slice.size(), _NoInit());
59 size_t __index = __slice.start();
62 ++__i, __index += __slice.stride())
63 __tmp[__i] = (*this)[__index];
67 template <class _Size>
68 bool _Gslice_Iter_tmpl<_Size>::_M_incr() {
69 size_t __dim = _M_indices.size() - 1;
72 _M_1d_idx += _M_gslice._M_strides[__dim];
73 if (++_M_indices[__dim] != _M_gslice._M_lengths[__dim])
75 else if (__dim != 0) {
77 _M_gslice._M_strides[__dim] * _M_gslice._M_lengths[__dim];
78 _M_indices[__dim] = 0;
86 // Behavior is undefined if __x and *this have different sizes, or if
87 // __x was constructed from a degenerate gslice.
89 valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array<_Tp>& __x)
91 if (this->size() != 0) {
92 _Gslice_Iter __i(__x._M_gslice);
94 (*this)[__i._M_step] = __x._M_array[__i._M_1d_idx];
101 valarray<_Tp> valarray<_Tp>::operator[](gslice __slice) const
103 valarray<_Tp> __tmp(__slice._M_size(), _NoInit());
104 if (__tmp.size() != 0) {
105 _Gslice_Iter __i(__slice);
106 do __tmp[__i._M_step] = (*this)[__i._M_1d_idx]; while(__i._M_incr());
112 valarray<_Tp> valarray<_Tp>::operator[](const _Valarray_bool& __mask) const
116 for (size_t __i = 0; __i < __mask.size(); ++__i)
117 if (__mask[__i]) ++_p_size;
120 valarray<_Tp> __tmp(_p_size, _NoInit());
123 for (size_t __i = 0; __i < __mask.size(); ++__i)
124 if (__mask[__i]) __tmp[__idx++] = (*this)[__i];
131 valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array<_Tp>& __x) {
132 for (size_t __i = 0; __i < __x._M_addr.size(); ++__i)
133 (*this)[__i] = __x._M_array[__x._M_addr[__i]];
139 valarray<_Tp>::operator[](const _Valarray_size_t& __addr) const
141 valarray<_Tp> __tmp(__addr.size(), _NoInit());
142 for (size_t __i = 0; __i < __addr.size(); ++__i)
143 __tmp[__i] = (*this)[__addr[__i]];
147 //----------------------------------------------------------------------
148 // Other valarray noninline member functions
153 valarray<_Tp> valarray<_Tp>::shift(int __n) const
155 valarray<_Tp> __tmp(this->size());
158 if (__n < this->size())
159 copy(this->_M_first + __n, this->_M_first + this->size(),
163 if (-__n < this->size())
164 copy(this->_M_first, this->_M_first + this->size() + __n,
165 __tmp._M_first - __n);
171 valarray<_Tp> valarray<_Tp>::cshift(int __m) const
173 valarray<_Tp> __tmp(this->size());
180 // Reduce __m to an equivalent number in the range [0, size()). We
181 // have to be careful with negative numbers, since the sign of a % b
182 // is unspecified when a < 0.
184 if (this->size() < (numeric_limits<long>::max)())
185 __n %= long(this->size());
189 copy(this->_M_first, this->_M_first + __n,
190 __tmp._M_first + (this->size() - __n));
191 copy(this->_M_first + __n, this->_M_first + this->size(),
199 #endif /* _STLP_VALARRAY_C */