1349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
981ad6265SDimitry Andric #include <valarray>
100b57cec5SDimitry Andric 
110b57cec5SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric // These two symbols are part of the v1 ABI but not part of the >=v2 ABI.
140b57cec5SDimitry Andric #if _LIBCPP_ABI_VERSION == 1
15fe013be4SDimitry Andric template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t);
16fe013be4SDimitry Andric template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray();
170b57cec5SDimitry Andric #endif
180b57cec5SDimitry Andric 
190b57cec5SDimitry Andric template void valarray<size_t>::resize(size_t, size_t);
200b57cec5SDimitry Andric 
__init(size_t __start)21*e710425bSDimitry Andric void gslice::__init(size_t __start) {
220b57cec5SDimitry Andric   valarray<size_t> __indices(__size_.size());
230b57cec5SDimitry Andric   size_t __k = __size_.size() != 0;
240b57cec5SDimitry Andric   for (size_t __i = 0; __i < __size_.size(); ++__i)
250b57cec5SDimitry Andric     __k *= __size_[__i];
260b57cec5SDimitry Andric   __1d_.resize(__k);
27*e710425bSDimitry Andric   if (__1d_.size()) {
280b57cec5SDimitry Andric     __k        = 0;
290b57cec5SDimitry Andric     __1d_[__k] = __start;
30*e710425bSDimitry Andric     while (true) {
310b57cec5SDimitry Andric       size_t __i = __indices.size() - 1;
32*e710425bSDimitry Andric       while (true) {
33*e710425bSDimitry Andric         if (++__indices[__i] < __size_[__i]) {
340b57cec5SDimitry Andric           ++__k;
350b57cec5SDimitry Andric           __1d_[__k] = __1d_[__k - 1] + __stride_[__i];
360b57cec5SDimitry Andric           for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
370b57cec5SDimitry Andric             __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
380b57cec5SDimitry Andric           break;
39*e710425bSDimitry Andric         } else {
400b57cec5SDimitry Andric           if (__i == 0)
410b57cec5SDimitry Andric             return;
420b57cec5SDimitry Andric           __indices[__i--] = 0;
430b57cec5SDimitry Andric         }
440b57cec5SDimitry Andric       }
450b57cec5SDimitry Andric     }
460b57cec5SDimitry Andric   }
470b57cec5SDimitry Andric }
480b57cec5SDimitry Andric 
490b57cec5SDimitry Andric _LIBCPP_END_NAMESPACE_STD
50