Whole document tree gslice_array.hGo to the documentation of this file.00001 // The template and inlines for the -*- C++ -*- gslice_array class. 00002 00003 // Copyright (C) 1997-2001 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 2, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // You should have received a copy of the GNU General Public License along 00017 // with this library; see the file COPYING. If not, write to the Free 00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00019 // USA. 00020 00021 // As a special exception, you may use this file as part of a free software 00022 // library without restriction. Specifically, if other files instantiate 00023 // templates or use macros or inline functions from this file, or you compile 00024 // this file and link it with other files to produce an executable, this 00025 // file does not by itself cause the resulting executable to be covered by 00026 // the GNU General Public License. This exception does not however 00027 // invalidate any other reasons why the executable file might be covered by 00028 // the GNU General Public License. 00029 00030 // Written by Gabriel Dos Reis <Gabriel.Dos-Reis@DPTMaths.ENS-Cachan.Fr> 00031 00032 #ifndef _CPP_BITS_GSLICE_ARRAY 00033 #define _CPP_BITS_GSLICE_ARRAY 1 00034 00035 #pragma GCC system_header 00036 00037 namespace std { 00038 00039 template<typename _Tp> class gslice_array 00040 { 00041 public: 00042 typedef _Tp value_type; 00043 00044 void operator= (const valarray<_Tp>&) const; 00045 void operator*= (const valarray<_Tp>&) const; 00046 void operator/= (const valarray<_Tp>&) const; 00047 void operator%= (const valarray<_Tp>&) const; 00048 void operator+= (const valarray<_Tp>&) const; 00049 void operator-= (const valarray<_Tp>&) const; 00050 void operator^= (const valarray<_Tp>&) const; 00051 void operator&= (const valarray<_Tp>&) const; 00052 void operator|= (const valarray<_Tp>&) const; 00053 void operator<<=(const valarray<_Tp>&) const; 00054 void operator>>=(const valarray<_Tp>&) const; 00055 void operator=(const _Tp&); 00056 00057 template<class _Dom> 00058 void operator= (const _Expr<_Dom,_Tp>&) const; 00059 template<class _Dom> 00060 void operator*= (const _Expr<_Dom,_Tp>&) const; 00061 template<class _Dom> 00062 void operator/= (const _Expr<_Dom,_Tp>&) const; 00063 template<class _Dom> 00064 void operator%= (const _Expr<_Dom,_Tp>&) const; 00065 template<class _Dom> 00066 void operator+= (const _Expr<_Dom,_Tp>&) const; 00067 template<class _Dom> 00068 void operator-= (const _Expr<_Dom,_Tp>&) const; 00069 template<class _Dom> 00070 void operator^= (const _Expr<_Dom,_Tp>&) const; 00071 template<class _Dom> 00072 void operator&= (const _Expr<_Dom,_Tp>&) const; 00073 template<class _Dom> 00074 void operator|= (const _Expr<_Dom,_Tp>&) const; 00075 template<class _Dom> 00076 void operator<<= (const _Expr<_Dom,_Tp>&) const; 00077 template<class _Dom> 00078 void operator>>= (const _Expr<_Dom,_Tp>&) const; 00079 00080 private: 00081 _Array<_Tp> _M_array; 00082 const valarray<size_t>& _M_index; 00083 00084 friend class valarray<_Tp>; 00085 00086 gslice_array (_Array<_Tp>, const valarray<size_t>&); 00087 00088 // this constructor needs to be implemented. 00089 gslice_array (const gslice_array&); 00090 00091 // not implemented 00092 gslice_array(); 00093 gslice_array& operator= (const gslice_array&); 00094 }; 00095 00096 template<typename _Tp> 00097 inline 00098 gslice_array<_Tp>::gslice_array (_Array<_Tp> __a, 00099 const valarray<size_t>& __i) 00100 : _M_array (__a), _M_index (__i) {} 00101 00102 00103 template<typename _Tp> 00104 inline 00105 gslice_array<_Tp>::gslice_array (const gslice_array<_Tp>& __a) 00106 : _M_array (__a._M_array), _M_index (__a._M_index) {} 00107 00108 00109 template<typename _Tp> 00110 inline void 00111 gslice_array<_Tp>::operator= (const _Tp& __t) 00112 { 00113 __valarray_fill (_M_array, _Array<size_t>(_M_index), 00114 _M_index.size(), __t); 00115 } 00116 00117 template<typename _Tp> 00118 inline void 00119 gslice_array<_Tp>::operator= (const valarray<_Tp>& __v) const 00120 { 00121 __valarray_copy (_Array<_Tp> (__v), __v.size (), 00122 _M_array, _Array<size_t>(_M_index)); 00123 } 00124 00125 template<typename _Tp> 00126 template<class E> 00127 inline void 00128 gslice_array<_Tp>::operator= (const _Expr<E, _Tp>& __e) const 00129 { 00130 __valarray_copy (__e, _M_index.size(), _M_array, 00131 _Array<size_t>(_M_index)); 00132 } 00133 00134 #undef _DEFINE_VALARRAY_OPERATOR 00135 #define _DEFINE_VALARRAY_OPERATOR(op, name) \ 00136 template<typename _Tp> \ 00137 inline void \ 00138 gslice_array<_Tp>::operator op##= (const valarray<_Tp>& __v) const \ 00139 { \ 00140 _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), \ 00141 _Array<_Tp> (__v), __v.size ()); \ 00142 } \ 00143 \ 00144 template<typename _Tp> template<class E> \ 00145 inline void \ 00146 gslice_array<_Tp>::operator op##= (const _Expr<E, _Tp>& __e) const \ 00147 { \ 00148 _Array_augmented_##name (_M_array, _Array<size_t>(_M_index), __e, \ 00149 _M_index.size()); \ 00150 } 00151 00152 _DEFINE_VALARRAY_OPERATOR(*, multiplies) 00153 _DEFINE_VALARRAY_OPERATOR(/, divides) 00154 _DEFINE_VALARRAY_OPERATOR(%, modulus) 00155 _DEFINE_VALARRAY_OPERATOR(+, plus) 00156 _DEFINE_VALARRAY_OPERATOR(-, minus) 00157 _DEFINE_VALARRAY_OPERATOR(^, xor) 00158 _DEFINE_VALARRAY_OPERATOR(&, and) 00159 _DEFINE_VALARRAY_OPERATOR(|, or) 00160 _DEFINE_VALARRAY_OPERATOR(<<, shift_left) 00161 _DEFINE_VALARRAY_OPERATOR(>>, shift_right) 00162 00163 #undef _DEFINE_VALARRAY_OPERATOR 00164 00165 } // std:: 00166 00167 #endif /* _CPP_BITS_GSLICE_ARRAY */ 00168 00169 // Local Variables: 00170 // mode:c++ 00171 // End: Generated on Mon Apr 8 03:11:25 2002 for libstdc++-v3 Source by ![]() |