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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [src/] [valarray-inst.cc] - Blame information for rev 18

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 jlechner
// Explicit instantiation file.
2
 
3
// Copyright (C) 2001, 2004 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
//
31
// ISO C++ 14882:
32
//
33
 
34
#include <valarray>
35
 
36
namespace std
37
{
38
  // Some explicit instantiations.
39
  template void
40
     __valarray_fill(size_t* __restrict__, size_t, const size_t&);
41
 
42
  template void
43
     __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
44
 
45
  template valarray<size_t>::valarray(size_t);
46
  template valarray<size_t>::valarray(const valarray<size_t>&);
47
  template valarray<size_t>::~valarray();
48
  template size_t valarray<size_t>::size() const;
49
  template size_t& valarray<size_t>::operator[](size_t);
50
 
51
  inline size_t
52
  __valarray_product(const valarray<size_t>& __a)
53
  {
54
    typedef const size_t* __restrict__ _Tp;
55
    const size_t __n = __a.size();
56
    // XXX: This ugly cast is necessary because
57
    //      valarray::operator[]() const return a VALUE!
58
    //      Try to get the committee to correct that gross error.
59
    valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a);
60
    return __valarray_product(&__t[0], &__t[0] + __n);
61
  }
62
 
63
  // Map a gslice, described by its multidimensional LENGTHS
64
  // and corresponding STRIDES, to a linear array of INDEXES
65
  // for the purpose of indexing a flat, one-dimensional array
66
  // representation of a gslice_array.
67
  void
68
  __gslice_to_index(size_t __o, const valarray<size_t>& __l,
69
                    const valarray<size_t>& __s, valarray<size_t>& __i)
70
  {
71
    // There are as much as dimensions as there are strides.
72
    size_t __n = __l.size();
73
 
74
    // Get a buffer to hold current multi-index as we go through
75
    // the gslice for the purpose of computing its linear-image.
76
    size_t* const __t = static_cast<size_t*>
77
      (__builtin_alloca(__n * sizeof (size_t)));
78
    __valarray_fill(__t, __n, size_t(0));
79
 
80
    // Note that this should match the product of all numbers appearing
81
    // in __l which describes the multidimensional sizes of the
82
    // the generalized slice.
83
    const size_t __z = __i.size();
84
 
85
    for (size_t __j = 0; __j < __z; ++__j)
86
      {
87
        // Compute the linear-index image of (t_0, ... t_{n-1}).
88
        // Normaly, we should use inner_product<>(), but we do it the
89
        // the hard way here to avoid link-time can of worms.
90
        size_t __a = __o;
91
        for (size_t __k = 0; __k < __n; ++__k)
92
          __a += __s[__k] * __t[__k];
93
 
94
        __i[__j] = __a;
95
 
96
        // Process the next multi-index.  The loop ought to be
97
        // backward since we're making a lexicagraphical visit.
98
        ++__t[__n - 1];
99
        for (size_t __k2 = __n - 1; __k2; --__k2)
100
          {
101
            if (__t[__k2] >= __l[__k2])
102
              {
103
                __t[__k2] = 0;
104
                ++__t[__k2 - 1];
105
              }
106
          }
107
      }
108
  }
109
 
110
  gslice::_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
111
                             const valarray<size_t>& __s)
112
  : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
113
    _M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
114
  { __gslice_to_index(__o, __l, __s, _M_index); }
115
} // namespace std

powered by: WebSVN 2.1.0

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