33 #ifndef _GSLICE_ARRAY_H
34 #define _GSLICE_ARRAY_H 1
36 #pragma GCC system_header
38 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
60 template<
typename _Tp>
64 typedef _Tp value_type;
77 void operator=(
const valarray<_Tp>&)
const;
95 void operator<<=(const valarray<_Tp>&)
const;
102 void operator=(
const _Expr<_Dom, _Tp>&)
const;
104 void operator*=(
const _Expr<_Dom, _Tp>&)
const;
106 void operator/=(
const _Expr<_Dom, _Tp>&)
const;
108 void operator%=(
const _Expr<_Dom, _Tp>&)
const;
110 void operator+=(
const _Expr<_Dom, _Tp>&)
const;
112 void operator-=(
const _Expr<_Dom, _Tp>&)
const;
114 void operator^=(
const _Expr<_Dom, _Tp>&)
const;
116 void operator&=(
const _Expr<_Dom, _Tp>&)
const;
118 void operator|=(
const _Expr<_Dom, _Tp>&)
const;
120 void operator<<=(const _Expr<_Dom, _Tp>&)
const;
125 _Array<_Tp> _M_array;
126 const valarray<size_t>& _M_index;
128 friend class valarray<_Tp>;
136 template<
typename _Tp>
138 gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
139 const valarray<size_t>& __i)
140 : _M_array(__a), _M_index(__i) {}
142 template<
typename _Tp>
145 : _M_array(__a._M_array), _M_index(__a._M_index) {}
147 template<
typename _Tp>
151 std::__valarray_copy(_Array<_Tp>(__a._M_array),
152 _Array<size_t>(__a._M_index), _M_index.size(),
153 _M_array, _Array<size_t>(_M_index));
157 template<
typename _Tp>
161 std::__valarray_fill(_M_array, _Array<size_t>(_M_index),
162 _M_index.size(), __t);
165 template<
typename _Tp>
169 std::__valarray_copy(_Array<_Tp>(__v), __v.
size(),
170 _M_array, _Array<size_t>(_M_index));
173 template<
typename _Tp>
178 std::__valarray_copy (__e, _M_index.size(), _M_array,
179 _Array<size_t>(_M_index));
182 #undef _DEFINE_VALARRAY_OPERATOR
183 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
184 template<typename _Tp> \
186 gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
188 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
189 _Array<_Tp>(__v), __v.size()); \
192 template<typename _Tp> \
193 template<class _Dom> \
195 gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
197 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
201 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
202 _DEFINE_VALARRAY_OPERATOR(/, __divides)
203 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
204 _DEFINE_VALARRAY_OPERATOR(+, __plus)
205 _DEFINE_VALARRAY_OPERATOR(-, __minus)
206 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
207 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
208 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
209 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
210 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
212 #undef _DEFINE_VALARRAY_OPERATOR
216 _GLIBCXX_END_NAMESPACE_VERSION
gslice_array & operator=(const gslice_array &)
Assignment operator. Assigns slice elements to corresponding elements of a.
void operator/=(const valarray< _Tp > &) const
Divide slice elements by corresponding elements of v.
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.
size_t size() const
Return the number of elements in array.
void operator|=(const valarray< _Tp > &) const
Logical or slice elements with corresponding elements of v.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
void operator>>=(const valarray< _Tp > &) const
Right shift slice elements by corresponding elements of v.
void operator%=(const valarray< _Tp > &) const
Modulo slice elements by corresponding elements of v.
void operator-=(const valarray< _Tp > &) const
Subtract corresponding elements of v from slice elements.
gslice_array(const gslice_array &)
Copy constructor. Both slices refer to the same underlying array.
Smart array designed to support numeric processing.
Reference to multi-dimensional subset of an array.
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.