Mercurial > hg > octave-lyh
changeset 7232:41680961da9b
[project @ 2007-11-30 19:09:34 by jwe]
author | jwe |
---|---|
date | Fri, 30 Nov 2007 19:09:34 +0000 |
parents | 2eb392d058bb |
children | c92f452c385f |
files | src/DLD-FUNCTIONS/sort.cc |
diffstat | 1 files changed, 58 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/sort.cc +++ b/src/DLD-FUNCTIONS/sort.cc @@ -67,21 +67,21 @@ template <class T> bool -ascending_compare (const vec_index<T> *a, const vec_index<T> *b) +ascending_compare (vec_index<T> *a, vec_index<T> *b) { return (a->vec < b->vec); } template <class T> bool -descending_compare (const vec_index<T> *a, const vec_index<T> *b) +descending_compare (vec_index<T> *a, vec_index<T> *b) { return (a->vec > b->vec); } template <class T> static octave_value -mx_sort (ArrayN<T>& m, int dim, sortmode mode = UNDEFINED) +mx_sort (ArrayN<T> &m, int dim, sortmode mode = UNDEFINED) { octave_value retval; @@ -143,7 +143,7 @@ template <class T> static octave_value_list -mx_sort_indexed (ArrayN<T>& m, int dim, sortmode mode = UNDEFINED) +mx_sort_indexed (ArrayN<T> &m, int dim, sortmode mode = UNDEFINED) { octave_value_list retval; @@ -237,7 +237,7 @@ template <class T> static octave_value -mx_sort_sparse (Sparse<T>& m, int dim, sortmode mode = UNDEFINED) +mx_sort_sparse (Sparse<T> &m, int dim, sortmode mode = UNDEFINED) { octave_value retval; @@ -302,7 +302,7 @@ template <class T> static octave_value_list -mx_sort_sparse_indexed (Sparse<T>& m, int dim, sortmode mode = UNDEFINED) +mx_sort_sparse_indexed (Sparse<T> &m, int dim, sortmode mode = UNDEFINED) { octave_value_list retval; @@ -442,28 +442,32 @@ template <> bool -ascending_compare (uint64_t a, uint64_t b) +ascending_compare (uint64_t a, + uint64_t b) { return (a < b); } template <> bool -ascending_compare (const vec_index<uint64_t> *a, const vec_index<uint64_t> *b) +ascending_compare (vec_index<uint64_t> *a, + vec_index<uint64_t> *b) { return (a->vec < b->vec); } template <> bool -descending_compare (uint64_t a, uint64_t b) +descending_compare (uint64_t a, + uint64_t b) { return (a > b); } template <> bool -descending_compare (const vec_index<uint64_t> *a, const vec_index<uint64_t> *b) +descending_compare (vec_index<uint64_t> *a, + vec_index<uint64_t> *b) { return (a->vec > b->vec); } @@ -474,7 +478,7 @@ template <> octave_value -mx_sort (ArrayN<double>& m, int dim, sortmode mode) +mx_sort (ArrayN<double> &m, int dim, sortmode mode) { octave_value retval; @@ -616,7 +620,7 @@ // Should other overloaded functions have their static keywords removed? template <> octave_value_list -mx_sort_indexed (ArrayN<double>& m, int dim, sortmode mode) +mx_sort_indexed (ArrayN<double> &m, int dim, sortmode mode) { octave_value_list retval; @@ -772,19 +776,19 @@ #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) static octave_value_list -mx_sort (ArrayN<double>& m, int dim, sortmode mode); +mx_sort (ArrayN<double> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<double>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<double> &m, int dim, sortmode mode); #endif #endif #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) static octave_value_list -mx_sort_sparse (Sparse<double>& m, int dim, sortmode mode); +mx_sort_sparse (Sparse<double> &m, int dim, sortmode mode); static octave_value_list -mx_sort_sparse_indexed (Sparse<double>& m, int dim, sortmode mode); +mx_sort_sparse_indexed (Sparse<double> &m, int dim, sortmode mode); #endif // std::abs(Inf) returns NaN!! @@ -796,37 +800,37 @@ template <> bool -ascending_compare (const Complex& a, const Complex& b) +ascending_compare (Complex a, Complex b) { - return (xisnan (b) || (xabs (a) < xabs (b)) - || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); + return (xisnan (b) || (xabs (a) < xabs (b)) || ((xabs (a) == xabs (b)) + && (arg (a) < arg (b)))); } -static inline bool -operator < (const Complex& a, const Complex& b) +bool +operator < (const Complex a, const Complex b) { - return (xisnan (b) || (xabs (a) < xabs (b)) - || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); + return (xisnan (b) || (xabs (a) < xabs (b)) || ((xabs (a) == xabs (b)) + && (arg (a) < arg (b)))); } template <> bool -descending_compare (const Complex& a, const Complex& b) +descending_compare (Complex a, Complex b) { - return (xisnan (a) || (xabs (a) > xabs (b)) - || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); + return (xisnan (a) || (xabs (a) > xabs (b)) || ((xabs (a) == xabs (b)) + && (arg (a) > arg (b)))); } bool -operator > (const Complex& a, const Complex& b) +operator > (const Complex a, const Complex b) { - return (xisnan (a) || (xabs (a) > xabs (b)) - || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); + return (xisnan (a) || (xabs (a) > xabs (b)) || ((xabs (a) == xabs (b)) + && (arg (a) > arg (b)))); } template <> bool -ascending_compare (const vec_index<Complex> *a, const vec_index<Complex> *b) +ascending_compare (vec_index<Complex> *a, vec_index<Complex> *b) { return (xisnan (b->vec) || (xabs (a->vec) < xabs (b->vec)) @@ -836,7 +840,7 @@ template <> bool -descending_compare (const vec_index<Complex> *a, const vec_index<Complex> *b) +descending_compare (vec_index<Complex> *a, vec_index<Complex> *b) { return (xisnan (a->vec) || (xabs (a->vec) > xabs (b->vec)) @@ -850,16 +854,16 @@ #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) static octave_value_list -mx_sort (ArrayN<Complex>& m, int dim, sortmode mode); +mx_sort (ArrayN<Complex> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<Complex>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<Complex> &m, int dim, sortmode mode); static octave_value_list -mx_sort_sparse (Sparse<Complex>& m, int dim, sortmode mode); +mx_sort_sparse (Sparse<Complex> &m, int dim, sortmode mode); static octave_value_list -mx_sort_sparse_indexed (Sparse<Complex>& m, int dim, sortmode mode); +mx_sort_sparse_indexed (Sparse<Complex> &m, int dim, sortmode mode); #endif template class octave_sort<char>; @@ -880,10 +884,10 @@ descending_compare (vec_index<char> *a, vec_index<char> *b); static octave_value_list -mx_sort (ArrayN<char>& m, int dim, sortmode mode); +mx_sort (ArrayN<char> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<char>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<char> &m, int dim, sortmode mode); #endif template class octave_sort<octave_int8>; @@ -904,10 +908,10 @@ descending_compare (vec_index<octave_int8> *a, vec_index<octave_int8> *b); static octave_value_list -mx_sort (ArrayN<octave_int8>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_int8> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_int8>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_int8> &m, int dim, sortmode mode); #endif template class octave_sort<octave_uint8>; @@ -928,10 +932,10 @@ descending_compare (vec_index<octave_uint8> *a, vec_index<octave_uint8> *b); static octave_value_list -mx_sort (ArrayN<octave_uint8>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_uint8> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_uint8>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_uint8> &m, int dim, sortmode mode); #endif template class octave_sort<octave_int16>; @@ -952,10 +956,10 @@ descending_compare (vec_index<octave_int16> *a, vec_index<octave_int16> *b); static octave_value_list -mx_sort (ArrayN<octave_int16>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_int16> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_int16>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_int16> &m, int dim, sortmode mode); #endif template class octave_sort<octave_uint16>; @@ -976,10 +980,10 @@ descending_compare (vec_index<octave_uint16> *a, vec_index<octave_uint16> *b); static octave_value_list -mx_sort (ArrayN<octave_uint16>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_uint16> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_uint16>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_uint16> &m, int dim, sortmode mode); #endif template class octave_sort<octave_int32>; @@ -1000,10 +1004,10 @@ descending_compare (vec_index<octave_int32> *a, vec_index<octave_int32> *b); static octave_value_list -mx_sort (ArrayN<octave_int32>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_int32> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_int32>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_int32> &m, int dim, sortmode mode); #endif template class octave_sort<octave_uint32>; @@ -1024,10 +1028,10 @@ descending_compare (vec_index<octave_uint32> *a, vec_index<octave_uint32> *b); static octave_value_list -mx_sort (ArrayN<octave_uint32>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_uint32> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_uint32>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_uint32> &m, int dim, sortmode mode); #endif template class octave_sort<octave_int64>; @@ -1048,10 +1052,10 @@ descending_compare (vec_index<octave_int64> *a, vec_index<octave_int64> *b); static octave_value_list -mx_sort (ArrayN<octave_int64>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_int64> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_int64>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_int64> &m, int dim, sortmode mode); #endif template class octave_sort<octave_uint64>; @@ -1072,10 +1076,10 @@ descending_compare (vec_index<octave_uint64> *a, vec_index<octave_uint64> *b); static octave_value_list -mx_sort (ArrayN<octave_uint64>& m, int dim, sortmode mode); +mx_sort (ArrayN<octave_uint64> &m, int dim, sortmode mode); static octave_value_list -mx_sort_indexed (ArrayN<octave_uint64>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_uint64> &m, int dim, sortmode mode); #endif template <> @@ -1097,7 +1101,7 @@ #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) static octave_value_list -mx_sort_indexed (ArrayN<octave_value>& m, int dim, sortmode mode); +mx_sort_indexed (ArrayN<octave_value> &m, int dim, sortmode mode); #endif DEFUN_DLD (sort, args, nargout,