Mercurial > octave
annotate libinterp/octave-value/ov-complex.cc @ 21691:263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
We had more or less decided not to bother trying to eliminate all
these warnings for cases in which external dependencies are missing.
But then we get people trying to fix these in various ways, so we
might as well do it for all cases and use a consistent method.
* oct-conf-post.in.h (octave_unused_parameter): New function for C++
code and new macro for C code.
* mk-octave-config-h.sh: Emit octave_unused_parameter function and
macro for octave-config.h.
* CSparse.cc, __delaunayn__.cc, __eigs__.cc, __fltk_uigetfile__.cc,
__glpk__.cc, __magick_read__.cc, __osmesa_print__.cc, __voronoi__.cc,
amd.cc, audiodevinfo.cc, audioread.cc, ccolamd.cc, cdisplay.c,
colamd.cc, convhulln.cc, dSparse.cc, dmperm.cc, fftw.cc, gl-render.cc,
lo-error.c, load-save.cc, ls-hdf5.cc, ls-mat5.cc, oct-hdf5-types.cc,
ov-base-int.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc,
ov-cell.cc, ov-class.cc, ov-complex.cc, ov-cx-mat.cc, ov-cx-sparse.cc,
ov-fcn-handle.cc, ov-fcn-inline.cc, ov-float.cc, ov-flt-complex.cc,
ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-java.cc, ov-range.cc,
ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc,
ov-struct.cc, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc,
sparse-qr.cc, sparse-util.cc, symbfact.cc: Use octave_unused_parameter
to eliminate warnings for conditionally compiled code.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 13 May 2016 09:36:14 -0400 |
parents | 66cae7a6dc47 |
children | aba2e6293dd8 |
rev | line source |
---|---|
2376 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19598
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
2376 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2376 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2376 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21231
diff
changeset
|
24 # include "config.h" |
2376 | 25 #endif |
26 | |
3503 | 27 #include <iostream> |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
28 #include <sstream> |
2901 | 29 |
2376 | 30 #include "lo-ieee.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
31 #include "lo-specfun.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
32 #include "lo-mappers.h" |
2376 | 33 |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15057
diff
changeset
|
34 #include "mxarray.h" |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
20893
diff
changeset
|
35 #include "ovl.h" |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
36 #include "oct-hdf5.h" |
4944 | 37 #include "oct-stream.h" |
2410 | 38 #include "ops.h" |
2376 | 39 #include "ov-complex.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
40 #include "ov-flt-complex.h" |
3223 | 41 #include "ov-base.h" |
42 #include "ov-base-scalar.h" | |
43 #include "ov-base-scalar.cc" | |
2423 | 44 #include "ov-cx-mat.h" |
2410 | 45 #include "ov-scalar.h" |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
46 #include "errwarn.h" |
2376 | 47 #include "pr-output.h" |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
48 #include "ops.h" |
2376 | 49 |
20447
c6224b4e7774
maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents:
19863
diff
changeset
|
50 #include "ls-oct-text.h" |
4687 | 51 #include "ls-hdf5.h" |
52 | |
21573
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
53 // Prevent implicit instantiations on some systems (Windows, others?) |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
54 // that can lead to duplicate definitions of static data members. |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
55 |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
56 extern template class OCTINTERP_API octave_base_scalar<double>; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
57 extern template class OCTINTERP_API octave_base_scalar<FloatComplex>; |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
58 |
f3f8e1d3e399
avoid mulitple definitions of static function-scope vars (bug #47372)
John W. Eaton <jwe@octave.org>
parents:
19863
diff
changeset
|
59 |
3223 | 60 template class octave_base_scalar<Complex>; |
61 | |
2376 | 62 |
4612 | 63 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
64 "complex scalar", "double"); |
2376 | 65 |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
66 // Complain if a complex value is used as a subscript. |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
67 |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
68 class complex_index_exception : public index_exception |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
69 { |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
70 public: |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
71 |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
72 complex_index_exception (const std::string& value) |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
73 : index_exception (value) { } |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
74 |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
75 ~complex_index_exception (void) { } |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
76 |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
77 std::string details (void) const |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
78 { |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
79 return "subscripts must be real (forgot to initialize i or j?)"; |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
80 } |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
81 |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
82 // ID of error to throw. |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
83 const char *err_id (void) const |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
84 { |
21111
7bb96a8df912
lo-array-errwarn.h: Don't export string constants unnecessarily.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
85 return "Octave:invalid-index"; |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
86 } |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
87 }; |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
88 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
89 static octave_base_value * |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
90 default_numeric_demotion_function (const octave_base_value& a) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
91 { |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21574
diff
changeset
|
92 const octave_complex& v = dynamic_cast<const octave_complex&> (a); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
93 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
94 return new octave_float_complex (v.float_complex_value ()); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
95 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
96 |
8345
c777f3ce02d8
smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
97 octave_base_value::type_conv_info |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
98 octave_complex::numeric_demotion_function (void) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
99 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 return |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 octave_base_value::type_conv_info (default_numeric_demotion_function, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 octave_float_complex::static_type_id ()); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
103 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
104 |
5759 | 105 octave_base_value * |
2410 | 106 octave_complex::try_narrowing_conversion (void) |
107 { | |
5759 | 108 octave_base_value *retval = 0; |
2410 | 109 |
5450 | 110 double im = std::imag (scalar); |
111 | |
9825
7483fe200fab
narrow complex values with negative zero imaginary parts
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
112 if (im == 0.0) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
113 retval = new octave_scalar (std::real (scalar)); |
2410 | 114 |
115 return retval; | |
116 } | |
117 | |
2376 | 118 octave_value |
5885 | 119 octave_complex::do_index_op (const octave_value_list& idx, bool resize_ok) |
2376 | 120 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 // FIXME: this doesn't solve the problem of |
8437
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
122 // |
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
123 // a = i; a([1,1], [1,1], [1,1]) |
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
124 // |
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
125 // and similar constructions. Hmm... |
2376 | 126 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 // FIXME: using this constructor avoids narrowing the |
8437
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
128 // 1x1 matrix back to a scalar value. Need a better solution |
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
129 // to this problem. |
2376 | 130 |
8437
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
131 octave_value tmp (new octave_complex_matrix (complex_matrix_value ())); |
2423 | 132 |
8437
f00578b495e9
remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents:
8345
diff
changeset
|
133 return tmp.do_index_op (idx, resize_ok); |
2376 | 134 } |
135 | |
21113
2bbbbb96f631
ov-complex.cc: Incorporate gripe_complex_index into calling fcn.
Rik <rik@octave.org>
parents:
21111
diff
changeset
|
136 // Can't make an index_vector from a complex number. Throw an error. |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
137 idx_vector |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
138 octave_complex::index_vector (bool) const |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
139 { |
21113
2bbbbb96f631
ov-complex.cc: Incorporate gripe_complex_index into calling fcn.
Rik <rik@octave.org>
parents:
21111
diff
changeset
|
140 std::ostringstream buf; |
2bbbbb96f631
ov-complex.cc: Incorporate gripe_complex_index into calling fcn.
Rik <rik@octave.org>
parents:
21111
diff
changeset
|
141 buf << std::real (scalar) << std::showpos << std::imag (scalar) << "i"; |
2bbbbb96f631
ov-complex.cc: Incorporate gripe_complex_index into calling fcn.
Rik <rik@octave.org>
parents:
21111
diff
changeset
|
142 complex_index_exception e (buf.str ()); |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
143 |
21113
2bbbbb96f631
ov-complex.cc: Incorporate gripe_complex_index into calling fcn.
Rik <rik@octave.org>
parents:
21111
diff
changeset
|
144 throw e; |
20653
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
145 } |
c16947991354
avoid fixed-size buffers in index exception code
John W. Eaton <jwe@octave.org>
parents:
20652
diff
changeset
|
146 |
2376 | 147 double |
148 octave_complex::double_value (bool force_conversion) const | |
149 { | |
18676
5bd1ca29c5f0
Clean up questionable code bits identified by clang sanitize.
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
150 double retval; |
2376 | 151 |
5781 | 152 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
153 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
154 "complex scalar", "real scalar"); |
2376 | 155 |
4451 | 156 retval = std::real (scalar); |
2376 | 157 |
158 return retval; | |
159 } | |
160 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
161 float |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
162 octave_complex::float_value (bool force_conversion) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
163 { |
18676
5bd1ca29c5f0
Clean up questionable code bits identified by clang sanitize.
Rik <rik@octave.org>
parents:
18100
diff
changeset
|
164 float retval; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
165 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
166 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
167 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
168 "complex scalar", "real scalar"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
169 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
170 retval = std::real (scalar); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
171 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
172 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
173 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
174 |
2376 | 175 Matrix |
176 octave_complex::matrix_value (bool force_conversion) const | |
177 { | |
178 Matrix retval; | |
179 | |
5781 | 180 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
181 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
182 "complex scalar", "real matrix"); |
2376 | 183 |
4451 | 184 retval = Matrix (1, 1, std::real (scalar)); |
2376 | 185 |
186 return retval; | |
187 } | |
188 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
189 FloatMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
190 octave_complex::float_matrix_value (bool force_conversion) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
191 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
192 FloatMatrix retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
193 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
194 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
195 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
196 "complex scalar", "real matrix"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
197 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
198 retval = FloatMatrix (1, 1, std::real (scalar)); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
199 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
200 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
201 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
202 |
4569 | 203 NDArray |
204 octave_complex::array_value (bool force_conversion) const | |
205 { | |
206 NDArray retval; | |
207 | |
5781 | 208 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
209 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
210 "complex scalar", "real matrix"); |
4569 | 211 |
212 retval = NDArray (dim_vector (1, 1), std::real (scalar)); | |
213 | |
214 return retval; | |
215 } | |
216 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
217 FloatNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
218 octave_complex::float_array_value (bool force_conversion) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
219 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
220 FloatNDArray retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
221 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
222 if (! force_conversion) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
223 warn_implicit_conversion ("Octave:imag-to-real", |
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21022
diff
changeset
|
224 "complex scalar", "real matrix"); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
225 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
226 retval = FloatNDArray (dim_vector (1, 1), std::real (scalar)); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
227 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
228 return retval; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
229 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
230 |
2376 | 231 Complex |
232 octave_complex::complex_value (bool) const | |
233 { | |
234 return scalar; | |
235 } | |
236 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
237 FloatComplex |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
238 octave_complex::float_complex_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
239 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
240 return static_cast<FloatComplex> (scalar); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
241 } |
2376 | 242 |
243 ComplexMatrix | |
244 octave_complex::complex_matrix_value (bool) const | |
245 { | |
246 return ComplexMatrix (1, 1, scalar); | |
247 } | |
248 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
249 FloatComplexMatrix |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
250 octave_complex::float_complex_matrix_value (bool) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
251 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
252 return FloatComplexMatrix (1, 1, static_cast<FloatComplex> (scalar)); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
253 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
254 |
4569 | 255 ComplexNDArray |
4664 | 256 octave_complex::complex_array_value (bool /* force_conversion */) const |
4569 | 257 { |
258 return ComplexNDArray (dim_vector (1, 1), scalar); | |
259 } | |
260 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
261 FloatComplexNDArray |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
262 octave_complex::float_complex_array_value (bool /* force_conversion */) const |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
263 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
264 return FloatComplexNDArray (dim_vector (1, 1), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
265 static_cast<FloatComplex> (scalar)); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
266 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7740
diff
changeset
|
267 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
268 octave_value |
5731 | 269 octave_complex::resize (const dim_vector& dv, bool fill) const |
270 { | |
271 if (fill) | |
272 { | |
14616
13cc11418393
improve handling of default resize fill value for arrays
John W. Eaton <jwe@octave.org>
parents:
14557
diff
changeset
|
273 ComplexNDArray retval (dv, Complex (0)); |
5731 | 274 |
275 if (dv.numel ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
276 retval(0) = scalar; |
5731 | 277 |
278 return retval; | |
279 } | |
280 else | |
281 { | |
282 ComplexNDArray retval (dv); | |
283 | |
284 if (dv.numel ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
285 retval(0) = scalar; |
5731 | 286 |
287 return retval; | |
288 } | |
289 } | |
290 | |
14557
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
291 octave_value |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
292 octave_complex::diag (octave_idx_type m, octave_idx_type n) const |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
293 { |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
294 return ComplexDiagMatrix (Array<Complex> (dim_vector (1, 1), scalar), m, n); |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
295 } |
e8e86ae3abbc
make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
296 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
297 bool |
6974 | 298 octave_complex::save_ascii (std::ostream& os) |
4687 | 299 { |
300 Complex c = complex_value (); | |
301 | |
5958 | 302 octave_write_complex (os, c); |
4687 | 303 |
5958 | 304 os << "\n"; |
4687 | 305 |
306 return true; | |
307 } | |
308 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
309 bool |
4687 | 310 octave_complex::load_ascii (std::istream& is) |
311 { | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
312 scalar = octave_read_value<Complex> (is); |
4687 | 313 |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20653
diff
changeset
|
314 if (! is) |
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20653
diff
changeset
|
315 error ("load: failed to load complex scalar constant"); |
4687 | 316 |
317 return true; | |
318 } | |
319 | |
320 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
321 bool |
4687 | 322 octave_complex::save_binary (std::ostream& os, bool& /* save_as_floats */) |
323 { | |
5760 | 324 char tmp = static_cast<char> (LS_DOUBLE); |
325 os.write (reinterpret_cast<char *> (&tmp), 1); | |
4687 | 326 Complex ctmp = complex_value (); |
5760 | 327 os.write (reinterpret_cast<char *> (&ctmp), 16); |
4687 | 328 |
329 return true; | |
330 } | |
331 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
332 bool |
4687 | 333 octave_complex::load_binary (std::istream& is, bool swap, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
334 oct_mach_info::float_format fmt) |
4687 | 335 { |
336 char tmp; | |
5760 | 337 if (! is.read (reinterpret_cast<char *> (&tmp), 1)) |
4687 | 338 return false; |
339 | |
340 Complex ctmp; | |
5760 | 341 read_doubles (is, reinterpret_cast<double *> (&ctmp), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
342 static_cast<save_type> (tmp), 2, swap, fmt); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
343 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
344 if (! is) |
4687 | 345 return false; |
346 | |
347 scalar = ctmp; | |
348 return true; | |
349 } | |
350 | |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
351 bool |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
352 octave_complex::save_hdf5 (octave_hdf5_id loc_id, const char *name, |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
353 bool /* save_as_floats */) |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
354 { |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
355 bool retval = false; |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
356 |
4687 | 357 #if defined (HAVE_HDF5) |
4944 | 358 |
4687 | 359 hsize_t dimens[3]; |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
360 hid_t space_hid, type_hid, data_hid; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
361 space_hid = type_hid = data_hid = -1; |
4687 | 362 |
4815 | 363 space_hid = H5Screate_simple (0, dimens, 0); |
4837 | 364 if (space_hid < 0) |
365 return false; | |
4687 | 366 |
367 type_hid = hdf5_make_complex_type (H5T_NATIVE_DOUBLE); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
368 if (type_hid < 0) |
4687 | 369 { |
370 H5Sclose (space_hid); | |
371 return false; | |
372 } | |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
373 #if defined (HAVE_HDF5_18) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
374 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
375 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
376 #else |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
377 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, octave_H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
378 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
379 if (data_hid < 0) |
4687 | 380 { |
381 H5Sclose (space_hid); | |
382 H5Tclose (type_hid); | |
383 return false; | |
384 } | |
385 | |
386 Complex tmp = complex_value (); | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
387 retval = H5Dwrite (data_hid, type_hid, octave_H5S_ALL, octave_H5S_ALL, octave_H5P_DEFAULT, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
388 &tmp) >= 0; |
4687 | 389 |
390 H5Dclose (data_hid); | |
391 H5Tclose (type_hid); | |
392 H5Sclose (space_hid); | |
4837 | 393 |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
394 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
395 octave_unused_parameter (loc_id); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
396 octave_unused_parameter (name); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
397 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
398 warn_save ("hdf5"); |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
399 #endif |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
400 |
4687 | 401 return retval; |
402 } | |
403 | |
404 bool | |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
405 octave_complex::load_hdf5 (octave_hdf5_id loc_id, const char *name) |
4687 | 406 { |
407 bool retval = false; | |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
408 |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
409 #if defined (HAVE_HDF5) |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
410 |
21211
2cf8bc5c7017
use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents:
21200
diff
changeset
|
411 #if defined (HAVE_HDF5_18) |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
412 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
413 #else |
4687 | 414 hid_t data_hid = H5Dopen (loc_id, name); |
9892
ac69e6f4b33d
Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents:
9881
diff
changeset
|
415 #endif |
4687 | 416 hid_t type_hid = H5Dget_type (data_hid); |
417 | |
418 hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE); | |
419 | |
420 if (! hdf5_types_compatible (type_hid, complex_type)) | |
421 { | |
4837 | 422 H5Tclose (complex_type); |
4687 | 423 H5Dclose (data_hid); |
424 return false; | |
425 } | |
426 | |
427 hid_t space_id = H5Dget_space (data_hid); | |
428 hsize_t rank = H5Sget_simple_extent_ndims (space_id); | |
429 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
430 if (rank != 0) |
4687 | 431 { |
4837 | 432 H5Tclose (complex_type); |
4687 | 433 H5Sclose (space_id); |
434 H5Dclose (data_hid); | |
435 return false; | |
436 } | |
437 | |
438 // complex scalar: | |
439 Complex ctmp; | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
440 if (H5Dread (data_hid, complex_type, octave_H5S_ALL, octave_H5S_ALL, octave_H5P_DEFAULT, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
441 &ctmp) >= 0) |
4687 | 442 { |
443 retval = true; | |
444 scalar = ctmp; | |
445 } | |
446 | |
4837 | 447 H5Tclose (complex_type); |
4687 | 448 H5Sclose (space_id); |
449 H5Dclose (data_hid); | |
4837 | 450 |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
451 #else |
21691
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
452 octave_unused_parameter (loc_id); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
453 octave_unused_parameter (name); |
263d18409fdf
Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
454 |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
455 warn_load ("hdf5"); |
19863
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
456 #endif |
09ed6f7538dd
avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents:
19697
diff
changeset
|
457 |
4687 | 458 return retval; |
459 } | |
4944 | 460 |
5900 | 461 mxArray * |
462 octave_complex::as_mxArray (void) const | |
463 { | |
464 mxArray *retval = new mxArray (mxDOUBLE_CLASS, 1, 1, mxCOMPLEX); | |
465 | |
466 double *pr = static_cast<double *> (retval->get_data ()); | |
467 double *pi = static_cast<double *> (retval->get_imag_data ()); | |
468 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
469 pr[0] = std::real (scalar); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
470 pi[0] = std::imag (scalar); |
5900 | 471 |
472 return retval; | |
473 } | |
474 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
475 octave_value |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
476 octave_complex::map (unary_mapper_t umap) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
477 { |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
478 switch (umap) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
479 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
480 #define SCALAR_MAPPER(UMAP, FCN) \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
481 case umap_ ## UMAP: \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
482 return octave_value (FCN (scalar)) |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
483 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
484 SCALAR_MAPPER (abs, std::abs); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
485 SCALAR_MAPPER (acos, ::acos); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
486 SCALAR_MAPPER (acosh, xacosh); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
487 SCALAR_MAPPER (angle, std::arg); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
488 SCALAR_MAPPER (arg, std::arg); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
489 SCALAR_MAPPER (asin, ::asin); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
490 SCALAR_MAPPER (asinh, xasinh); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
491 SCALAR_MAPPER (atan, ::atan); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
492 SCALAR_MAPPER (atanh, xatanh); |
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
493 SCALAR_MAPPER (erf, xerf); |
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
494 SCALAR_MAPPER (erfc, xerfc); |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15195
diff
changeset
|
495 SCALAR_MAPPER (erfcx, ::erfcx); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15195
diff
changeset
|
496 SCALAR_MAPPER (erfi, ::erfi); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15195
diff
changeset
|
497 SCALAR_MAPPER (dawson, ::dawson); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
498 SCALAR_MAPPER (ceil, ::ceil); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
499 SCALAR_MAPPER (conj, std::conj); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
500 SCALAR_MAPPER (cos, std::cos); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
501 SCALAR_MAPPER (cosh, std::cosh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
502 SCALAR_MAPPER (exp, std::exp); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
503 SCALAR_MAPPER (expm1, xexpm1); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
504 SCALAR_MAPPER (fix, ::fix); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
505 SCALAR_MAPPER (floor, ::floor); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
506 SCALAR_MAPPER (imag, std::imag); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
507 SCALAR_MAPPER (log, std::log); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
508 SCALAR_MAPPER (log2, xlog2); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
509 SCALAR_MAPPER (log10, std::log10); |
21231
5f318c8ec634
eliminate feature tests from lo-specfun.h
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
510 SCALAR_MAPPER (log1p, xlog1p); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
511 SCALAR_MAPPER (real, std::real); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
512 SCALAR_MAPPER (round, xround); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
513 SCALAR_MAPPER (roundb, xroundb); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
514 SCALAR_MAPPER (signum, ::signum); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
515 SCALAR_MAPPER (sin, std::sin); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
516 SCALAR_MAPPER (sinh, std::sinh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
517 SCALAR_MAPPER (sqrt, std::sqrt); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
518 SCALAR_MAPPER (tan, std::tan); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
519 SCALAR_MAPPER (tanh, std::tanh); |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
520 SCALAR_MAPPER (isfinite, xfinite); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
521 SCALAR_MAPPER (isinf, xisinf); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
522 SCALAR_MAPPER (isna, octave_is_NA); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
523 SCALAR_MAPPER (isnan, xisnan); |
7667
fb3a6c53c2b2
Allow negative zero imaginary part to be treated as zero for erf, erfc, gamma and lgamma mapper function
David Bateman <dbateman@free.fr>
parents:
7638
diff
changeset
|
524 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
525 default: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
526 return octave_base_value::map (umap); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
527 } |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9469
diff
changeset
|
528 } |