GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
sparse-sort.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2015 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
5 
6 This file is part of Octave.
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
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
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
19 along with Octave; see the file COPYING. If not, see
20 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <cassert>
29 #include <cstring>
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
43 {
44  octave_idx_type tmp = i->c - j->c;
45  if (tmp < 0)
46  return true;
47  else if (tmp > 0)
48  return false;
49  return (i->r < j->r);
50 }
51 
53 
54 // Need to know the original order of the sorted indexes in
55 // sparse assignments, and this class does that
56 bool
59 {
60  return (i->i < j->i);
61 }
62 
octave_idx_type r
Definition: sparse-sort.h:33
octave_idx_type c
Definition: sparse-sort.h:34
bool octave_sparse_sidxl_comp(octave_sparse_sort_idxl *i, octave_sparse_sort_idxl *j)
Definition: sparse-sort.cc:41
bool octave_idx_vector_comp(octave_idx_vector_sort *i, octave_idx_vector_sort *j)
Definition: sparse-sort.cc:57
octave_idx_type i
Definition: sparse-sort.h:45