Mercurial > octave-nkf
annotate liboctave/Array-C.cc @ 7961:a5d1e27ee1f4 ss-3-1-51
3.1.51 snapshot
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Jul 2008 11:40:48 -0400 |
parents | ff9c2bb7abc7 |
children | 7cbe01c21986 |
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" | |
7433 | 34 |
35 static double | |
36 xabs (const Complex& x) | |
37 { | |
38 return (xisinf (x.real ()) || xisinf (x.imag ())) ? octave_Inf : abs (x); | |
39 } | |
40 | |
41 static bool | |
42 operator < (const Complex& a, const Complex& b) | |
43 { | |
44 return (xisnan (b) || (xabs (a) < xabs (b)) | |
45 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); | |
46 } | |
47 | |
48 static bool | |
49 operator > (const Complex& a, const Complex& b) | |
50 { | |
51 return (xisnan (a) || (xabs (a) > xabs (b)) | |
52 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); | |
53 } | |
54 | |
7549
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
55 // This file must be included after the < and > operators are |
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
56 // defined to avoid errors with the Intel C++ compiler. |
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
57 #include "oct-sort.cc" |
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7433
diff
changeset
|
58 |
7433 | 59 template <> |
60 bool | |
61 ascending_compare (Complex a, Complex b) | |
62 { | |
63 return (xisnan (b) || (xabs (a) < xabs (b)) | |
64 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); | |
65 } | |
66 | |
67 template <> | |
68 bool | |
69 ascending_compare (vec_index<Complex> *a, vec_index<Complex> *b) | |
70 { | |
71 return (xisnan (b->vec) | |
72 || (xabs (a->vec) < xabs (b->vec)) | |
73 || ((xabs (a->vec) == xabs (b->vec)) | |
74 && (arg (a->vec) < arg (b->vec)))); | |
75 } | |
76 | |
77 template <> | |
78 bool | |
79 descending_compare (Complex a, Complex b) | |
80 { | |
81 return (xisnan (a) || (xabs (a) > xabs (b)) | |
82 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); | |
83 } | |
84 | |
85 template <> | |
86 bool | |
87 descending_compare (vec_index<Complex> *a, vec_index<Complex> *b) | |
88 { | |
89 return (xisnan (a->vec) | |
90 || (xabs (a->vec) > xabs (b->vec)) | |
91 || ((xabs (a->vec) == xabs (b->vec)) | |
92 && (arg (a->vec) > arg (b->vec)))); | |
93 } | |
94 | |
95 INSTANTIATE_ARRAY_SORT (Complex); | |
757 | 96 |
6708 | 97 INSTANTIATE_ARRAY_AND_ASSIGN (Complex, OCTAVE_API); |
757 | 98 |
6708 | 99 INSTANTIATE_ARRAY_ASSIGN (Complex, double, OCTAVE_API); |
100 INSTANTIATE_ARRAY_ASSIGN (Complex, int, OCTAVE_API); | |
101 INSTANTIATE_ARRAY_ASSIGN (Complex, short, OCTAVE_API); | |
102 INSTANTIATE_ARRAY_ASSIGN (Complex, char, OCTAVE_API); | |
3836 | 103 |
1989 | 104 #include "Array2.h" |
105 | |
6108 | 106 template class OCTAVE_API Array2<Complex>; |
1989 | 107 |
4513 | 108 #include "ArrayN.h" |
109 #include "ArrayN.cc" | |
110 | |
6108 | 111 template class OCTAVE_API ArrayN<Complex>; |
4513 | 112 |
6108 | 113 template OCTAVE_API std::ostream& operator << (std::ostream&, const ArrayN<Complex>&); |
4513 | 114 |
1989 | 115 #include "DiagArray2.h" |
116 #include "DiagArray2.cc" | |
117 | |
6108 | 118 template class OCTAVE_API DiagArray2<Complex>; |
1989 | 119 |
757 | 120 /* |
121 ;;; Local Variables: *** | |
122 ;;; mode: C++ *** | |
123 ;;; End: *** | |
124 */ |