sparse-sort.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 David Bateman
00004 Copyright (C) 1998-2004 Andy Adler
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #include <cassert>
00029 #include <cstring>
00030 
00031 #include "oct-sort.cc"
00032 #include "quit.h"
00033 
00034 #include "sparse-sort.h"
00035 
00036 // A simple class and instantiation of the octave merge sort class
00037 // to sort sparse data before matrix creation. This is significantly
00038 // faster than using octave_qsort.
00039 
00040 bool
00041 octave_sparse_sidxl_comp (octave_sparse_sort_idxl* i,
00042                           octave_sparse_sort_idxl* j)
00043 {
00044   octave_idx_type tmp = i->c - j->c;
00045   if (tmp < 0)
00046     return true;
00047   else if (tmp > 0)
00048     return false;
00049   return  (i->r < j->r);
00050 }
00051 
00052 template class octave_sort<octave_sparse_sort_idxl *>;
00053 
00054 // Need to know the original order of the sorted indexes in
00055 // sparse assignments, and this class does that
00056 bool
00057 octave_idx_vector_comp (octave_idx_vector_sort* i,
00058                         octave_idx_vector_sort* j)
00059 {
00060   return (i->i < j->i);
00061 }
00062 
00063 template class octave_sort<octave_idx_vector_sort *>;
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines