1//===----------------------------------------------------------------------===//
2//
3// 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
6//
7//===----------------------------------------------------------------------===//
8
9#include <valarray>
10
11_LIBCPP_BEGIN_NAMESPACE_STD
12
13#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9
14template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t);
15template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray();
16#endif
17
18template void valarray<size_t>::resize(size_t, size_t);
19
20void 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(n: __k);
26 if (__1d_.size()) {
27 __k = 0;
28 __1d_[__k] = __start;
29 while (true) {
30 size_t __i = __indices.size() - 1;
31 while (true) {
32 if (++__indices[__i] < __size_[__i]) {
33 ++__k;
34 __1d_[__k] = __1d_[__k - 1] + __stride_[__i];
35 for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
36 __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
37 break;
38 } else {
39 if (__i == 0)
40 return;
41 __indices[__i--] = 0;
42 }
43 }
44 }
45 }
46}
47
48_LIBCPP_END_NAMESPACE_STD
49