Mercurial > octave-nkf
comparison src/DLD-FUNCTIONS/sort.cc @ 7064:faff87ff9d5a
[project @ 2007-10-24 21:09:43 by dbateman]
author | dbateman |
---|---|
date | Wed, 24 Oct 2007 21:09:44 +0000 |
parents | a1dbe9d80eee |
children | 97db94ae2cf0 |
comparison
equal
deleted
inserted
replaced
7063:58102cc15ddf | 7064:faff87ff9d5a |
---|---|
886 static octave_value_list | 886 static octave_value_list |
887 mx_sort (ArrayN<char> &m, int dim, sortmode mode); | 887 mx_sort (ArrayN<char> &m, int dim, sortmode mode); |
888 | 888 |
889 static octave_value_list | 889 static octave_value_list |
890 mx_sort_indexed (ArrayN<char> &m, int dim, sortmode mode); | 890 mx_sort_indexed (ArrayN<char> &m, int dim, sortmode mode); |
891 #endif | |
892 | |
893 template class octave_sort<octave_int8>; | |
894 template class vec_index<octave_int8>; | |
895 template class octave_sort<vec_index<octave_int8> *>; | |
896 | |
897 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
898 bool | |
899 ascending_compare (octave_int8 a, octave_int8 b); | |
900 | |
901 bool | |
902 ascending_compare (vec_index<octave_int8> *a, vec_index<octave_int8> *b); | |
903 | |
904 bool | |
905 descending_compare (octave_int8 a, octave_int8 b); | |
906 | |
907 bool | |
908 descending_compare (vec_index<octave_int8> *a, vec_index<octave_int8> *b); | |
909 | |
910 static octave_value_list | |
911 mx_sort (ArrayN<octave_int8> &m, int dim, sortmode mode); | |
912 | |
913 static octave_value_list | |
914 mx_sort_indexed (ArrayN<octave_int8> &m, int dim, sortmode mode); | |
915 #endif | |
916 | |
917 template class octave_sort<octave_uint8>; | |
918 template class vec_index<octave_uint8>; | |
919 template class octave_sort<vec_index<octave_uint8> *>; | |
920 | |
921 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
922 bool | |
923 ascending_compare (octave_uint8 a, octave_uint8 b); | |
924 | |
925 bool | |
926 ascending_compare (vec_index<octave_uint8> *a, vec_index<octave_uint8> *b); | |
927 | |
928 bool | |
929 descending_compare (octave_uint8 a, octave_uint8 b); | |
930 | |
931 bool | |
932 descending_compare (vec_index<octave_uint8> *a, vec_index<octave_uint8> *b); | |
933 | |
934 static octave_value_list | |
935 mx_sort (ArrayN<octave_uint8> &m, int dim, sortmode mode); | |
936 | |
937 static octave_value_list | |
938 mx_sort_indexed (ArrayN<octave_uint8> &m, int dim, sortmode mode); | |
939 #endif | |
940 | |
941 template class octave_sort<octave_int16>; | |
942 template class vec_index<octave_int16>; | |
943 template class octave_sort<vec_index<octave_int16> *>; | |
944 | |
945 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
946 bool | |
947 ascending_compare (octave_int16 a, octave_int16 b); | |
948 | |
949 bool | |
950 ascending_compare (vec_index<octave_int16> *a, vec_index<octave_int16> *b); | |
951 | |
952 bool | |
953 descending_compare (octave_int16 a, octave_int16 b); | |
954 | |
955 bool | |
956 descending_compare (vec_index<octave_int16> *a, vec_index<octave_int16> *b); | |
957 | |
958 static octave_value_list | |
959 mx_sort (ArrayN<octave_int16> &m, int dim, sortmode mode); | |
960 | |
961 static octave_value_list | |
962 mx_sort_indexed (ArrayN<octave_int16> &m, int dim, sortmode mode); | |
963 #endif | |
964 | |
965 template class octave_sort<octave_uint16>; | |
966 template class vec_index<octave_uint16>; | |
967 template class octave_sort<vec_index<octave_uint16> *>; | |
968 | |
969 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
970 bool | |
971 ascending_compare (octave_uint16 a, octave_uint16 b); | |
972 | |
973 bool | |
974 ascending_compare (vec_index<octave_uint16> *a, vec_index<octave_uint16> *b); | |
975 | |
976 bool | |
977 descending_compare (octave_uint16 a, octave_uint16 b); | |
978 | |
979 bool | |
980 descending_compare (vec_index<octave_uint16> *a, vec_index<octave_uint16> *b); | |
981 | |
982 static octave_value_list | |
983 mx_sort (ArrayN<octave_uint16> &m, int dim, sortmode mode); | |
984 | |
985 static octave_value_list | |
986 mx_sort_indexed (ArrayN<octave_uint16> &m, int dim, sortmode mode); | |
987 #endif | |
988 | |
989 template class octave_sort<octave_int32>; | |
990 template class vec_index<octave_int32>; | |
991 template class octave_sort<vec_index<octave_int32> *>; | |
992 | |
993 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
994 bool | |
995 ascending_compare (octave_int32 a, octave_int32 b); | |
996 | |
997 bool | |
998 ascending_compare (vec_index<octave_int32> *a, vec_index<octave_int32> *b); | |
999 | |
1000 bool | |
1001 descending_compare (octave_int32 a, octave_int32 b); | |
1002 | |
1003 bool | |
1004 descending_compare (vec_index<octave_int32> *a, vec_index<octave_int32> *b); | |
1005 | |
1006 static octave_value_list | |
1007 mx_sort (ArrayN<octave_int32> &m, int dim, sortmode mode); | |
1008 | |
1009 static octave_value_list | |
1010 mx_sort_indexed (ArrayN<octave_int32> &m, int dim, sortmode mode); | |
1011 #endif | |
1012 | |
1013 template class octave_sort<octave_uint32>; | |
1014 template class vec_index<octave_uint32>; | |
1015 template class octave_sort<vec_index<octave_uint32> *>; | |
1016 | |
1017 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
1018 bool | |
1019 ascending_compare (octave_uint32 a, octave_uint32 b); | |
1020 | |
1021 bool | |
1022 ascending_compare (vec_index<octave_uint32> *a, vec_index<octave_uint32> *b); | |
1023 | |
1024 bool | |
1025 descending_compare (octave_uint32 a, octave_uint32 b); | |
1026 | |
1027 bool | |
1028 descending_compare (vec_index<octave_uint32> *a, vec_index<octave_uint32> *b); | |
1029 | |
1030 static octave_value_list | |
1031 mx_sort (ArrayN<octave_uint32> &m, int dim, sortmode mode); | |
1032 | |
1033 static octave_value_list | |
1034 mx_sort_indexed (ArrayN<octave_uint32> &m, int dim, sortmode mode); | |
1035 #endif | |
1036 | |
1037 template class octave_sort<octave_int64>; | |
1038 template class vec_index<octave_int64>; | |
1039 template class octave_sort<vec_index<octave_int64> *>; | |
1040 | |
1041 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
1042 bool | |
1043 ascending_compare (octave_int64 a, octave_int64 b); | |
1044 | |
1045 bool | |
1046 ascending_compare (vec_index<octave_int64> *a, vec_index<octave_int64> *b); | |
1047 | |
1048 bool | |
1049 descending_compare (octave_int64 a, octave_int64 b); | |
1050 | |
1051 bool | |
1052 descending_compare (vec_index<octave_int64> *a, vec_index<octave_int64> *b); | |
1053 | |
1054 static octave_value_list | |
1055 mx_sort (ArrayN<octave_int64> &m, int dim, sortmode mode); | |
1056 | |
1057 static octave_value_list | |
1058 mx_sort_indexed (ArrayN<octave_int64> &m, int dim, sortmode mode); | |
1059 #endif | |
1060 | |
1061 template class octave_sort<octave_uint64>; | |
1062 template class vec_index<octave_uint64>; | |
1063 template class octave_sort<vec_index<octave_uint64> *>; | |
1064 | |
1065 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL) | |
1066 bool | |
1067 ascending_compare (octave_uint64 a, octave_uint64 b); | |
1068 | |
1069 bool | |
1070 ascending_compare (vec_index<octave_uint64> *a, vec_index<octave_uint64> *b); | |
1071 | |
1072 bool | |
1073 descending_compare (octave_uint64 a, octave_uint64 b); | |
1074 | |
1075 bool | |
1076 descending_compare (vec_index<octave_uint64> *a, vec_index<octave_uint64> *b); | |
1077 | |
1078 static octave_value_list | |
1079 mx_sort (ArrayN<octave_uint64> &m, int dim, sortmode mode); | |
1080 | |
1081 static octave_value_list | |
1082 mx_sort_indexed (ArrayN<octave_uint64> &m, int dim, sortmode mode); | |
891 #endif | 1083 #endif |
892 | 1084 |
893 template <> | 1085 template <> |
894 bool | 1086 bool |
895 ascending_compare (vec_index<octave_value> *a, vec_index<octave_value> *b) | 1087 ascending_compare (vec_index<octave_value> *a, vec_index<octave_value> *b) |
1046 error ("sort: dim must be a valid dimension"); | 1238 error ("sort: dim must be a valid dimension"); |
1047 return retval; | 1239 return retval; |
1048 } | 1240 } |
1049 } | 1241 } |
1050 | 1242 |
1243 // FIXME Perhaps sort should be made a method of the octave_value classes | |
1244 // and then the mess of if statements both might be replaced with | |
1245 // retval = arg.sort (dim, smode, return_idx); | |
1246 | |
1051 if (arg.is_real_type ()) | 1247 if (arg.is_real_type ()) |
1052 { | 1248 { |
1053 if (arg.is_sparse_type ()) | 1249 if (arg.is_sparse_type ()) |
1054 { | 1250 { |
1055 SparseMatrix m = arg.sparse_matrix_value (); | 1251 SparseMatrix m = arg.sparse_matrix_value (); |
1058 { | 1254 { |
1059 if (return_idx) | 1255 if (return_idx) |
1060 retval = mx_sort_sparse_indexed (m, dim, smode); | 1256 retval = mx_sort_sparse_indexed (m, dim, smode); |
1061 else | 1257 else |
1062 retval = mx_sort_sparse (m, dim, smode); | 1258 retval = mx_sort_sparse (m, dim, smode); |
1259 } | |
1260 } | |
1261 else if (arg.is_int8_type ()) | |
1262 { | |
1263 int8NDArray m = arg.int8_array_value (); | |
1264 if (! error_state) | |
1265 { | |
1266 if (return_idx) | |
1267 retval = mx_sort_indexed (m, dim, smode); | |
1268 else | |
1269 retval = mx_sort (m, dim, smode); | |
1270 } | |
1271 } | |
1272 else if (arg.is_uint8_type ()) | |
1273 { | |
1274 uint8NDArray m = arg.uint8_array_value (); | |
1275 if (! error_state) | |
1276 { | |
1277 if (return_idx) | |
1278 retval = mx_sort_indexed (m, dim, smode); | |
1279 else | |
1280 retval = mx_sort (m, dim, smode); | |
1281 } | |
1282 } | |
1283 else if (arg.is_int16_type ()) | |
1284 { | |
1285 int16NDArray m = arg.int16_array_value (); | |
1286 if (! error_state) | |
1287 { | |
1288 if (return_idx) | |
1289 retval = mx_sort_indexed (m, dim, smode); | |
1290 else | |
1291 retval = mx_sort (m, dim, smode); | |
1292 } | |
1293 } | |
1294 else if (arg.is_uint16_type ()) | |
1295 { | |
1296 uint16NDArray m = arg.uint16_array_value (); | |
1297 if (! error_state) | |
1298 { | |
1299 if (return_idx) | |
1300 retval = mx_sort_indexed (m, dim, smode); | |
1301 else | |
1302 retval = mx_sort (m, dim, smode); | |
1303 } | |
1304 } | |
1305 else if (arg.is_int32_type ()) | |
1306 { | |
1307 int32NDArray m = arg.int32_array_value (); | |
1308 if (! error_state) | |
1309 { | |
1310 if (return_idx) | |
1311 retval = mx_sort_indexed (m, dim, smode); | |
1312 else | |
1313 retval = mx_sort (m, dim, smode); | |
1314 } | |
1315 } | |
1316 else if (arg.is_uint32_type ()) | |
1317 { | |
1318 uint32NDArray m = arg.uint32_array_value (); | |
1319 if (! error_state) | |
1320 { | |
1321 if (return_idx) | |
1322 retval = mx_sort_indexed (m, dim, smode); | |
1323 else | |
1324 retval = mx_sort (m, dim, smode); | |
1325 } | |
1326 } | |
1327 else if (arg.is_int64_type ()) | |
1328 { | |
1329 int64NDArray m = arg.int64_array_value (); | |
1330 if (! error_state) | |
1331 { | |
1332 if (return_idx) | |
1333 retval = mx_sort_indexed (m, dim, smode); | |
1334 else | |
1335 retval = mx_sort (m, dim, smode); | |
1336 } | |
1337 } | |
1338 else if (arg.is_uint64_type ()) | |
1339 { | |
1340 uint64NDArray m = arg.uint64_array_value (); | |
1341 if (! error_state) | |
1342 { | |
1343 if (return_idx) | |
1344 retval = mx_sort_indexed (m, dim, smode); | |
1345 else | |
1346 retval = mx_sort (m, dim, smode); | |
1063 } | 1347 } |
1064 } | 1348 } |
1065 else | 1349 else |
1066 { | 1350 { |
1067 NDArray m = arg.array_value (); | 1351 NDArray m = arg.array_value (); |