1 #include <std/std_valarray.h> 2 3 // Some Explicit Instanciations. 4 template class multiplies<size_t>; 5 template size_t accumulate(size_t*, size_t*, size_t, multiplies<size_t>); 6 7 template void 8 __valarray_fill(size_t* __restrict__, size_t, const size_t&); 9 10 template void 11 __valarray_copy(const size_t* __restrict__, size_t, size_t* __restrict__); 12 13 template valarray<size_t>::valarray(size_t); 14 template valarray<size_t>::~valarray(); 15 template valarray<size_t>::valarray(const valarray<size_t>&); 16 template size_t valarray<size_t>::size() const; 17 template size_t& valarray<size_t>::operator[](size_t); 18 template size_t valarray<size_t>::product() const; 19 20 21 void __gslice_to_index(size_t __o, const valarray<size_t>& __l, 22 const valarray<size_t>& __s, 23 valarray<size_t>& __i) 24 { 25 const size_t __n = __l.size(); 26 size_t* const __t = static_cast<size_t*>(alloca(__n*sizeof(size_t))); 27 __valarray_fill(__t, __n, size_t(0)); 28 const size_t __z = __i.size(); 29 __valarray_fill(&__i[0], __z, __o); 30 for (size_t __j=0; __j<__z; ++__j) { 31 for (size_t __k=0; __k<__n; ++__k) 32 __i[__j] += __s[__k]*__t[__k]; 33 ++__t[__n-1]; 34 for (size_t __k=__n-1; __k; --__k) { 35 if (__t[__k] >= __l[__k]) { 36 __t[__k] = 0; 37 ++__t[__k-1]; 38 } 39 } 40 } 41 } 42 43 _Indexer::_Indexer(size_t __o, const valarray<size_t>& __l, 44 const valarray<size_t>& __s) 45 : _M_count(1), _M_start(__o), _M_size(__l), _M_stride(__s), 46 _M_index(__l.size() ? __l.product() : 0) 47 { __gslice_to_index(__o, __l, __s, _M_index); } 48 49 50 51