blob: 893de050fc688e46e413518f07ddda76ca9c774d [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161//===------------------------ valarray.cpp --------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:403// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:166//
7//===----------------------------------------------------------------------===//
8
Howard Hinnant3e519522010-05-11 19:42:169#include "valarray"
10
11_LIBCPP_BEGIN_NAMESPACE_STD
12
13template valarray<size_t>::valarray(size_t);
14template valarray<size_t>::~valarray();
15template void valarray<size_t>::resize(size_t, size_t);
16
17void
18gslice::__init(size_t __start)
19{
20 valarray<size_t> __indices(__size_.size());
21 size_t __k = __size_.size() != 0;
22 for (size_t __i = 0; __i < __size_.size(); ++__i)
23 __k *= __size_[__i];
24 __1d_.resize(__k);
25 if (__1d_.size())
26 {
27 __k = 0;
28 __1d_[__k] = __start;
29 while (true)
30 {
31 size_t __i = __indices.size() - 1;
32 while (true)
33 {
34 if (++__indices[__i] < __size_[__i])
35 {
36 ++__k;
37 __1d_[__k] = __1d_[__k-1] + __stride_[__i];
38 for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
39 __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
40 break;
41 }
42 else
43 {
44 if (__i == 0)
45 return;
46 __indices[__i--] = 0;
47 }
48 }
49 }
50 }
51}
52
53_LIBCPP_END_NAMESPACE_STD