Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
sort.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2014 NVIDIA Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
21 #pragma once
22 
23 #include <cusp/detail/config.h>
24 
25 #include <thrust/execution_policy.h>
26 
27 namespace cusp
28 {
29 
36 /* \cond */
37 template <typename DerivedPolicy, typename ArrayType>
38 void counting_sort(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
39  ArrayType& keys,
40  typename ArrayType::value_type min, typename ArrayType::value_type max);
41 /* \endcond */
42 
91 template <typename ArrayType>
92 void counting_sort(ArrayType& keys, typename ArrayType::value_type min, typename ArrayType::value_type max);
93 
94 /* \cond */
95 template <typename DerivedPolicy, typename ArrayType1, typename ArrayType2>
96 void counting_sort_by_key(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
97  ArrayType1& keys, ArrayType2& vals,
98  typename ArrayType1::value_type min,
99  typename ArrayType1::value_type max);
100 /* \endcond */
101 
157 template <typename ArrayType1, typename ArrayType2>
158 void counting_sort_by_key(ArrayType1& keys, ArrayType2& vals,
159  typename ArrayType1::value_type min,
160  typename ArrayType1::value_type max);
161 
162 
163 /* \cond */
164 template <typename DerivedPolicy, typename ArrayType1, typename ArrayType2, typename ArrayType3>
165 void sort_by_row(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
166  ArrayType1& row_indices, ArrayType2& column_indices, ArrayType3& values,
167  typename ArrayType1::value_type min_row = 0,
168  typename ArrayType1::value_type max_row = 0);
169 /* \endcond */
170 
215 template <typename ArrayType1, typename ArrayType2, typename ArrayType3>
216 void sort_by_row(ArrayType1& row_indices, ArrayType2& column_indices, ArrayType3& values,
217  typename ArrayType1::value_type min_row = 0,
218  typename ArrayType1::value_type max_row = 0);
219 
220 /* \cond */
221 template <typename DerivedPolicy, typename ArrayType1, typename ArrayType2, typename ArrayType3>
222 void sort_by_row_and_column(const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
223  ArrayType1& row_indices, ArrayType2& column_indices, ArrayType3& values,
224  typename ArrayType1::value_type min_row = 0,
225  typename ArrayType1::value_type max_row = 0,
226  typename ArrayType2::value_type min_col = 0,
227  typename ArrayType2::value_type max_col = 0);
228 /* \endcond */
229 
277 template <typename ArrayType1, typename ArrayType2, typename ArrayType3>
278 void sort_by_row_and_column(ArrayType1& row_indices, ArrayType2& column_indices, ArrayType3& values,
279  typename ArrayType1::value_type min_row = 0,
280  typename ArrayType1::value_type max_row = 0,
281  typename ArrayType2::value_type min_col = 0,
282  typename ArrayType2::value_type max_col = 0);
286 } // end namespace cusp
287 
288 #include <cusp/detail/sort.inl>
289 
void sort_by_row(ArrayType1 &row_indices, ArrayType2 &column_indices, ArrayType3 &values, typename ArrayType1::value_type min_row=0, typename ArrayType1::value_type max_row=0)
Sort matrix indices by row.
void sort_by_row_and_column(ArrayType1 &row_indices, ArrayType2 &column_indices, ArrayType3 &values, typename ArrayType1::value_type min_row=0, typename ArrayType1::value_type max_row=0, typename ArrayType2::value_type min_col=0, typename ArrayType2::value_type max_col=0)
Sort matrix indices by row and column.
void counting_sort(ArrayType &keys, typename ArrayType::value_type min, typename ArrayType::value_type max)
Use counting sort to order an array.
void counting_sort_by_key(ArrayType1 &keys, ArrayType2 &vals, typename ArrayType1::value_type min, typename ArrayType1::value_type max)
Use counting sort to order an array and permute an array of values.