]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/libstdc++-v3/contrib/libstdc++-v3-4.6/src/valarray.cc
Update
[l4.git] / l4 / pkg / l4re-core / libstdc++-v3 / contrib / libstdc++-v3-4.6 / src / valarray.cc
1 // Explicit instantiation file.
2
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library.  This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
11
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
20
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24 // <http://www.gnu.org/licenses/>.
25
26 //
27 // ISO C++ 14882:
28 //
29
30 #include <valarray>
31
32 namespace std _GLIBCXX_VISIBILITY(default)
33 {
34 _GLIBCXX_BEGIN_NAMESPACE_VERSION
35
36   // Some explicit instantiations.
37   template void
38      __valarray_fill(size_t* __restrict__, size_t, const size_t&);
39   
40   template void
41      __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
42   
43   template valarray<size_t>::valarray(size_t);
44   template valarray<size_t>::valarray(const valarray<size_t>&);
45   template valarray<size_t>::~valarray();
46   template size_t valarray<size_t>::size() const;
47   template size_t& valarray<size_t>::operator[](size_t);
48
49   inline size_t
50   __valarray_product(const valarray<size_t>& __a)
51   {
52     typedef const size_t* __restrict__ _Tp;
53     const size_t __n = __a.size();
54     // XXX: This ugly cast is necessary because
55     //      valarray::operator[]() const return a VALUE!
56     //      Try to get the committee to correct that gross error.
57     valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a);
58     return __valarray_product(&__t[0], &__t[0] + __n);
59   }
60   
61   // Map a gslice, described by its multidimensional LENGTHS
62   // and corresponding STRIDES, to a linear array of INDEXES
63   // for the purpose of indexing a flat, one-dimensional array
64   // representation of a gslice_array.
65   void
66   __gslice_to_index(size_t __o, const valarray<size_t>& __l,
67                     const valarray<size_t>& __s, valarray<size_t>& __i)
68   {
69     // There are as many dimensions as there are strides.
70     const size_t __n = __l.size();
71
72     // Holds current multi-index as we go through the gslice for the
73     // purpose of computing its linear-image.
74     valarray<size_t> __t(__l);
75
76     // Note that this should match the product of all numbers appearing
77     // in __l which describes the multidimensional sizes of the
78     // generalized slice.
79     const size_t __z = __i.size();
80
81     for (size_t __j = 0; __j < __z; ++__j)
82       {
83         // Compute the linear-index image of (t_0, ... t_{n-1}).
84         __i[__j] = __o;
85
86         --__t[__n - 1];
87         __o += __s[__n - 1];
88
89         // Process the next multi-index.  The loop ought to be
90         // backward since we're making a lexicographical visit.
91         for (size_t __k2 = __n - 1; __k2 && !__t[__k2]; --__k2)
92           {
93             __o -= __s[__k2] * __l[__k2];
94             __t[__k2] = __l[__k2];
95
96             --__t[__k2 - 1];
97             __o += __s[__k2 - 1];
98           }
99       }
100   }
101   
102   gslice::_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
103                              const valarray<size_t>& __s)
104   : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
105     _M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
106   { __gslice_to_index(__o, __l, __s, _M_index); }  
107
108 _GLIBCXX_END_NAMESPACE_VERSION
109 } // namespace