1 //===------------------------ valarray.cpp --------------------------------===// 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 template valarray<size_t>::valarray(size_t); 14 template valarray<size_t>::~valarray(); 15 template void valarray<size_t>::resize(size_t, size_t); 16 17 void 18 gslice::__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 54