valarray_array.tcc

00001 // The template and inlines for the -*- C++ -*- internal _Array helper class.
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2004 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_VALARRAY_ARRAY_TCC 
00033 #define _CPP_BITS_VALARRAY_ARRAY_TCC 1
00034 
00035 namespace std
00036 {
00037 
00038 export template<typename _Tp>
00039 void
00040 __valarray_fill (_Array<_Tp> __a, size_t __n, _Array<bool> __m, const _Tp& __t)
00041 {
00042     _Tp* __p = __a._M_data;
00043     bool* __ok (__m._M_data);
00044     for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
00045         while (! *__ok) {
00046             ++__ok;
00047             ++__p;
00048         }
00049         *__p = __t;
00050     }
00051 }
00052 
00053 export template<typename _Tp>
00054 void
00055 __valarray_copy (_Array<_Tp> __a, _Array<bool> __m, _Array<_Tp> __b, size_t __n)
00056 {
00057     _Tp* __p (__a._M_data);
00058     bool* __ok (__m._M_data);
00059     for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) {
00060         while (! *__ok) {
00061             ++__ok;
00062             ++__p;
00063         }
00064         *__q = *__p;
00065     }
00066 }
00067 
00068 export template<typename _Tp>
00069 void
00070 __valarray_copy (_Array<_Tp> __a, size_t __n, _Array<_Tp> __b, _Array<bool> __m)
00071 {
00072     _Tp* __q (__b._M_data);
00073     bool* __ok (__m._M_data);
00074     for (_Tp* __p=__a._M_data; __p<__a._M_data+__n; ++__p, ++__ok, ++__q) {
00075         while (! *__ok) {
00076             ++__ok;
00077             ++__q;
00078         }
00079         *__q = *__p;
00080     }
00081 }
00082 
00083 export template<typename _Tp>
00084 void
00085 __valarray_copy(_Array<_Tp> __a, _Array<bool> __m, size_t __n,
00086         _Array<_Tp> __b, _Array<bool> __k)
00087 {
00088   _Tp* __p (__a._M_data);
00089   _Tp* __q (__b._M_data);
00090   bool* __srcok (__m._M_data);
00091   bool* __dstok (__k._M_data);
00092   for (size_t __i = 0; __i < __n;
00093        ++__srcok, ++__p, ++__dstok, ++__q, ++__i)
00094     {
00095       while (! *__srcok)
00096     {
00097       ++__srcok;
00098       ++__p;
00099     }
00100       while (! *__dstok) 
00101     {
00102       ++__dstok;
00103       ++__q;
00104     }
00105       *__q = *__p;
00106     }
00107 }
00108 
00109 export template<typename _Tp, class _Dom>
00110 void
00111 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
00112 {
00113     _Tp* __p (__a._M_data);
00114     for (size_t __i=0; __i<__n; ++__i, ++__p) *__p = __e[__i];
00115 }
00116 
00117 export template<typename _Tp, class _Dom>
00118 void
00119 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, 
00120                  _Array<_Tp> __a, size_t __s)
00121 {
00122     _Tp* __p (__a._M_data);
00123     for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p = __e[__i];
00124 }
00125 
00126 export template<typename _Tp, class _Dom>
00127 void
00128 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, 
00129                  _Array<_Tp> __a, _Array<size_t> __i)
00130 {
00131     size_t* __j (__i._M_data);
00132     for (size_t __k=0; __k<__n; ++__k, ++__j) __a._M_data[*__j] = __e[__k];
00133 }
00134 
00135 export template<typename _Tp>
00136 void
00137 __valarray_copy(_Array<_Tp> __e, _Array<size_t> __f,
00138         size_t __n, 
00139         _Array<_Tp> __a, _Array<size_t> __i)
00140 {
00141   size_t* __g (__f._M_data);
00142   size_t* __j (__i._M_data);
00143   for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g) 
00144     __a._M_data[*__j] = __e._M_data[*__g];
00145 }
00146 
00147 export template<typename _Tp, class _Dom>
00148 void
00149 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, 
00150                  _Array<_Tp> __a, _Array<bool> __m)
00151 {
00152     bool* __ok (__m._M_data);
00153     _Tp* __p (__a._M_data);
00154     for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
00155         while (! *__ok) {
00156             ++__ok;
00157             ++__p;
00158         }
00159         *__p = __e[__i];
00160     }
00161 }
00162 
00163 export template<typename _Tp, class _Dom>
00164 void
00165 __valarray_copy_construct (const _Expr<_Dom, _Tp>& __e, size_t __n,
00166                            _Array<_Tp> __a)
00167 {
00168     _Tp* __p (__a._M_data);
00169     for (size_t __i=0; __i<__n; ++__i, ++__p) new (__p) _Tp(__e[__i]);
00170 }
00171 
00172 export template<typename _Tp>
00173 void
00174 __valarray_copy_construct (_Array<_Tp> __a, _Array<bool> __m,
00175                            _Array<_Tp> __b, size_t __n)
00176 {
00177     _Tp* __p (__a._M_data);
00178     bool* __ok (__m._M_data);
00179     for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) {
00180         while (! *__ok) {
00181             ++__ok;
00182             ++__p;
00183         }
00184         new (__q) _Tp(*__p);
00185     }
00186 }
00187 
00188 } // std::
00189 
00190 #endif /* _CPP_BITS_VALARRAY_ARRAY_TCC */
00191 
00192 // Local Variables:
00193 // mode:c++
00194 // End:

Generated on Sat Mar 19 18:32:25 2005 for libstdc++-v3 Source by  doxygen 1.4.1