blob: 6ef1f1cafc0e53dfb4dad4525deb96dfe114e5a0 [file] [log] [blame]
Louis Dionneeb8650a2021-11-17 21:25:011//===----------------------------------------------------------------------===//
Howard Hinnant3e519522010-05-11 19:42:162//
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
Arthur O'Dwyerbbb0f2c2022-02-11 18:00:399#include <valarray>
Howard Hinnant3e519522010-05-11 19:42:1610
11_LIBCPP_BEGIN_NAMESPACE_STD
12
Richard Smithde329352019-04-25 21:31:5813// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
14#if _LIBCPP_ABI_VERSION == 1
Nikolas Klauserf1ea0b12023-06-14 17:17:5015template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t);
16template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray();
Richard Smithde329352019-04-25 21:31:5817#endif
18
Howard Hinnant3e519522010-05-11 19:42:1619template void valarray<size_t>::resize(size_t, size_t);
20
Louis Dionne9783f282023-12-18 19:01:3321void gslice::__init(size_t __start) {
22 valarray<size_t> __indices(__size_.size());
23 size_t __k = __size_.size() != 0;
24 for (size_t __i = 0; __i < __size_.size(); ++__i)
25 __k *= __size_[__i];
26 __1d_.resize(__k);
27 if (__1d_.size()) {
28 __k = 0;
29 __1d_[__k] = __start;
30 while (true) {
31 size_t __i = __indices.size() - 1;
32 while (true) {
33 if (++__indices[__i] < __size_[__i]) {
34 ++__k;
35 __1d_[__k] = __1d_[__k - 1] + __stride_[__i];
36 for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
37 __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
38 break;
39 } else {
40 if (__i == 0)
41 return;
42 __indices[__i--] = 0;
Howard Hinnant3e519522010-05-11 19:42:1643 }
Louis Dionne9783f282023-12-18 19:01:3344 }
Howard Hinnant3e519522010-05-11 19:42:1645 }
Louis Dionne9783f282023-12-18 19:01:3346 }
Howard Hinnant3e519522010-05-11 19:42:1647}
48
49_LIBCPP_END_NAMESPACE_STD