1 //===------------------------ valarray.cpp --------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__;
11 
12 #include "valarray"
13 
14 _LIBCPP_BEGIN_NAMESPACE_STD
15 
16 template valarray<size_t>::valarray(size_t);
17 template valarray<size_t>::~valarray();
18 template void valarray<size_t>::resize(size_t, size_t);
19 
20 void
__init(size_t __start)21 gslice::__init(size_t __start)
22 {
23     valarray<size_t> __indices(__size_.size());
24     size_t __k = __size_.size() != 0;
25     for (size_t __i = 0; __i < __size_.size(); ++__i)
26         __k *= __size_[__i];
27     __1d_.resize(__k);
28     if (__1d_.size())
29     {
30         __k = 0;
31         __1d_[__k] = __start;
32         while (true)
33         {
34             size_t __i = __indices.size() - 1;
35             while (true)
36             {
37                 if (++__indices[__i] < __size_[__i])
38                 {
39                     ++__k;
40                     __1d_[__k] = __1d_[__k-1] + __stride_[__i];
41                     for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
42                         __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
43                     break;
44                 }
45                 else
46                 {
47                     if (__i == 0)
48                         return;
49                     __indices[__i--] = 0;
50                 }
51             }
52         }
53     }
54 }
55 
56 _LIBCPP_END_NAMESPACE_STD
57