]>
Commit | Line | Data |
---|---|---|
b2dad0e3 BK |
1 | #include <bits/std_valarray.h> |
2 | ||
3 | namespace std | |
4 | { | |
5 | // Some explicit instanciations. | |
6 | template void | |
7 | __valarray_fill(size_t* __restrict__, size_t, const size_t&); | |
8 | ||
9 | template void | |
10 | __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__); | |
11 | ||
12 | template size_t | |
13 | __valarray_product(const size_t* __restrict__, const size_t* __restrict__); | |
14 | ||
15 | template valarray<size_t>::valarray(size_t); | |
16 | template valarray<size_t>::valarray(const valarray<size_t>&); | |
17 | template valarray<size_t>::~valarray(); | |
18 | template size_t valarray<size_t>::size() const; | |
19 | template size_t& valarray<size_t>::operator[](size_t); | |
20 | ||
21 | ||
22 | inline size_t | |
23 | __valarray_product(const valarray<size_t>& __a) | |
24 | { | |
d4c4ae6f GDR |
25 | typedef const size_t* __restrict__ _Tp; |
26 | const size_t __n = __a.size(); | |
b2dad0e3 BK |
27 | // XXX: This ugly cast is necessary because |
28 | // valarray::operator[]() const return a VALUE! | |
29 | // Try to get the committee to correct that gross error. | |
b2dad0e3 | 30 | valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a); |
d4c4ae6f | 31 | return __valarray_product(&__t[0], &__t[0] + __n); |
b2dad0e3 BK |
32 | } |
33 | ||
34 | void __gslice_to_index(size_t __o, const valarray<size_t>& __l, | |
35 | const valarray<size_t>& __s, | |
36 | valarray<size_t>& __i) | |
37 | { | |
38 | size_t __n = __l.size(); | |
39 | size_t* const __t = static_cast<size_t*> | |
40 | (__builtin_alloca(__n*sizeof(size_t))); | |
41 | __valarray_fill(__t, __n, size_t(0)); | |
42 | const size_t __z = __i.size(); | |
43 | __valarray_fill(&__i[0], __z, __o); | |
44 | for (size_t __j=0; __j<__z; ++__j) { | |
45 | for (size_t __k=0; __k<__n; ++__k) | |
46 | __i[__j] += __s[__k]*__t[__k]; | |
47 | ++__t[__n-1]; | |
48 | for (size_t __k=__n-1; __k; --__k) { | |
49 | if (__t[__k] >= __l[__k]) { | |
50 | __t[__k] = 0; | |
51 | ++__t[__k-1]; | |
52 | } | |
53 | } | |
54 | } | |
55 | } | |
56 | ||
57 | gslice::_Indexer::_Indexer(size_t __o, const valarray<size_t>& __s, | |
58 | const valarray<size_t>& __l) | |
59 | : _M_count(1), _M_start(__o), _M_size(__s), _M_stride(__l), | |
60 | _M_index(__l.size() ? __valarray_product(__l) : 0) | |
61 | { __gslice_to_index(__o, __l, __s, _M_index); } | |
62 | ||
63 | } |