00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _GSLICE_ARRAY_H
00034 #define _GSLICE_ARRAY_H 1
00035
00036 #pragma GCC system_header
00037
00038 namespace std _GLIBCXX_VISIBILITY(default)
00039 {
00040 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 template<typename _Tp>
00061 class gslice_array
00062 {
00063 public:
00064 typedef _Tp value_type;
00065
00066
00067
00068
00069
00070 gslice_array(const gslice_array&);
00071
00072
00073
00074 gslice_array& operator=(const gslice_array&);
00075
00076
00077 void operator=(const valarray<_Tp>&) const;
00078
00079 void operator*=(const valarray<_Tp>&) const;
00080
00081 void operator/=(const valarray<_Tp>&) const;
00082
00083 void operator%=(const valarray<_Tp>&) const;
00084
00085 void operator+=(const valarray<_Tp>&) const;
00086
00087 void operator-=(const valarray<_Tp>&) const;
00088
00089 void operator^=(const valarray<_Tp>&) const;
00090
00091 void operator&=(const valarray<_Tp>&) const;
00092
00093 void operator|=(const valarray<_Tp>&) const;
00094
00095 void operator<<=(const valarray<_Tp>&) const;
00096
00097 void operator>>=(const valarray<_Tp>&) const;
00098
00099 void operator=(const _Tp&) const;
00100
00101 template<class _Dom>
00102 void operator=(const _Expr<_Dom, _Tp>&) const;
00103 template<class _Dom>
00104 void operator*=(const _Expr<_Dom, _Tp>&) const;
00105 template<class _Dom>
00106 void operator/=(const _Expr<_Dom, _Tp>&) const;
00107 template<class _Dom>
00108 void operator%=(const _Expr<_Dom, _Tp>&) const;
00109 template<class _Dom>
00110 void operator+=(const _Expr<_Dom, _Tp>&) const;
00111 template<class _Dom>
00112 void operator-=(const _Expr<_Dom, _Tp>&) const;
00113 template<class _Dom>
00114 void operator^=(const _Expr<_Dom, _Tp>&) const;
00115 template<class _Dom>
00116 void operator&=(const _Expr<_Dom, _Tp>&) const;
00117 template<class _Dom>
00118 void operator|=(const _Expr<_Dom, _Tp>&) const;
00119 template<class _Dom>
00120 void operator<<=(const _Expr<_Dom, _Tp>&) const;
00121 template<class _Dom>
00122 void operator>>=(const _Expr<_Dom, _Tp>&) const;
00123
00124 private:
00125 _Array<_Tp> _M_array;
00126 const valarray<size_t>& _M_index;
00127
00128 friend class valarray<_Tp>;
00129
00130 gslice_array(_Array<_Tp>, const valarray<size_t>&);
00131
00132
00133 gslice_array();
00134 };
00135
00136 template<typename _Tp>
00137 inline
00138 gslice_array<_Tp>::gslice_array(_Array<_Tp> __a,
00139 const valarray<size_t>& __i)
00140 : _M_array(__a), _M_index(__i) {}
00141
00142 template<typename _Tp>
00143 inline
00144 gslice_array<_Tp>::gslice_array(const gslice_array<_Tp>& __a)
00145 : _M_array(__a._M_array), _M_index(__a._M_index) {}
00146
00147 template<typename _Tp>
00148 inline gslice_array<_Tp>&
00149 gslice_array<_Tp>::operator=(const gslice_array<_Tp>& __a)
00150 {
00151 std::__valarray_copy(_Array<_Tp>(__a._M_array),
00152 _Array<size_t>(__a._M_index), _M_index.size(),
00153 _M_array, _Array<size_t>(_M_index));
00154 return *this;
00155 }
00156
00157 template<typename _Tp>
00158 inline void
00159 gslice_array<_Tp>::operator=(const _Tp& __t) const
00160 {
00161 std::__valarray_fill(_M_array, _Array<size_t>(_M_index),
00162 _M_index.size(), __t);
00163 }
00164
00165 template<typename _Tp>
00166 inline void
00167 gslice_array<_Tp>::operator=(const valarray<_Tp>& __v) const
00168 {
00169 std::__valarray_copy(_Array<_Tp>(__v), __v.size(),
00170 _M_array, _Array<size_t>(_M_index));
00171 }
00172
00173 template<typename _Tp>
00174 template<class _Dom>
00175 inline void
00176 gslice_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const
00177 {
00178 std::__valarray_copy (__e, _M_index.size(), _M_array,
00179 _Array<size_t>(_M_index));
00180 }
00181
00182 #undef _DEFINE_VALARRAY_OPERATOR
00183 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name) \
00184 template<typename _Tp> \
00185 inline void \
00186 gslice_array<_Tp>::operator _Op##=(const valarray<_Tp>& __v) const \
00187 { \
00188 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), \
00189 _Array<_Tp>(__v), __v.size()); \
00190 } \
00191 \
00192 template<typename _Tp> \
00193 template<class _Dom> \
00194 inline void \
00195 gslice_array<_Tp>::operator _Op##= (const _Expr<_Dom, _Tp>& __e) const\
00196 { \
00197 _Array_augmented_##_Name(_M_array, _Array<size_t>(_M_index), __e,\
00198 _M_index.size()); \
00199 }
00200
00201 _DEFINE_VALARRAY_OPERATOR(*, __multiplies)
00202 _DEFINE_VALARRAY_OPERATOR(/, __divides)
00203 _DEFINE_VALARRAY_OPERATOR(%, __modulus)
00204 _DEFINE_VALARRAY_OPERATOR(+, __plus)
00205 _DEFINE_VALARRAY_OPERATOR(-, __minus)
00206 _DEFINE_VALARRAY_OPERATOR(^, __bitwise_xor)
00207 _DEFINE_VALARRAY_OPERATOR(&, __bitwise_and)
00208 _DEFINE_VALARRAY_OPERATOR(|, __bitwise_or)
00209 _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
00210 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
00211
00212 #undef _DEFINE_VALARRAY_OPERATOR
00213
00214
00215
00216 _GLIBCXX_END_NAMESPACE_VERSION
00217 }
00218
00219 #endif