Mercurial > octave-nkf
annotate liboctave/Sparse-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 | 06b9903a029b |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
7017 | 3 Copyright (C) 2004, 2005, 2007 David Bateman |
7016 | 4 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Andy Adler |
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 // Instantiate Sparse matrix of complex values. | |
29 | |
30 #include "oct-cmplx.h" | |
7433 | 31 #include "lo-mappers.h" |
32 #include "lo-ieee.h" | |
5164 | 33 #include "Sparse.h" |
34 #include "Sparse.cc" | |
35 | |
7433 | 36 |
37 static double | |
38 xabs (const Complex& x) | |
39 { | |
40 return (xisinf (x.real ()) || xisinf (x.imag ())) ? octave_Inf : abs (x); | |
41 } | |
42 | |
43 static bool | |
44 operator < (const Complex& a, const Complex& b) | |
45 { | |
46 return (xisnan (b) || (xabs (a) < xabs (b)) | |
47 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); | |
48 } | |
49 | |
50 static bool | |
51 operator > (const Complex& a, const Complex& b) | |
52 { | |
53 return (xisnan (a) || (xabs (a) > xabs (b)) | |
54 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); | |
55 } | |
56 | |
7549
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
57 // 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:
7470
diff
changeset
|
58 // 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:
7470
diff
changeset
|
59 #include "oct-sort.cc" |
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
60 |
7433 | 61 template <> |
62 bool | |
63 sparse_ascending_compare (Complex a, Complex b) | |
64 { | |
65 return (xisnan (b) || (xabs (a) < xabs (b)) | |
66 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); | |
67 } | |
68 | |
69 template <> | |
70 bool | |
71 sparse_ascending_compare (vec_index<Complex> *a, vec_index<Complex> *b) | |
72 { | |
73 return (xisnan (b->vec) | |
74 || (xabs (a->vec) < xabs (b->vec)) | |
75 || ((xabs (a->vec) == xabs (b->vec)) | |
76 && (arg (a->vec) < arg (b->vec)))); | |
77 } | |
78 | |
79 template <> | |
80 bool | |
81 sparse_descending_compare (Complex a, Complex b) | |
82 { | |
83 return (xisnan (a) || (xabs (a) > xabs (b)) | |
84 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); | |
85 } | |
86 | |
87 template <> | |
88 bool | |
89 sparse_descending_compare (vec_index<Complex> *a, vec_index<Complex> *b) | |
90 { | |
91 return (xisnan (a->vec) | |
92 || (xabs (a->vec) > xabs (b->vec)) | |
93 || ((xabs (a->vec) == xabs (b->vec)) | |
94 && (arg (a->vec) > arg (b->vec)))); | |
95 } | |
96 | |
6708 | 97 INSTANTIATE_SPARSE_AND_ASSIGN (Complex, OCTAVE_API); |
5164 | 98 |
6708 | 99 INSTANTIATE_SPARSE_ASSIGN (Complex, double, OCTAVE_API); |
5164 | 100 |
101 #if 0 | |
102 template std::ostream& operator << (std::ostream&, const Sparse<Complex>&); | |
103 #endif | |
104 | |
105 /* | |
106 ;;; Local Variables: *** | |
107 ;;; mode: C++ *** | |
108 ;;; End: *** | |
109 */ |