etc/services - sync with NetBSD-8
[minix.git] / external / bsd / libc++ / dist / libcxx / src / valarray.cpp
blob2d8db52ac36b2b9346693367b302e44892ef2e75
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 //===----------------------------------------------------------------------===//
10 #include "valarray"
12 _LIBCPP_BEGIN_NAMESPACE_STD
14 template valarray<size_t>::valarray(size_t);
15 template valarray<size_t>::~valarray();
16 template void valarray<size_t>::resize(size_t, size_t);
18 void
19 gslice::__init(size_t __start)
21 valarray<size_t> __indices(__size_.size());
22 size_t __k = __size_.size() != 0;
23 for (size_t __i = 0; __i < __size_.size(); ++__i)
24 __k *= __size_[__i];
25 __1d_.resize(__k);
26 if (__1d_.size())
28 __k = 0;
29 __1d_[__k] = __start;
30 while (true)
32 size_t __i = __indices.size() - 1;
33 while (true)
35 if (++__indices[__i] < __size_[__i])
37 ++__k;
38 __1d_[__k] = __1d_[__k-1] + __stride_[__i];
39 for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
40 __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
41 break;
43 else
45 if (__i == 0)
46 return;
47 __indices[__i--] = 0;
54 _LIBCPP_END_NAMESPACE_STD