32 #ifndef _GSLICE_ARRAY_H
33 #define _GSLICE_ARRAY_H 1
35 #pragma GCC system_header
37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
59 template<
typename _Tp>
63 typedef _Tp value_type;
76 void operator=(
const valarray<_Tp>&)
const;
94 void operator<<=(const valarray<_Tp>&)
const;
101 void operator=(
const _Expr<_Dom, _Tp>&)
const;
103 void operator*=(
const _Expr<_Dom, _Tp>&)
const;
105 void operator/=(
const _Expr<_Dom, _Tp>&)
const;
107 void operator%=(
const _Expr<_Dom, _Tp>&)
const;
109 void operator+=(
const _Expr<_Dom, _Tp>&)
const;
111 void operator-=(
const _Expr<_Dom, _Tp>&)
const;
113 void operator^=(
const _Expr<_Dom, _Tp>&)
const;
115 void operator&=(
const _Expr<_Dom, _Tp>&)
const;
117 void operator|=(
const _Expr<_Dom, _Tp>&)
const;
119 void operator<<=(const _Expr<_Dom, _Tp>&)
const;
124 _Array<_Tp> _M_array;
125 const valarray<size_t>& _M_index;
127 friend class valarray<_Tp>;
135 template<
typename _Tp>
137 gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
138 const valarray<size_t>& __i)
139 : _M_array(__a), _M_index(__i) {}
141 template<
typename _Tp>
144 : _M_array(__a._M_array), _M_index(__a._M_index) {}
146 template<
typename _Tp>
150 std::__valarray_copy(_Array<_Tp>(__a._M_array),
151 _Array<size_t>(__a._M_index), _M_index.size(),
152 _M_array, _Array<size_t>(_M_index));
156 template<
typename _Tp>
160 std::__valarray_fill(_M_array, _Array<size_t>(_M_index),
161 _M_index.size(), __t);
164 template<
typename _Tp>
168 std::__valarray_copy(_Array<_Tp>(__v), __v.
size(),
169 _M_array, _Array<size_t>(_M_index));
172 template<
typename _Tp>
177 std::__valarray_copy (__e, _M_index.size(), _M_array,
178 _Array<size_t>(_M_index));
181 #undef _DEFINE_VALARRAY_OPERATOR
182 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
183 template<typename _Tp> \
185 gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
187 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
188 _Array<_Tp>(__v), __v.size()); \
191 template<typename _Tp> \
192 template<class _Dom> \
194 gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
196 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
200 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
201 _DEFINE_VALARRAY_OPERATOR(/, __divides)
202 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
203 _DEFINE_VALARRAY_OPERATOR(+, __plus)
204 _DEFINE_VALARRAY_OPERATOR(-, __minus)
205 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
206 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
207 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
208 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
209 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
211 #undef _DEFINE_VALARRAY_OPERATOR
215 _GLIBCXX_END_NAMESPACE_VERSION
void operator^=(const valarray< _Tp > &) const
Logical xor slice elements with corresponding elements of v.
gslice_array(const gslice_array &)
Copy constructor. Both slices refer to the same underlying array.
Reference to multi-dimensional subset of an array.
Smart array designed to support numeric processing.
void operator*=(const valarray< _Tp > &) const
Multiply slice elements by corresponding elements of v.
void operator&=(const valarray< _Tp > &) const
Logical and slice elements with corresponding elements of v.
size_t size() const
Return the number of elements in array.
void operator+=(const valarray< _Tp > &) const
Add corresponding elements of v to slice elements.
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 & 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 or slice elements with corresponding elements of v.