]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libstdc++-v3/contrib/libstdc++-v3-4.3.3/src/valarray-inst.cc
update
[l4.git] / l4 / pkg / libstdc++-v3 / contrib / libstdc++-v3-4.3.3 / src / valarray-inst.cc
1 // Explicit instantiation file.
2
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
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 2, 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 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 //
32 // ISO C++ 14882:
33 //
34
35 #include <valarray>
36
37 _GLIBCXX_BEGIN_NAMESPACE(std)
38
39   // Some explicit instantiations.
40   template void
41      __valarray_fill(size_t* __restrict__, size_t, const size_t&);
42   
43   template void
44      __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
45   
46   template valarray<size_t>::valarray(size_t);
47   template valarray<size_t>::valarray(const valarray<size_t>&);
48   template valarray<size_t>::~valarray();
49   template size_t valarray<size_t>::size() const;
50   template size_t& valarray<size_t>::operator[](size_t);
51
52   inline size_t
53   __valarray_product(const valarray<size_t>& __a)
54   {
55     typedef const size_t* __restrict__ _Tp;
56     const size_t __n = __a.size();
57     // XXX: This ugly cast is necessary because
58     //      valarray::operator[]() const return a VALUE!
59     //      Try to get the committee to correct that gross error.
60     valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a);
61     return __valarray_product(&__t[0], &__t[0] + __n);
62   }
63   
64   // Map a gslice, described by its multidimensional LENGTHS
65   // and corresponding STRIDES, to a linear array of INDEXES
66   // for the purpose of indexing a flat, one-dimensional array
67   // representation of a gslice_array.
68   void
69   __gslice_to_index(size_t __o, const valarray<size_t>& __l,
70                     const valarray<size_t>& __s, valarray<size_t>& __i)
71   {
72     // There are as many dimensions as there are strides.
73     const size_t __n = __l.size();
74
75     // Holds current multi-index as we go through the gslice for the
76     // purpose of computing its linear-image.
77     valarray<size_t> __t(__l);
78
79     // Note that this should match the product of all numbers appearing
80     // in __l which describes the multidimensional sizes of the
81     // generalized slice.
82     const size_t __z = __i.size();
83
84     for (size_t __j = 0; __j < __z; ++__j)
85       {
86         // Compute the linear-index image of (t_0, ... t_{n-1}).
87         __i[__j] = __o;
88
89         --__t[__n - 1];
90         __o += __s[__n - 1];
91
92         // Process the next multi-index.  The loop ought to be
93         // backward since we're making a lexicographical visit.
94         for (size_t __k2 = __n - 1; __k2 && !__t[__k2]; --__k2)
95           {
96             __o -= __s[__k2] * __l[__k2];
97             __t[__k2] = __l[__k2];
98
99             --__t[__k2 - 1];
100             __o += __s[__k2 - 1];
101           }
102       }
103   }
104   
105   gslice::_Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
106                              const valarray<size_t>& __s)
107   : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
108     _M_index(__l.size() == 0 ? 0 : __valarray_product(__l))
109   { __gslice_to_index(__o, __l, __s, _M_index); }  
110
111 _GLIBCXX_END_NAMESPACE