* gcc.dg/c90-digraph-1.c: Restore { dg-do run } marker.
[official-gcc.git] / libstdc++ / valarray.cc
blob5de4e9299821a9a2a4432afb49e1373e814a7184
1 #include <std/std_valarray.h>
3 template void
4 __valarray_fill(size_t* __restrict__, size_t, const size_t&);
6 template void
7 __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__);
9 template valarray<size_t>::valarray(size_t);
10 template valarray<size_t>::~valarray();
11 template valarray<size_t>::valarray(const valarray<size_t>&);
12 template size_t valarray<size_t>::size() const;
13 template size_t& valarray<size_t>::operator[](size_t);
16 inline size_t
17 __valarray_product(const valarray<size_t>& __a)
19 // XXX: This ugly cast is necessary because
20 // valarray::operator[]() const returns a VALUE!
21 // Try to get the committee to correct that gross error.
22 typedef const size_t* __restrict__ _Tp;
23 const size_t __n = __a.size();
24 valarray<size_t>& __t = const_cast<valarray<size_t>&>(__a);
25 return __valarray_product(&__t[0], &__t[0] + __n);
29 void __gslice_to_index(size_t __o, const valarray<size_t>& __l,
30 const valarray<size_t>& __s,
31 valarray<size_t>& __i)
33 const size_t __n = __l.size();
34 size_t* const __t = static_cast<size_t*>(alloca(__n*sizeof(size_t)));
35 __valarray_fill(__t, __n, size_t(0));
36 const size_t __z = __i.size();
37 __valarray_fill(&__i[0], __z, __o);
38 for (size_t __j=0; __j<__z; ++__j) {
39 for (size_t __k=0; __k<__n; ++__k)
40 __i[__j] += __s[__k]*__t[__k];
41 ++__t[__n-1];
42 for (size_t __k=__n-1; __k; --__k) {
43 if (__t[__k] >= __l[__k]) {
44 __t[__k] = 0;
45 ++__t[__k-1];
51 _Indexer::_Indexer(size_t __o, const valarray<size_t>& __l,
52 const valarray<size_t>& __s)
53 : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s),
54 _M_index(__l.size() ? __valarray_product(__l) : 0)
55 { __gslice_to_index(__o, __l, __s, _M_index); }