OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [bits/] [valarray_array.tcc] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// The template and inlines for the -*- C++ -*- internal _Array helper class.
2
 
3
// Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
4
//
5
// This file is part of the GNU ISO C++ Library.  This library is free
6
// software; you can redistribute it and/or modify it under the
7
// terms of the GNU General Public License as published by the
8
// Free Software Foundation; either version 2, or (at your option)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
16
// You should have received a copy of the GNU General Public License along
17
// with this library; see the file COPYING.  If not, write to the Free
18
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19
// USA.
20
 
21
// As a special exception, you may use this file as part of a free software
22
// library without restriction.  Specifically, if other files instantiate
23
// templates or use macros or inline functions from this file, or you compile
24
// this file and link it with other files to produce an executable, this
25
// file does not by itself cause the resulting executable to be covered by
26
// the GNU General Public License.  This exception does not however
27
// invalidate any other reasons why the executable file might be covered by
28
// the GNU General Public License.
29
 
30
/** @file valarray_array.tcc
31
 *  This is an internal header file, included by other library headers.
32
 *  You should not attempt to use it directly.
33
 */
34
 
35
// Written by Gabriel Dos Reis 
36
 
37
#ifndef _VALARRAY_ARRAY_TCC
38
#define _VALARRAY_ARRAY_TCC 1
39
 
40
namespace std
41
{
42
  template
43
    void
44
    __valarray_fill(_Array<_Tp> __a, size_t __n, _Array __m,
45
                    const _Tp& __t)
46
    {
47
      _Tp* __p = __a._M_data;
48
      bool* __ok (__m._M_data);
49
      for (size_t __i=0; __i < __n; ++__i, ++__ok, ++__p)
50
        {
51
          while (!*__ok)
52
          {
53
            ++__ok;
54
            ++__p;
55
          }
56
          *__p = __t;
57
        }
58
    }
59
 
60
  // Copy n elements of a into consecutive elements of b.  When m is
61
  // false, the corresponding element of a is skipped.  m must contain
62
  // at least n true elements.  a must contain at least n elements and
63
  // enough elements to match up with m through the nth true element
64
  // of m.  I.e.  if n is 10, m has 15 elements with 5 false followed
65
  // by 10 true, a must have 15 elements.
66
  template
67
    void
68
    __valarray_copy(_Array<_Tp> __a, _Array __m, _Array<_Tp> __b,
69
                    size_t __n)
70
    {
71
      _Tp* __p (__a._M_data);
72
      bool* __ok (__m._M_data);
73
      for (_Tp* __q = __b._M_data; __q < __b._M_data + __n;
74
           ++__q, ++__ok, ++__p)
75
        {
76
          while (! *__ok)
77
            {
78
              ++__ok;
79
              ++__p;
80
            }
81
          *__q = *__p;
82
        }
83
    }
84
 
85
  // Copy n consecutive elements from a into elements of b.  Elements
86
  // of b are skipped if the corresponding element of m is false.  m
87
  // must contain at least n true elements.  b must have at least as
88
  // many elements as the index of the nth true element of m.  I.e. if
89
  // m has 15 elements with 5 false followed by 10 true, b must have
90
  // at least 15 elements.
91
  template
92
    void
93
    __valarray_copy(_Array<_Tp> __a, size_t __n, _Array<_Tp> __b,
94
                    _Array __m)
95
    {
96
      _Tp* __q (__b._M_data);
97
      bool* __ok (__m._M_data);
98
      for (_Tp* __p = __a._M_data; __p < __a._M_data+__n;
99
           ++__p, ++__ok, ++__q)
100
        {
101
          while (! *__ok)
102
            {
103
              ++__ok;
104
              ++__q;
105
            }
106
          *__q = *__p;
107
        }
108
    }
109
 
110
  // Copy n elements from a into elements of b.  Elements of a are
111
  // skipped if the corresponding element of m is false.  Elements of
112
  // b are skipped if the corresponding element of k is false.  m and
113
  // k must contain at least n true elements.  a and b must have at
114
  // least as many elements as the index of the nth true element of m.
115
  template
116
    void
117
    __valarray_copy(_Array<_Tp> __a, _Array __m, size_t __n,
118
                    _Array<_Tp> __b, _Array __k)
119
    {
120
      _Tp* __p (__a._M_data);
121
      _Tp* __q (__b._M_data);
122
      bool* __srcok (__m._M_data);
123
      bool* __dstok (__k._M_data);
124
      for (size_t __i = 0; __i < __n;
125
           ++__srcok, ++__p, ++__dstok, ++__q, ++__i)
126
        {
127
          while (! *__srcok)
128
            {
129
              ++__srcok;
130
              ++__p;
131
            }
132
          while (! *__dstok)
133
            {
134
              ++__dstok;
135
              ++__q;
136
            }
137
          *__q = *__p;
138
        }
139
    }
140
 
141
  // Copy n consecutive elements of e into consecutive elements of a.
142
  // I.e. a[i] = e[i].
143
  template
144
    void
145
    __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n, _Array<_Tp> __a)
146
    {
147
      _Tp* __p (__a._M_data);
148
      for (size_t __i = 0; __i < __n; ++__i, ++__p)
149
        *__p = __e[__i];
150
    }
151
 
152
  // Copy n consecutive elements of e into elements of a using stride
153
  // s.  I.e., a[0] = e[0], a[s] = e[1], a[2*s] = e[2].
154
  template
155
    void
156
    __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
157
                     _Array<_Tp> __a, size_t __s)
158
    {
159
      _Tp* __p (__a._M_data);
160
      for (size_t __i = 0; __i < __n; ++__i, __p += __s)
161
        *__p = __e[__i];
162
    }
163
 
164
  // Copy n consecutive elements of e into elements of a indexed by
165
  // contents of i.  I.e., a[i[0]] = e[0].
166
  template
167
    void
168
    __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
169
                    _Array<_Tp> __a, _Array __i)
170
    {
171
      size_t* __j (__i._M_data);
172
      for (size_t __k = 0; __k < __n; ++__k, ++__j)
173
        __a._M_data[*__j] = __e[__k];
174
    }
175
 
176
  // Copy n elements of e indexed by contents of f into elements of a
177
  // indexed by contents of i.  I.e., a[i[0]] = e[f[0]].
178
  template
179
    void
180
    __valarray_copy(_Array<_Tp> __e, _Array __f,
181
                    size_t __n,
182
                    _Array<_Tp> __a, _Array __i)
183
    {
184
      size_t* __g (__f._M_data);
185
      size_t* __j (__i._M_data);
186
      for (size_t __k = 0; __k < __n; ++__k, ++__j, ++__g)
187
        __a._M_data[*__j] = __e._M_data[*__g];
188
    }
189
 
190
  // Copy n consecutive elements of e into elements of a.  Elements of
191
  // a are skipped if the corresponding element of m is false.  m must
192
  // have at least n true elements and a must have at least as many
193
  // elements as the index of the nth true element of m.  I.e. if m
194
  // has 5 false followed by 10 true elements and n == 10, a must have
195
  // at least 15 elements.
196
  template
197
    void
198
    __valarray_copy(const _Expr<_Dom, _Tp>& __e, size_t __n,
199
                    _Array<_Tp> __a, _Array __m)
200
    {
201
      bool* __ok (__m._M_data);
202
      _Tp* __p (__a._M_data);
203
      for (size_t __i = 0; __i < __n; ++__i, ++__ok, ++__p)
204
        {
205
          while (! *__ok)
206
            {
207
              ++__ok;
208
              ++__p;
209
            }
210
          *__p = __e[__i];
211
        }
212
    }
213
 
214
 
215
  template
216
    void
217
    __valarray_copy_construct(const _Expr<_Dom, _Tp>& __e, size_t __n,
218
                              _Array<_Tp> __a)
219
    {
220
      _Tp* __p (__a._M_data);
221
      for (size_t __i = 0; __i < __n; ++__i, ++__p)
222
        new (__p) _Tp(__e[__i]);
223
    }
224
 
225
 
226
  template
227
    void
228
    __valarray_copy_construct(_Array<_Tp> __a, _Array __m,
229
                              _Array<_Tp> __b, size_t __n)
230
    {
231
      _Tp* __p (__a._M_data);
232
      bool* __ok (__m._M_data);
233
      for (_Tp* __q = __b._M_data; __q < __b._M_data+__n; ++__q, ++__ok, ++__p)
234
        {
235
          while (! *__ok)
236
            {
237
              ++__ok;
238
              ++__p;
239
            }
240
          new (__q) _Tp(*__p);
241
        }
242
    }
243
} // namespace std
244
 
245
#endif /* _VALARRAY_ARRAY_TCC */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.