Mercurial > hg > octave-nkf
annotate liboctave/Array-C.cc @ 12107:1fc9fd052f0c release-3-2-x
fix typo in expm
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Wed, 25 Nov 2009 12:05:03 +0100 |
parents | a407e894ec74 |
children | b4fdfee405b5 |
rev | line source |
---|---|
757 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 1998, 2001, 2003, 2004, 2005, |
8920 | 4 2006, 2007, 2008, 2009 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" |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
31 #include "lo-mappers.h" |
1989 | 32 |
757 | 33 #include "Array.h" |
34 #include "Array.cc" | |
8700 | 35 #include "oct-sort.cc" |
7433 | 36 |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
37 template <> |
8725 | 38 inline bool |
39 sort_isnan<Complex> (const Complex& x) | |
7433 | 40 { |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
41 return xisnan (x); |
7433 | 42 } |
43 | |
8725 | 44 static bool |
45 nan_ascending_compare (const Complex& x, const Complex& y) | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
46 { |
8725 | 47 return (xisnan (y) |
48 ? ! xisnan (x) | |
49 : ((std::abs (x) < std::abs (x)) | |
50 || ((std::abs (x) == std::abs (x)) && (arg (x) < arg (x))))); | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
51 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
52 |
8725 | 53 static bool |
54 nan_descending_compare (const Complex& x, const Complex& y) | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
55 { |
8725 | 56 return (xisnan (x) |
57 ? ! xisnan (y) | |
58 : ((std::abs (x) > std::abs (x)) | |
59 || ((std::abs (x) == std::abs (x)) && (arg (x) > arg (x))))); | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
60 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
61 |
8725 | 62 Array<Complex>::compare_fcn_type |
63 sortrows_comparator (sortmode mode, const Array<Complex>& a , bool allow_chk) | |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
64 { |
8725 | 65 Array<Complex>::compare_fcn_type result = 0; |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
66 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
67 if (allow_chk) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
68 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
69 octave_idx_type k = 0; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
70 for (; k < a.numel () && ! xisnan (a(k)); k++) ; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
71 if (k == a.numel ()) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
72 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
73 if (mode == ASCENDING) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
74 result = octave_sort<Complex>::ascending_compare; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
75 else if (mode == DESCENDING) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
76 result = octave_sort<Complex>::descending_compare; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
77 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
78 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
79 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
80 if (! result) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
81 { |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
82 if (mode == ASCENDING) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
83 result = nan_ascending_compare; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
84 else if (mode == DESCENDING) |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
85 result = nan_descending_compare; |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
86 } |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
87 |
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
88 return result; |
7433 | 89 } |
90 | |
91 INSTANTIATE_ARRAY_SORT (Complex); | |
757 | 92 |
8721
e9cb742df9eb
imported patch sort3.diff
Jaroslav Hajek <highegg@gmail.com>
parents:
8700
diff
changeset
|
93 INSTANTIATE_ARRAY (Complex, OCTAVE_API); |
3836 | 94 |
1989 | 95 #include "Array2.h" |
96 | |
6108 | 97 template class OCTAVE_API Array2<Complex>; |
1989 | 98 |
4513 | 99 #include "ArrayN.h" |
100 #include "ArrayN.cc" | |
101 | |
6108 | 102 template class OCTAVE_API ArrayN<Complex>; |
4513 | 103 |
6108 | 104 template OCTAVE_API std::ostream& operator << (std::ostream&, const ArrayN<Complex>&); |
4513 | 105 |
1989 | 106 #include "DiagArray2.h" |
107 #include "DiagArray2.cc" | |
108 | |
9287
a407e894ec74
conditionally enable MSVC-specific DiagArray2<T>::Proxy instantiations
Jaroslav Hajek <highegg@gmail.com>
parents:
9237
diff
changeset
|
109 #ifdef _MSC_VER |
9237
3c1762c7e787
Add missing xxx_API decoration and remove misplaced ones
Michael Goffioul <michael.goffioul@gmail.com>
parents:
8920
diff
changeset
|
110 template class OCTAVE_API DiagArray2<Complex>::Proxy; |
9287
a407e894ec74
conditionally enable MSVC-specific DiagArray2<T>::Proxy instantiations
Jaroslav Hajek <highegg@gmail.com>
parents:
9237
diff
changeset
|
111 #endif |
6108 | 112 template class OCTAVE_API DiagArray2<Complex>; |
1989 | 113 |
757 | 114 /* |
115 ;;; Local Variables: *** | |
116 ;;; mode: C++ *** | |
117 ;;; End: *** | |
118 */ |