Mercurial > hg > octave-nkf
annotate liboctave/sparse-sort.cc @ 12283:0664a7ddd944 release-3-4-x
README.MacOS: Spelling corrections.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Fri, 28 Jan 2011 22:27:17 -0500 |
parents | 12df7854fa7c |
children | 72c96de7a403 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2004-2011 David Bateman |
4 Copyright (C) 1998-2004 Andy Adler | |
7016 | 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> | |
7048 | 29 #include <cstring> |
5164 | 30 |
31 #include "oct-sort.cc" | |
32 #include "quit.h" | |
33 | |
34 #include "sparse-sort.h" | |
35 | |
36 // A simple class and instantiation of the octave merge sort class | |
37 // to sort sparse data before matrix creation. This is significantly | |
38 // faster than using octave_qsort. | |
39 | |
40 bool | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 octave_sparse_sidxl_comp (octave_sparse_sort_idxl* i, |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
42 octave_sparse_sort_idxl* j) |
5164 | 43 { |
5603 | 44 octave_idx_type tmp = i->c - j->c; |
5164 | 45 if (tmp < 0) |
46 return true; | |
47 else if (tmp > 0) | |
48 return false; | |
49 return (i->r < j->r); | |
50 } | |
51 | |
8752
06b9903a029b
fix & clean up complex & sparse sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
52 template class octave_sort<octave_sparse_sort_idxl *>; |
06b9903a029b
fix & clean up complex & sparse sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
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, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 octave_idx_vector_sort* j) |
5603 | 59 { |
60 return (i->i < j->i); | |
61 } | |
62 | |
8752
06b9903a029b
fix & clean up complex & sparse sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
63 template class octave_sort<octave_idx_vector_sort *>; |