Mercurial > hg > octave-lyh
annotate liboctave/Array-C.cc @ 8700:314be237cd5b
sorting optimizations
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 09 Feb 2009 13:05:35 +0100 |
parents | 7cbe01c21986 |
children | e9cb742df9eb |
rev | line source |
---|---|
757 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001, 2003, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
757 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
757 | 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/>. | |
757 | 21 |
22 */ | |
23 | |
2006 | 24 #ifdef HAVE_CONFIG_H |
25 #include <config.h> | |
26 #endif | |
27 | |
757 | 28 // Instantiate Arrays of Complex values. |
29 | |
1989 | 30 #include "oct-cmplx.h" |
31 | |
757 | 32 #include "Array.h" |
33 #include "Array.cc" | |
8700 | 34 #include "oct-sort.cc" |
7433 | 35 |
36 static double | |
37 xabs (const Complex& x) | |
38 { | |
39 return (xisinf (x.real ()) || xisinf (x.imag ())) ? octave_Inf : abs (x); | |
40 } | |
41 | |
42 template <> | |
43 bool | |
8700 | 44 octave_sort<Complex>::ascending_compare (Complex a, Complex b) |
7433 | 45 { |
46 return (xisnan (b) || (xabs (a) < xabs (b)) | |
47 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); | |
48 } | |
49 | |
50 template <> | |
51 bool | |
8700 | 52 octave_sort<Complex>::descending_compare (Complex a, Complex b) |
7433 | 53 { |
54 return (xisnan (a) || (xabs (a) > xabs (b)) | |
55 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); | |
56 } | |
57 | |
58 INSTANTIATE_ARRAY_SORT (Complex); | |
757 | 59 |
6708 | 60 INSTANTIATE_ARRAY_AND_ASSIGN (Complex, OCTAVE_API); |
757 | 61 |
8290
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
62 INSTANTIATE_ARRAY_ASSIGN (Complex, double, OCTAVE_API) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
63 INSTANTIATE_ARRAY_ASSIGN (Complex, int, OCTAVE_API) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
64 INSTANTIATE_ARRAY_ASSIGN (Complex, short, OCTAVE_API) |
7cbe01c21986
improve dense array indexing
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
65 INSTANTIATE_ARRAY_ASSIGN (Complex, char, OCTAVE_API) |
3836 | 66 |
1989 | 67 #include "Array2.h" |
68 | |
6108 | 69 template class OCTAVE_API Array2<Complex>; |
1989 | 70 |
4513 | 71 #include "ArrayN.h" |
72 #include "ArrayN.cc" | |
73 | |
6108 | 74 template class OCTAVE_API ArrayN<Complex>; |
4513 | 75 |
6108 | 76 template OCTAVE_API std::ostream& operator << (std::ostream&, const ArrayN<Complex>&); |
4513 | 77 |
1989 | 78 #include "DiagArray2.h" |
79 #include "DiagArray2.cc" | |
80 | |
6108 | 81 template class OCTAVE_API DiagArray2<Complex>; |
1989 | 82 |
757 | 83 /* |
84 ;;; Local Variables: *** | |
85 ;;; mode: C++ *** | |
86 ;;; End: *** | |
87 */ |