1 | // Copyright (C) 2009-2015 Conrad Sanderson |
---|
2 | // Copyright (C) 2009-2015 NICTA (www.nicta.com.au) |
---|
3 | // |
---|
4 | // This Source Code Form is subject to the terms of the Mozilla Public |
---|
5 | // License, v. 2.0. If a copy of the MPL was not distributed with this |
---|
6 | // file, You can obtain one at http://mozilla.org/MPL/2.0/. |
---|
7 | |
---|
8 | |
---|
9 | //! \addtogroup fn_sort_index |
---|
10 | //! @{ |
---|
11 | |
---|
12 | |
---|
13 | |
---|
14 | |
---|
15 | //! kept for compatibility with old code |
---|
16 | template<typename T1> |
---|
17 | inline |
---|
18 | const mtOp<uword,T1,op_sort_index> |
---|
19 | sort_index |
---|
20 | ( |
---|
21 | const Base<typename T1::elem_type,T1>& X, |
---|
22 | const uword sort_type = 0 |
---|
23 | ) |
---|
24 | { |
---|
25 | arma_extra_debug_sigprint(); |
---|
26 | |
---|
27 | arma_debug_check( (sort_type > 1), "sort_index(): sort_type must be 0 or 1"); |
---|
28 | |
---|
29 | return mtOp<uword,T1,op_sort_index>(X.get_ref(), sort_type, uword(0)); |
---|
30 | } |
---|
31 | |
---|
32 | |
---|
33 | |
---|
34 | //! kept for compatibility with old code |
---|
35 | template<typename T1> |
---|
36 | inline |
---|
37 | const mtOp<uword,T1,op_stable_sort_index> |
---|
38 | stable_sort_index |
---|
39 | ( |
---|
40 | const Base<typename T1::elem_type,T1>& X, |
---|
41 | const uword sort_type = 0 |
---|
42 | ) |
---|
43 | { |
---|
44 | arma_extra_debug_sigprint(); |
---|
45 | |
---|
46 | arma_debug_check( (sort_type > 1), "stable_sort_index(): sort_type must be 0 or 1"); |
---|
47 | |
---|
48 | return mtOp<uword,T1,op_stable_sort_index>(X.get_ref(), sort_type, uword(0)); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | template<typename T1, typename T2> |
---|
54 | inline |
---|
55 | typename |
---|
56 | enable_if2 |
---|
57 | < |
---|
58 | ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value == true) ), |
---|
59 | const mtOp<uword,T1,op_sort_index> |
---|
60 | >::result |
---|
61 | sort_index |
---|
62 | ( |
---|
63 | const T1& X, |
---|
64 | const T2* sort_direction |
---|
65 | ) |
---|
66 | { |
---|
67 | arma_extra_debug_sigprint(); |
---|
68 | |
---|
69 | const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); |
---|
70 | |
---|
71 | arma_debug_check( ((sig != 'a') && (sig != 'd')), "sort_index(): unknown sort direction" ); |
---|
72 | |
---|
73 | return mtOp<uword,T1,op_sort_index>(X, ((sig == 'a') ? uword(0) : uword(1)), uword(0)); |
---|
74 | } |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | template<typename T1, typename T2> |
---|
79 | inline |
---|
80 | typename |
---|
81 | enable_if2 |
---|
82 | < |
---|
83 | ( (is_arma_type<T1>::value == true) && (is_same_type<T2, char>::value == true) ), |
---|
84 | const mtOp<uword,T1,op_stable_sort_index> |
---|
85 | >::result |
---|
86 | stable_sort_index |
---|
87 | ( |
---|
88 | const T1& X, |
---|
89 | const T2* sort_direction |
---|
90 | ) |
---|
91 | { |
---|
92 | arma_extra_debug_sigprint(); |
---|
93 | |
---|
94 | const char sig = (sort_direction != NULL) ? sort_direction[0] : char(0); |
---|
95 | |
---|
96 | arma_debug_check( ((sig != 'a') && (sig != 'd')), "stable_sort_index(): unknown sort direction" ); |
---|
97 | |
---|
98 | return mtOp<uword,T1,op_stable_sort_index>(X, ((sig == 'a') ? uword(0) : uword(1)), uword(0)); |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | //! @} |
---|