# valarray_array.tcc

    00001 // The template and inlines for the -*- C++ -*- internal _Array helper class.
    00002
    00003 // Copyright (C) 1997, 1998, 1999 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, class _Dom>
    00084 void
    00085 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
    00086 {
    00087     _Tp* __p (__a._M_data);
    00088     for (size_t __i=0; __i<__n; ++__i, ++__p) *__p = __e[__i];
    00089 }
    00090
    00091 export template<typename _Tp, class _Dom>
    00092 void
    00093 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
    00094                  _Array<_Tp> __a, size_t __s)
    00095 {
    00096     _Tp* __p (__a._M_data);
    00097     for (size_t __i=0; __i<__n; ++__i, __p+=__s) *__p = __e[__i];
    00098 }
    00099
    00100 export template<typename _Tp, class _Dom>
    00101 void
    00102 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
    00103                  _Array<_Tp> __a, _Array<size_t> __i)
    00104 {
    00105     size_t* __j (__i._M_data);
    00106     for (size_t __k=0; __k<__n; ++__k, ++__j) __a._M_data[*__j] = __e[__k];
    00107 }
    00108
    00109 export template<typename _Tp, class _Dom>
    00110 void
    00111 __valarray_copy (const _Expr<_Dom, _Tp>& __e, size_t __n,
    00112                  _Array<_Tp> __a, _Array<bool> __m)
    00113 {
    00114     bool* __ok (__m._M_data);
    00115     _Tp* __p (__a._M_data);
    00116     for (size_t __i=0; __i<__n; ++__i, ++__ok, ++__p) {
    00117         while (! *__ok) {
    00118             ++__ok;
    00119             ++__p;
    00120         }
    00121         *__p = __e[__i];
    00122     }
    00123 }
    00124
    00125
    00126 export template<typename _Tp, class _Dom>
    00127 void
    00128 __valarray_copy_construct (const _Expr<_Dom, _Tp>& __e, size_t __n,
    00129                            _Array<_Tp> __a)
    00130 {
    00131     _Tp* __p (__a._M_data);
    00132     for (size_t __i=0; __i<__n; ++__i, ++__p) new (__p) _Tp(__e[__i]);
    00133 }
    00134
    00135
    00136 export template<typename _Tp>
    00137 void
    00138 __valarray_copy_construct (_Array<_Tp> __a, _Array<bool> __m,
    00139                            _Array<_Tp> __b, size_t __n)
    00140 {
    00141     _Tp* __p (__a._M_data);
    00142     bool* __ok (__m._M_data);
    00143     for (_Tp* __q=__b._M_data; __q<__b._M_data+__n; ++__q, ++__ok, ++__p) {
    00144         while (! *__ok) {
    00145             ++__ok;
    00146             ++__p;
    00147         }
    00148         new (__q) _Tp(*__p);
    00149     }
    00150 }
    00151
    00152
    00153
    00154
    00155 } // std::
    00156
    00157 #endif /* _CPP_BITS_VALARRAY_ARRAY_TCC */
    00158
    00159 // Local Variables:
    00160 // mode:c++
    00161 // End: