5164
|
1 /* |
|
2 |
7017
|
3 Copyright (C) 2004, 2005, 2006, 2007 David Bateman |
7016
|
4 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Andy Adler |
|
5 |
|
6 This file is part of Octave. |
5164
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
7016
|
10 Free Software Foundation; either version 3 of the License, or (at your |
|
11 option) any later version. |
5164
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
7016
|
19 along with Octave; see the file COPYING. If not, see |
|
20 <http://www.gnu.org/licenses/>. |
5164
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <cassert> |
|
29 |
|
30 #include "oct-sort.cc" |
|
31 #include "quit.h" |
|
32 |
|
33 #include "sparse-sort.h" |
|
34 |
|
35 // A simple class and instantiation of the octave merge sort class |
|
36 // to sort sparse data before matrix creation. This is significantly |
|
37 // faster than using octave_qsort. |
|
38 |
|
39 bool |
|
40 octave_sparse_sidxl_comp (octave_sparse_sort_idxl* i, |
|
41 octave_sparse_sort_idxl* j) |
|
42 { |
5603
|
43 octave_idx_type tmp = i->c - j->c; |
5164
|
44 if (tmp < 0) |
|
45 return true; |
|
46 else if (tmp > 0) |
|
47 return false; |
|
48 return (i->r < j->r); |
|
49 } |
|
50 |
|
51 // Instantiate the sparse sorting class |
|
52 template class octave_sort<octave_sparse_sort_idxl *>; |
|
53 |
5603
|
54 // Need to know the original order of the sorted indexes in |
|
55 // sparse assignments, and this class does that |
|
56 bool |
|
57 octave_idx_vector_comp (octave_idx_vector_sort* i, |
|
58 octave_idx_vector_sort* j) |
|
59 { |
|
60 return (i->i < j->i); |
|
61 } |
|
62 |
|
63 // Instantiate the sparse index sorting class |
|
64 template class octave_sort<octave_idx_vector_sort *>; |
|
65 |
5587
|
66 // Instantiate the sorting class of octave_idx_type, need in MUL macro |
|
67 template class octave_sort<octave_idx_type>; |
|
68 |
5164
|
69 /* |
|
70 ;;; Local Variables: *** |
|
71 ;;; mode: C++ *** |
|
72 ;;; End: *** |
|
73 */ |