1 // Explicit instantiation file.
3 // Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
31 namespace std
_GLIBCXX_VISIBILITY(default)
33 _GLIBCXX_BEGIN_NAMESPACE_VERSION
35 // Some explicit instantiations.
37 __valarray_fill(size_t* __restrict__
, size_t, const size_t&);
40 __valarray_copy(const size_t* __restrict__
, size_t, size_t* __restrict__
);
42 template valarray
<size_t>::valarray(size_t);
43 template valarray
<size_t>::valarray(const valarray
<size_t>&);
44 template valarray
<size_t>::~valarray();
45 template size_t valarray
<size_t>::size() const;
46 template size_t& valarray
<size_t>::operator[](size_t);
48 // Compute the product of all elements in the non-empty range [__f, __l)
49 template<typename _Tp
>
51 __valarray_product(const _Tp
* __f
, const _Tp
* __l
)
60 __valarray_product(const valarray
<size_t>& __a
)
62 return __valarray_product(&__a
[0], &__a
[0] + __a
.size());
65 // Map a gslice, described by its multidimensional LENGTHS
66 // and corresponding STRIDES, to a linear array of INDEXES
67 // for the purpose of indexing a flat, one-dimensional array
68 // representation of a gslice_array.
70 __gslice_to_index(size_t __o
, const valarray
<size_t>& __l
,
71 const valarray
<size_t>& __s
, valarray
<size_t>& __i
)
73 // There are as many dimensions as there are strides.
74 const size_t __n
= __l
.size();
76 // Holds current multi-index as we go through the gslice for the
77 // purpose of computing its linear-image.
78 valarray
<size_t> __t(__l
);
80 // Note that this should match the product of all numbers appearing
81 // in __l which describes the multidimensional sizes of the
83 const size_t __z
= __i
.size();
85 for (size_t __j
= 0; __j
< __z
; ++__j
)
87 // Compute the linear-index image of (t_0, ... t_{n-1}).
93 // Process the next multi-index. The loop ought to be
94 // backward since we're making a lexicographical visit.
95 for (size_t __k2
= __n
- 1; __k2
&& !__t
[__k2
]; --__k2
)
97 __o
-= __s
[__k2
] * __l
[__k2
];
98 __t
[__k2
] = __l
[__k2
];
101 __o
+= __s
[__k2
- 1];
106 gslice::_Indexer::_Indexer(size_t __o
, const valarray
<size_t>& __l
,
107 const valarray
<size_t>& __s
)
108 : _M_count(1), _M_start(__o
), _M_size(__l
), _M_stride(__s
),
109 _M_index(__l
.size() == 0 ? 0 : __valarray_product(__l
))
110 { __gslice_to_index(__o
, __l
, __s
, _M_index
); }
112 _GLIBCXX_END_NAMESPACE_VERSION