Mercurial > octave
annotate liboctave/array/Sparse-C.cc @ 21721:bcc30b45a225
define octave_numeric_limits template methods for Inf and NaN
* lo-ieee.h (octave_numeric_limits::Inf, octave_numeric_limits::NaN):
New methods.
* Canvas.cc, data.cc, graphics.cc, graphics.in.h, oct-handle.h,
oct-stream.cc, quadcc.cc, sparse-xdiv.cc, str2double.cc, variables.h,
__glpk__.cc, __init_fltk__.cc, __voronoi__.cc, octave.cc, Matrix.cc,
CNDArray.cc, CSparse.cc, Sparse-C.cc, dDiagMatrix.cc, dMatrix.cc,
dSparse.cc, fCMatrix.cc, fCNDArray.cc, fDiagMatrix.cc, fMatrix.cc,
Faddeeva.cc, eigs-base.cc, lo-mappers.cc, lo-mappers.h, lo-specfun.cc,
oct-norm.cc, oct-rand.cc, oct-rand.h, oct-spparms.cc, randgamma.cc,
randpoisson.cc: Use them instead of octave_Inf, octave_Float_Inf,
octave_NaN, and octave_Float_NaN.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 May 2016 01:11:27 -0400 |
parents | 40de9f8f23a6 |
children | bae585228161 |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
3 Copyright (C) 2004-2015 David Bateman |
11523 | 4 Copyright (C) 1998-2004 Andy Adler |
7016 | 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 | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
25 # include "config.h" |
5164 | 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 { | |
21721
bcc30b45a225
define octave_numeric_limits template methods for Inf and NaN
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
40 return ((xisinf (x.real ()) || xisinf (x.imag ())) |
bcc30b45a225
define octave_numeric_limits template methods for Inf and NaN
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
41 ? octave_numeric_limits<double>::Inf () : abs (x)); |
7433 | 42 } |
43 | |
7549
ff9c2bb7abc7
workaround to enable compiling with Intel C++ 10.1
Jaroslav Hajek <highegg@gmail.com>
parents:
7470
diff
changeset
|
44 |
7433 | 45 template <> |
46 bool | |
8752
06b9903a029b
fix & clean up complex & sparse sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
47 sparse_ascending_compare<Complex> (const Complex& a, const Complex& b) |
7433 | 48 { |
49 return (xisnan (b) || (xabs (a) < xabs (b)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
50 || ((xabs (a) == xabs (b)) && (arg (a) < arg (b)))); |
7433 | 51 } |
52 | |
53 template <> | |
54 bool | |
8752
06b9903a029b
fix & clean up complex & sparse sorting
Jaroslav Hajek <highegg@gmail.com>
parents:
7549
diff
changeset
|
55 sparse_descending_compare<Complex> (const Complex& a, const Complex& b) |
7433 | 56 { |
57 return (xisnan (a) || (xabs (a) > xabs (b)) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
58 || ((xabs (a) == xabs (b)) && (arg (a) > arg (b)))); |
7433 | 59 } |
60 | |
10512
aac9f4265048
rewrite sparse indexed assignment
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
61 INSTANTIATE_SPARSE (Complex, OCTAVE_API); |
5164 | 62 |
63 #if 0 | |
64 template std::ostream& operator << (std::ostream&, const Sparse<Complex>&); | |
65 #endif |