blob: 5d63bc11846d53d116880563fe25568e5046cf09 [file] [log] [blame]
Louis Dionne9bd93882021-11-17 16:25:01 -05001//===----------------------------------------------------------------------===//
Howard Hinnantc51e1022010-05-11 19:42:16 +00002//
Chandler Carruthd2012102019-01-19 10:56:40 +00003// 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 Hinnantc51e1022010-05-11 19:42:16 +00006//
7//===----------------------------------------------------------------------===//
8
Arthur O'Dwyercf9bf392022-02-11 13:00:39 -05009#include <valarray>
Howard Hinnantc51e1022010-05-11 19:42:16 +000010
11_LIBCPP_BEGIN_NAMESPACE_STD
12
Richard Smith4e2010d2019-04-25 21:31:58 +000013// These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
14#if _LIBCPP_ABI_VERSION == 1
Louis Dionne0ba10dc2019-08-13 15:02:53 +000015template _LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t);
16template _LIBCPP_FUNC_VIS valarray<size_t>::~valarray();
Richard Smith4e2010d2019-04-25 21:31:58 +000017#endif
18
Howard Hinnantc51e1022010-05-11 19:42:16 +000019template void valarray<size_t>::resize(size_t, size_t);
20
21void
22gslice::__init(size_t __start)
23{
24 valarray<size_t> __indices(__size_.size());
25 size_t __k = __size_.size() != 0;
26 for (size_t __i = 0; __i < __size_.size(); ++__i)
27 __k *= __size_[__i];
28 __1d_.resize(__k);
29 if (__1d_.size())
30 {
31 __k = 0;
32 __1d_[__k] = __start;
33 while (true)
34 {
35 size_t __i = __indices.size() - 1;
36 while (true)
37 {
38 if (++__indices[__i] < __size_[__i])
39 {
40 ++__k;
41 __1d_[__k] = __1d_[__k-1] + __stride_[__i];
42 for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
43 __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
44 break;
45 }
46 else
47 {
48 if (__i == 0)
49 return;
50 __indices[__i--] = 0;
51 }
52 }
53 }
54 }
55}
56
57_LIBCPP_END_NAMESPACE_STD