33 #ifndef _SLICE_ARRAY_H
34 #define _SLICE_ARRAY_H 1
36 #pragma GCC system_header
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
73 slice(
size_t __o,
size_t __d,
size_t __s);
92 : _M_off(0), _M_sz(0), _M_st(0) {}
96 : _M_off(__o), _M_sz(__d), _M_st(__s) {}
123 template<
typename _Tp>
127 typedef _Tp value_type;
158 void operator<<=(const valarray<_Tp>&)
const;
166 void operator=(
const _Expr<_Dom, _Tp>&)
const;
168 void operator*=(
const _Expr<_Dom, _Tp>&)
const;
170 void operator/=(
const _Expr<_Dom, _Tp>&)
const;
172 void operator%=(
const _Expr<_Dom, _Tp>&)
const;
174 void operator+=(
const _Expr<_Dom, _Tp>&)
const;
176 void operator-=(
const _Expr<_Dom, _Tp>&)
const;
178 void operator^=(
const _Expr<_Dom, _Tp>&)
const;
180 void operator&=(
const _Expr<_Dom, _Tp>&)
const;
182 void operator|=(
const _Expr<_Dom, _Tp>&)
const;
184 void operator<<=(const _Expr<_Dom, _Tp>&)
const;
193 const size_t _M_stride;
194 const _Array<_Tp> _M_array;
200 template<
typename _Tp>
202 slice_array<_Tp>::slice_array(_Array<_Tp> __a,
const slice& __s)
203 : _M_sz(__s.
size()), _M_stride(__s.stride()),
204 _M_array(__a.
begin() + __s.start()) {}
206 template<
typename _Tp>
209 : _M_sz(a._M_sz), _M_stride(a._M_stride), _M_array(a._M_array) {}
214 template<
typename _Tp>
218 std::__valarray_copy(__a._M_array, __a._M_sz, __a._M_stride,
219 _M_array, _M_stride);
223 template<
typename _Tp>
226 { std::__valarray_fill(_M_array, _M_sz, _M_stride, __t); }
228 template<
typename _Tp>
231 { std::__valarray_copy(_Array<_Tp>(__v), _M_array, _M_sz, _M_stride); }
233 template<
typename _Tp>
237 { std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); }
239 #undef _DEFINE_VALARRAY_OPERATOR
240 #define _DEFINE_VALARRAY_OPERATOR(_Op,_Name) \
241 template<typename _Tp> \
243 slice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
245 _Array_augmented_##_Name(_M_array, _M_sz, _M_stride, _Array<_Tp>(__v));\
248 template<typename _Tp> \
249 template<class _Dom> \
251 slice_array<_Tp>::operator _Op##=(const _Expr<_Dom,_Tp>& __e) const\
253 _Array_augmented_##_Name(_M_array, _M_stride, __e, _M_sz); \
257 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
258 _DEFINE_VALARRAY_OPERATOR(/, __divides)
259 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
260 _DEFINE_VALARRAY_OPERATOR(+, __plus)
261 _DEFINE_VALARRAY_OPERATOR(-, __minus)
262 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
263 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
264 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
265 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
266 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
268 #undef _DEFINE_VALARRAY_OPERATOR
272 _GLIBCXX_END_NAMESPACE_VERSION
void operator|=(const valarray< _Tp > &) const
Logical or slice elements with corresponding elements of v.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.
Reference to one-dimensional subset of an array.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
slice()
Construct an empty slice.
void operator-=(const valarray< _Tp > &) const
Subtract corresponding elements of v from slice elements.
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.
Class defining one-dimensional subset of an array.
size_t size() const
Return size of slice.
Smart array designed to support numeric processing.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
slice_array & operator=(const slice_array &)
Assignment operator. Assigns slice elements to corresponding elements of a.
size_t stride() const
Return array stride of slice.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
void operator/=(const valarray< _Tp > &) const
Divide slice elements by corresponding elements of v.
size_t start() const
Return array offset of first slice element.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initilizer_list.
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.