Mercurial > jwe > octave
annotate libinterp/octave-value/ov-re-sparse.cc @ 21120:499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
* schur.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-sparse.cc, ov-float.h,
ov-flt-complex.h, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-range.cc,
ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.h, ov-str-mat.cc, ops.h, pt-idx.cc,
Array.cc, CColVector.cc, CMatrix.cc, CRowVector.cc, MSparse.cc, PermMatrix.cc,
Sparse.cc, dColVector.cc, dMatrix.cc, dRowVector.cc, dSparse.cc,
fCColVector.cc, fCMatrix.cc, fCRowVector.cc, fColVector.cc, fMatrix.cc,
fRowVector.cc:
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 20 Jan 2016 16:58:59 -0800 |
parents | 3ac9f47fb04b |
children | fcac5dbbf9ed |
rev | line source |
---|---|
5164 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19598
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 | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include <iostream> | |
15215
9020dddc925a
use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
29 #include <limits> |
5164 | 30 #include <vector> |
31 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
32 #include "lo-specfun.h" |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
33 #include "lo-mappers.h" |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7922
diff
changeset
|
34 #include "oct-locbuf.h" |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
35 |
15149
62a35ae7d6a2
use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents:
15057
diff
changeset
|
36 #include "mxarray.h" |
5164 | 37 #include "ov-base.h" |
38 #include "ov-scalar.h" | |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
39 #include "errwarn.h" |
5164 | 40 |
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
|
41 #include "oct-hdf5.h" |
5164 | 42 #include "ls-hdf5.h" |
43 | |
44 #include "ov-re-sparse.h" | |
45 | |
46 #include "ov-base-sparse.h" | |
47 #include "ov-base-sparse.cc" | |
48 | |
49 #include "ov-bool-sparse.h" | |
50 | |
6109 | 51 template class OCTINTERP_API octave_base_sparse<SparseMatrix>; |
5164 | 52 |
53 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
54 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sparse_matrix, "sparse matrix", |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
55 "double"); |
5164 | 56 |
5282 | 57 idx_vector |
18130
e473c4853afc
enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents:
17787
diff
changeset
|
58 octave_sparse_matrix::index_vector (bool /* require_integers */) const |
5282 | 59 { |
5604 | 60 if (matrix.numel () == matrix.nnz ()) |
5282 | 61 return idx_vector (array_value ()); |
62 else | |
63 { | |
20542
dd6345fd8a97
use exceptions for better invalid index error reporting (bug #45957)
Lachlan Andrew <lachlanbis@gmail.com>
parents:
20181
diff
changeset
|
64 std::string nm = "<" + type_name () + ">"; |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
65 err_invalid_index (nm.c_str ()); |
5282 | 66 } |
67 } | |
68 | |
5759 | 69 octave_base_value * |
5164 | 70 octave_sparse_matrix::try_narrowing_conversion (void) |
71 { | |
5759 | 72 octave_base_value *retval = 0; |
5164 | 73 |
7193 | 74 if (Vsparse_auto_mutate) |
5164 | 75 { |
7193 | 76 // Don't use numel, since it can overflow for very large matrices |
77 // Note that for the second test, this means it becomes approximative | |
78 // since it involves a cast to double to avoid issues of overflow | |
79 if (matrix.rows () == 1 && matrix.cols () == 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
80 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
81 // Const copy of the matrix, so the right version of () operator used |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
82 const SparseMatrix tmp (matrix); |
5164 | 83 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
84 retval = new octave_scalar (tmp (0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
85 } |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
86 else if (matrix.cols () > 0 && matrix.rows () > 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
87 && (double (matrix.byte_size ()) > double (matrix.rows ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
88 * double (matrix.cols ()) * sizeof (double))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
89 retval = new octave_matrix (matrix.matrix_value ()); |
5164 | 90 } |
91 | |
92 return retval; | |
93 } | |
94 | |
95 double | |
96 octave_sparse_matrix::double_value (bool) const | |
97 { | |
98 double retval = lo_ieee_nan_value (); | |
99 | |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
100 if (numel () == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
101 err_invalid_conversion ("real sparse matrix", "real scalar"); |
5164 | 102 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
103 if (numel () > 1) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
104 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
105 "real sparse matrix", "real scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
106 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
107 retval = matrix(0, 0); |
5164 | 108 |
109 return retval; | |
110 } | |
111 | |
112 Complex | |
113 octave_sparse_matrix::complex_value (bool) const | |
114 { | |
115 double tmp = lo_ieee_nan_value (); | |
116 | |
117 Complex retval (tmp, tmp); | |
118 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 // FIXME: maybe this should be a function, valid_as_scalar() |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
120 if (rows () == 0 || columns () == 0) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
121 err_invalid_conversion ("real sparse matrix", "complex scalar"); |
5164 | 122 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
123 if (numel () > 1) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
124 warn_implicit_conversion ("Octave:array-to-scalar", |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
125 "real sparse matrix", "complex scalar"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
126 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
127 retval = matrix(0, 0); |
5164 | 128 |
129 return retval; | |
130 } | |
131 | |
132 Matrix | |
133 octave_sparse_matrix::matrix_value (bool) const | |
134 { | |
135 return matrix.matrix_value (); | |
136 } | |
137 | |
5898 | 138 boolNDArray |
5943 | 139 octave_sparse_matrix::bool_array_value (bool warn) const |
5898 | 140 { |
5943 | 141 NDArray m = matrix.matrix_value (); |
142 | |
7922
935be827eaf8
error for NaN values in & and | expressions
John W. Eaton <jwe@octave.org>
parents:
7885
diff
changeset
|
143 if (m.any_element_is_nan ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
144 err_nan_to_logical_conversion (); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
145 if (warn && m.any_element_not_one_or_zero ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
146 warn_logical_conversion (); |
5943 | 147 |
148 return boolNDArray (m); | |
5898 | 149 } |
150 | |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
151 charNDArray |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
152 octave_sparse_matrix::char_array_value (bool) const |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
153 { |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
154 charNDArray retval (dims (), 0); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
155 octave_idx_type nc = matrix.cols (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
156 octave_idx_type nr = matrix.rows (); |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
157 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
158 for (octave_idx_type j = 0; j < nc; j++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
159 for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
160 retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i)); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
161 |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
162 return retval; |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
163 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
164 |
5164 | 165 ComplexMatrix |
166 octave_sparse_matrix::complex_matrix_value (bool) const | |
167 { | |
168 return ComplexMatrix (matrix.matrix_value ()); | |
169 } | |
170 | |
171 ComplexNDArray | |
172 octave_sparse_matrix::complex_array_value (bool) const | |
173 { | |
174 return ComplexNDArray (ComplexMatrix (matrix.matrix_value ())); | |
175 } | |
176 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
177 NDArray |
5164 | 178 octave_sparse_matrix::array_value (bool) const |
179 { | |
180 return NDArray (matrix.matrix_value ()); | |
181 } | |
182 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
183 SparseBoolMatrix |
9852
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
184 octave_sparse_matrix::sparse_bool_matrix_value (bool warn) const |
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
185 { |
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
186 if (matrix.any_element_is_nan ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
187 err_nan_to_logical_conversion (); |
21120
499b851fbfae
Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents:
21118
diff
changeset
|
188 if (warn && matrix.any_element_not_one_or_zero ()) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
189 warn_logical_conversion (); |
9852
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
190 |
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
191 return mx_el_ne (matrix, 0.0); |
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
192 } |
aabf7a8c2e57
implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents:
9835
diff
changeset
|
193 |
5282 | 194 octave_value |
5322 | 195 octave_sparse_matrix::convert_to_str_internal (bool, bool, char type) const |
5282 | 196 { |
197 octave_value retval; | |
198 dim_vector dv = dims (); | |
199 octave_idx_type nel = dv.numel (); | |
200 | |
201 if (nel == 0) | |
202 { | |
203 char s = '\0'; | |
5322 | 204 retval = octave_value (&s, type); |
5282 | 205 } |
206 else | |
207 { | |
208 octave_idx_type nr = matrix.rows (); | |
209 octave_idx_type nc = matrix.cols (); | |
210 charNDArray chm (dv, static_cast<char> (0)); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
211 |
5282 | 212 bool warned = false; |
213 | |
214 for (octave_idx_type j = 0; j < nc; j++) | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
215 for (octave_idx_type i = matrix.cidx (j); |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
216 i < matrix.cidx (j+1); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
217 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
218 octave_quit (); |
5282 | 219 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
220 double d = matrix.data (i); |
5282 | 221 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
222 if (xisnan (d)) |
21100
e39e05d90788
Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents:
21024
diff
changeset
|
223 err_nan_to_character_conversion (); |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
224 |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
225 int ival = NINT (d); |
5282 | 226 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
227 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ()) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
228 { |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
229 // FIXME: is there something better we could do? |
5282 | 230 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
231 ival = 0; |
5282 | 232 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
233 if (! warned) |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
234 { |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
235 ::warning ("range error for conversion to character value"); |
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
236 warned = true; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
237 } |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
238 } |
5282 | 239 |
21118
3ac9f47fb04b
Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents:
21102
diff
changeset
|
240 chm(matrix.ridx (i) + j * nr) = static_cast<char> (ival); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
241 } |
9689
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9470
diff
changeset
|
242 |
34d6f005db4b
eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents:
9470
diff
changeset
|
243 retval = octave_value (chm, type); |
5282 | 244 } |
245 | |
246 return retval; | |
247 } | |
248 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
249 bool |
5164 | 250 octave_sparse_matrix::save_binary (std::ostream& os, bool&save_as_floats) |
251 { | |
252 dim_vector d = this->dims (); | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
253 if (d.length () < 1) |
5164 | 254 return false; |
255 | |
256 // Ensure that additional memory is deallocated | |
257 matrix.maybe_compress (); | |
258 | |
259 int nr = d(0); | |
260 int nc = d(1); | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10414
diff
changeset
|
261 int nz = nnz (); |
5164 | 262 |
5828 | 263 int32_t itmp; |
5164 | 264 // Use negative value for ndims to be consistent with other formats |
18738
3bffa847d215
maint: Use space after variable name and before equals sign.
Rik <rik@octave.org>
parents:
18132
diff
changeset
|
265 itmp = -2; |
5760 | 266 os.write (reinterpret_cast<char *> (&itmp), 4); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
267 |
18738
3bffa847d215
maint: Use space after variable name and before equals sign.
Rik <rik@octave.org>
parents:
18132
diff
changeset
|
268 itmp = nr; |
5760 | 269 os.write (reinterpret_cast<char *> (&itmp), 4); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
270 |
18738
3bffa847d215
maint: Use space after variable name and before equals sign.
Rik <rik@octave.org>
parents:
18132
diff
changeset
|
271 itmp = nc; |
5760 | 272 os.write (reinterpret_cast<char *> (&itmp), 4); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
273 |
18738
3bffa847d215
maint: Use space after variable name and before equals sign.
Rik <rik@octave.org>
parents:
18132
diff
changeset
|
274 itmp = nz; |
5760 | 275 os.write (reinterpret_cast<char *> (&itmp), 4); |
5164 | 276 |
277 save_type st = LS_DOUBLE; | |
278 if (save_as_floats) | |
279 { | |
280 if (matrix.too_large_for_float ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
281 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
282 warning ("save: some values too large to save as floats --"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
283 warning ("save: saving as doubles instead"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
284 } |
5164 | 285 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
286 st = LS_FLOAT; |
5164 | 287 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
288 else if (matrix.nnz () > 8192) // FIXME: make this configurable. |
5164 | 289 { |
290 double max_val, min_val; | |
291 if (matrix.all_integers (max_val, min_val)) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
292 st = get_save_type (max_val, min_val); |
5164 | 293 } |
294 | |
295 // add one to the printed indices to go from | |
296 // zero-based to one-based arrays | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
297 for (int i = 0; i < nc+1; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
298 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
299 octave_quit (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
300 itmp = matrix.cidx (i); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
301 os.write (reinterpret_cast<char *> (&itmp), 4); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
302 } |
5164 | 303 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
304 for (int i = 0; i < nz; i++) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
305 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
306 octave_quit (); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
307 itmp = matrix.ridx (i); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
308 os.write (reinterpret_cast<char *> (&itmp), 4); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
309 } |
5164 | 310 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
311 write_doubles (os, matrix.data (), st, nz); |
5164 | 312 |
313 return true; | |
314 } | |
315 | |
316 bool | |
317 octave_sparse_matrix::load_binary (std::istream& is, bool swap, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
318 oct_mach_info::float_format fmt) |
5164 | 319 { |
5828 | 320 int32_t nz, nc, nr, tmp; |
5327 | 321 char ctmp; |
322 | |
5760 | 323 if (! is.read (reinterpret_cast<char *> (&tmp), 4)) |
5164 | 324 return false; |
325 | |
326 if (swap) | |
327 swap_bytes<4> (&tmp); | |
328 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
329 if (tmp != -2) |
20893
384ff5aa9437
2015 Code Sprint: Eliminate useless return statements after error ().
Rik <rik@octave.org>
parents:
20555
diff
changeset
|
330 error ("load: only 2-D sparse matrices are supported"); |
5164 | 331 |
5760 | 332 if (! is.read (reinterpret_cast<char *> (&nr), 4)) |
5164 | 333 return false; |
5760 | 334 if (! is.read (reinterpret_cast<char *> (&nc), 4)) |
5164 | 335 return false; |
5760 | 336 if (! is.read (reinterpret_cast<char *> (&nz), 4)) |
5164 | 337 return false; |
338 | |
339 if (swap) | |
340 { | |
341 swap_bytes<4> (&nr); | |
342 swap_bytes<4> (&nc); | |
343 swap_bytes<4> (&nz); | |
344 } | |
345 | |
5275 | 346 SparseMatrix m (static_cast<octave_idx_type> (nr), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
347 static_cast<octave_idx_type> (nc), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
348 static_cast<octave_idx_type> (nz)); |
5164 | 349 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
350 for (int i = 0; i < nc+1; i++) |
5164 | 351 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
352 octave_quit (); |
5760 | 353 if (! is.read (reinterpret_cast<char *> (&tmp), 4)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
354 return false; |
5164 | 355 if (swap) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
356 swap_bytes<4> (&tmp); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
357 m.xcidx (i) = tmp; |
5164 | 358 } |
359 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
360 for (int i = 0; i < nz; i++) |
5164 | 361 { |
10142
829e69ec3110
make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents:
9892
diff
changeset
|
362 octave_quit (); |
5760 | 363 if (! is.read (reinterpret_cast<char *> (&tmp), 4)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
364 return false; |
5164 | 365 if (swap) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
366 swap_bytes<4> (&tmp); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
367 m.xridx (i) = tmp; |
5164 | 368 } |
369 | |
5760 | 370 if (! is.read (reinterpret_cast<char *> (&ctmp), 1)) |
5164 | 371 return false; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
372 |
5760 | 373 read_doubles (is, m.xdata (), static_cast<save_type> (ctmp), nz, swap, fmt); |
5164 | 374 |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20542
diff
changeset
|
375 if (! is) |
5164 | 376 return false; |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
377 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
378 if (! m.indices_ok ()) |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
379 return false; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
380 |
5164 | 381 matrix = m; |
382 | |
383 return true; | |
384 } | |
385 | |
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
|
386 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
|
387 octave_sparse_matrix::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
|
388 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
|
389 { |
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
|
390 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
|
391 |
5164 | 392 #if defined (HAVE_HDF5) |
5900 | 393 |
5164 | 394 dim_vector dv = dims (); |
395 int empty = save_hdf5_empty (loc_id, name, dv); | |
396 if (empty) | |
397 return (empty > 0); | |
398 | |
399 // Ensure that additional memory is deallocated | |
400 matrix.maybe_compress (); | |
401 | |
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
|
402 #if 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
|
403 hid_t group_hid = H5Gcreate (loc_id, name, octave_H5P_DEFAULT, octave_H5P_DEFAULT, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
404 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
|
405 #else |
5164 | 406 hid_t group_hid = H5Gcreate (loc_id, name, 0); |
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
|
407 #endif |
5164 | 408 if (group_hid < 0) |
409 return false; | |
410 | |
18100
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
411 hid_t space_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
|
412 space_hid = data_hid = -1; |
5164 | 413 SparseMatrix m = sparse_matrix_value (); |
5351 | 414 octave_idx_type tmp; |
5164 | 415 hsize_t hdims[2]; |
416 | |
5760 | 417 space_hid = H5Screate_simple (0, hdims, 0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
418 if (space_hid < 0) |
5164 | 419 { |
420 H5Gclose (group_hid); | |
421 return false; | |
422 } | |
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
|
423 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
424 data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, 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
|
425 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
|
426 #else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
427 data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, 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
|
428 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
|
429 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
430 if (data_hid < 0) |
5164 | 431 { |
432 H5Sclose (space_hid); | |
433 H5Gclose (group_hid); | |
434 return false; | |
435 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
436 |
5164 | 437 tmp = m.rows (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
438 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, 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
|
439 &tmp) >= 0; |
5164 | 440 H5Dclose (data_hid); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
441 if (! retval) |
5164 | 442 { |
443 H5Sclose (space_hid); | |
444 H5Gclose (group_hid); | |
445 return false; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
446 } |
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
|
447 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
448 data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, 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
|
449 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
|
450 #else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
451 data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, 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
|
452 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
|
453 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
454 if (data_hid < 0) |
5164 | 455 { |
456 H5Sclose (space_hid); | |
457 H5Gclose (group_hid); | |
458 return false; | |
459 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
460 |
5164 | 461 tmp = m.cols (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
462 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, 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
|
463 &tmp) >= 0; |
5164 | 464 H5Dclose (data_hid); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
465 if (! retval) |
5164 | 466 { |
467 H5Sclose (space_hid); | |
468 H5Gclose (group_hid); | |
469 return false; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
470 } |
5164 | 471 |
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
|
472 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
473 data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, 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
|
474 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_H5P_DEFAULT); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
475 #else |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
476 data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, 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
|
477 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
|
478 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
479 if (data_hid < 0) |
5164 | 480 { |
481 H5Sclose (space_hid); | |
482 H5Gclose (group_hid); | |
483 return false; | |
484 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
485 |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10414
diff
changeset
|
486 tmp = m.nnz (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
487 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, 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
|
488 &tmp) >= 0; |
5164 | 489 H5Dclose (data_hid); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
490 if (! retval) |
5164 | 491 { |
492 H5Sclose (space_hid); | |
493 H5Gclose (group_hid); | |
494 return false; | |
495 } | |
496 | |
497 H5Sclose (space_hid); | |
498 | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
499 hdims[0] = m.cols () + 1; |
5164 | 500 hdims[1] = 1; |
501 | |
502 space_hid = H5Screate_simple (2, hdims, 0); | |
503 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
504 if (space_hid < 0) |
5164 | 505 { |
506 H5Gclose (group_hid); | |
507 return false; | |
508 } | |
509 | |
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
|
510 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
511 data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, 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
|
512 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
|
513 #else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
514 data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, 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
|
515 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
|
516 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
517 if (data_hid < 0) |
5164 | 518 { |
519 H5Sclose (space_hid); | |
520 H5Gclose (group_hid); | |
521 return false; | |
522 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
523 |
5351 | 524 octave_idx_type * itmp = m.xcidx (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
525 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, 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
|
526 itmp) >= 0; |
5164 | 527 H5Dclose (data_hid); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
528 if (! retval) |
5164 | 529 { |
530 H5Sclose (space_hid); | |
531 H5Gclose (group_hid); | |
532 return false; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
533 } |
5164 | 534 |
535 H5Sclose (space_hid); | |
536 | |
10527
b4d2080b6df7
Replace nzmax by nnz as needed
David Bateman <dbateman@free.fr>
parents:
10414
diff
changeset
|
537 hdims[0] = m.nnz (); |
5164 | 538 hdims[1] = 1; |
539 | |
540 space_hid = H5Screate_simple (2, hdims, 0); | |
541 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
542 if (space_hid < 0) |
5164 | 543 { |
544 H5Gclose (group_hid); | |
545 return false; | |
546 } | |
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
|
547 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
548 data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, 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
|
549 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
|
550 #else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
551 data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, 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
|
552 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
|
553 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
554 if (data_hid < 0) |
5164 | 555 { |
556 H5Sclose (space_hid); | |
557 H5Gclose (group_hid); | |
558 return false; | |
559 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
560 |
5164 | 561 itmp = m.xridx (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
562 retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, 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
|
563 itmp) >= 0; |
5164 | 564 H5Dclose (data_hid); |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
20945
diff
changeset
|
565 if (! retval) |
5164 | 566 { |
567 H5Sclose (space_hid); | |
568 H5Gclose (group_hid); | |
569 return false; | |
570 } | |
571 | |
572 hid_t save_type_hid = H5T_NATIVE_DOUBLE; | |
573 | |
574 if (save_as_floats) | |
575 { | |
576 if (m.too_large_for_float ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
577 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
578 warning ("save: some values too large to save as floats --"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
579 warning ("save: saving as doubles instead"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
580 } |
5164 | 581 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
582 save_type_hid = H5T_NATIVE_FLOAT; |
5164 | 583 } |
584 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS | |
585 // hdf5 currently doesn't support float/integer conversions | |
586 else | |
587 { | |
588 double max_val, min_val; | |
589 | |
590 if (m.all_integers (max_val, min_val)) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
591 save_type_hid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
592 = save_type_to_hdf5 (get_save_type (max_val, min_val)); |
5164 | 593 } |
20945
9d9270e2f98f
eliminate comments after preprocessor conditionals
John W. Eaton <jwe@octave.org>
parents:
20893
diff
changeset
|
594 #endif |
5164 | 595 |
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
|
596 #if HAVE_HDF5_18 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
597 data_hid = H5Dcreate (group_hid, "data", save_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
|
598 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
|
599 #else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
600 data_hid = H5Dcreate (group_hid, "data", save_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
|
601 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
|
602 #endif |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
603 if (data_hid < 0) |
5164 | 604 { |
605 H5Sclose (space_hid); | |
606 H5Gclose (group_hid); | |
607 return false; | |
608 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
609 |
5164 | 610 double * dtmp = m.xdata (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
611 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
612 octave_H5P_DEFAULT, dtmp) >= 0; |
5164 | 613 H5Dclose (data_hid); |
614 H5Sclose (space_hid); | |
615 H5Gclose (group_hid); | |
616 | |
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
|
617 #else |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
618 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
|
619 #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
|
620 |
5164 | 621 return retval; |
622 } | |
623 | |
624 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
|
625 octave_sparse_matrix::load_hdf5 (octave_hdf5_id loc_id, const char *name) |
5164 | 626 { |
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
|
627 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
|
628 |
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
|
629 #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
|
630 |
5351 | 631 octave_idx_type nr, nc, nz; |
5164 | 632 hid_t group_hid, data_hid, space_hid; |
633 hsize_t rank; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
634 |
5164 | 635 dim_vector dv; |
636 int empty = load_hdf5_empty (loc_id, name, dv); | |
637 if (empty > 0) | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
638 matrix.resize (dv); |
5164 | 639 if (empty) |
640 return (empty > 0); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
641 |
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
|
642 #if 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
|
643 group_hid = H5Gopen (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
|
644 #else |
5164 | 645 group_hid = H5Gopen (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
|
646 #endif |
5760 | 647 if (group_hid < 0) return false; |
5164 | 648 |
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
|
649 #if 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
|
650 data_hid = H5Dopen (group_hid, "nr", 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
|
651 #else |
5164 | 652 data_hid = H5Dopen (group_hid, "nr"); |
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
|
653 #endif |
5164 | 654 space_hid = H5Dget_space (data_hid); |
655 rank = H5Sget_simple_extent_ndims (space_hid); | |
656 | |
657 if (rank != 0) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
658 { |
5164 | 659 H5Dclose (data_hid); |
660 H5Gclose (group_hid); | |
661 return false; | |
662 } | |
663 | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
664 if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
665 octave_H5P_DEFAULT, &nr) < 0) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
666 { |
5164 | 667 H5Dclose (data_hid); |
668 H5Gclose (group_hid); | |
669 return false; | |
670 } | |
671 | |
672 H5Dclose (data_hid); | |
673 | |
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
|
674 #if 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
|
675 data_hid = H5Dopen (group_hid, "nc", 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
|
676 #else |
5164 | 677 data_hid = H5Dopen (group_hid, "nc"); |
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
|
678 #endif |
5164 | 679 space_hid = H5Dget_space (data_hid); |
680 rank = H5Sget_simple_extent_ndims (space_hid); | |
681 | |
682 if (rank != 0) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
683 { |
5164 | 684 H5Dclose (data_hid); |
685 H5Gclose (group_hid); | |
686 return false; | |
687 } | |
688 | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
689 if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
690 octave_H5P_DEFAULT, &nc) < 0) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
691 { |
5164 | 692 H5Dclose (data_hid); |
693 H5Gclose (group_hid); | |
694 return false; | |
695 } | |
696 | |
697 H5Dclose (data_hid); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
698 |
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
|
699 #if 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
|
700 data_hid = H5Dopen (group_hid, "nz", 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
|
701 #else |
5164 | 702 data_hid = H5Dopen (group_hid, "nz"); |
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
|
703 #endif |
5164 | 704 space_hid = H5Dget_space (data_hid); |
705 rank = H5Sget_simple_extent_ndims (space_hid); | |
706 | |
707 if (rank != 0) | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
708 { |
5164 | 709 H5Dclose (data_hid); |
710 H5Gclose (group_hid); | |
711 return false; | |
712 } | |
713 | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
714 if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
715 octave_H5P_DEFAULT, &nz) < 0) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
716 { |
5164 | 717 H5Dclose (data_hid); |
718 H5Gclose (group_hid); | |
719 return false; | |
720 } | |
721 | |
722 H5Dclose (data_hid); | |
723 | |
5275 | 724 SparseMatrix m (static_cast<octave_idx_type> (nr), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
725 static_cast<octave_idx_type> (nc), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
726 static_cast<octave_idx_type> (nz)); |
5164 | 727 |
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
|
728 #if 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
|
729 data_hid = H5Dopen (group_hid, "cidx", 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
|
730 #else |
5164 | 731 data_hid = H5Dopen (group_hid, "cidx"); |
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
|
732 #endif |
5164 | 733 space_hid = H5Dget_space (data_hid); |
734 rank = H5Sget_simple_extent_ndims (space_hid); | |
735 | |
736 if (rank != 2) | |
737 { | |
738 H5Sclose (space_hid); | |
739 H5Dclose (data_hid); | |
740 H5Gclose (group_hid); | |
741 return false; | |
742 } | |
743 | |
744 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank); | |
745 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank); | |
746 | |
747 H5Sget_simple_extent_dims (space_hid, hdims, maxdims); | |
748 | |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
749 if (static_cast<int> (hdims[0]) != nc + 1 |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
750 || static_cast<int> (hdims[1]) != 1) |
5164 | 751 { |
752 H5Sclose (space_hid); | |
753 H5Dclose (data_hid); | |
754 H5Gclose (group_hid); | |
755 return false; | |
756 } | |
757 | |
5351 | 758 octave_idx_type *itmp = m.xcidx (); |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
759 if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
760 octave_H5P_DEFAULT, itmp) < 0) |
5164 | 761 { |
762 H5Sclose (space_hid); | |
763 H5Dclose (data_hid); | |
764 H5Gclose (group_hid); | |
765 return false; | |
766 } | |
767 | |
768 H5Sclose (space_hid); | |
769 H5Dclose (data_hid); | |
770 | |
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
|
771 #if 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
|
772 data_hid = H5Dopen (group_hid, "ridx", 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
|
773 #else |
5164 | 774 data_hid = H5Dopen (group_hid, "ridx"); |
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
|
775 #endif |
5164 | 776 space_hid = H5Dget_space (data_hid); |
777 rank = H5Sget_simple_extent_ndims (space_hid); | |
778 | |
779 if (rank != 2) | |
780 { | |
781 H5Sclose (space_hid); | |
782 H5Dclose (data_hid); | |
783 H5Gclose (group_hid); | |
784 return false; | |
785 } | |
786 | |
787 H5Sget_simple_extent_dims (space_hid, hdims, maxdims); | |
788 | |
5322 | 789 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1) |
5164 | 790 { |
791 H5Sclose (space_hid); | |
792 H5Dclose (data_hid); | |
793 H5Gclose (group_hid); | |
794 return false; | |
795 } | |
796 | |
797 itmp = m.xridx (); | |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
798 if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
799 octave_H5P_DEFAULT, itmp) < 0) |
5164 | 800 { |
801 H5Sclose (space_hid); | |
802 H5Dclose (data_hid); | |
803 H5Gclose (group_hid); | |
804 return false; | |
805 } | |
806 | |
807 H5Sclose (space_hid); | |
808 H5Dclose (data_hid); | |
809 | |
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
|
810 #if 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
|
811 data_hid = H5Dopen (group_hid, "data", 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
|
812 #else |
5164 | 813 data_hid = H5Dopen (group_hid, "data"); |
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
|
814 #endif |
5164 | 815 space_hid = H5Dget_space (data_hid); |
816 rank = H5Sget_simple_extent_ndims (space_hid); | |
817 | |
818 if (rank != 2) | |
819 { | |
820 H5Sclose (space_hid); | |
821 H5Dclose (data_hid); | |
822 H5Gclose (group_hid); | |
823 return false; | |
824 } | |
825 | |
826 H5Sget_simple_extent_dims (space_hid, hdims, maxdims); | |
827 | |
5322 | 828 if (static_cast<int> (hdims[0]) != nz || static_cast<int> (hdims[1]) != 1) |
5164 | 829 { |
830 H5Sclose (space_hid); | |
831 H5Dclose (data_hid); | |
832 H5Gclose (group_hid); | |
833 return false; | |
834 } | |
835 | |
836 double *dtmp = m.xdata (); | |
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
|
837 |
21022
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
838 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL, |
ebc439187d29
avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents:
21013
diff
changeset
|
839 octave_H5P_DEFAULT, dtmp) >= 0 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
840 && m.indices_ok ()) |
5164 | 841 { |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
842 retval = true; |
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
843 matrix = m; |
5164 | 844 } |
845 | |
846 H5Sclose (space_hid); | |
847 H5Dclose (data_hid); | |
848 H5Gclose (group_hid); | |
849 | |
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
|
850 #else |
21102
dfcb9d74b253
Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents:
21100
diff
changeset
|
851 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
|
852 #endif |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
19863
diff
changeset
|
853 |
9469
c6edba80dfae
sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
854 return retval; |
5164 | 855 } |
5900 | 856 |
857 mxArray * | |
858 octave_sparse_matrix::as_mxArray (void) const | |
859 { | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
860 mwSize nz = nzmax (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
861 mwSize nr = rows (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
862 mwSize nc = columns (); |
5903 | 863 mxArray *retval = new mxArray (mxDOUBLE_CLASS, nr, nc, nz, mxREAL); |
864 double *pr = static_cast<double *> (retval->get_data ()); | |
14846
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
865 mwIndex *ir = retval->get_ir (); |
460a3c6d8bf1
maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents:
14770
diff
changeset
|
866 mwIndex *jc = retval->get_jc (); |
5903 | 867 |
6686 | 868 for (mwIndex i = 0; i < nz; i++) |
5903 | 869 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
870 pr[i] = matrix.data (i); |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
871 ir[i] = matrix.ridx (i); |
5903 | 872 } |
873 | |
6686 | 874 for (mwIndex i = 0; i < nc + 1; i++) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
875 jc[i] = matrix.cidx (i); |
5903 | 876 |
877 return retval; | |
5900 | 878 } |
879 | |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
880 octave_value |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
881 octave_sparse_matrix::map (unary_mapper_t umap) const |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
882 { |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
883 switch (umap) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
884 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
885 case umap_imag: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
886 return SparseMatrix (matrix.rows (), matrix.cols (), 0.0); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
887 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
888 case umap_real: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
889 case umap_conj: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
890 return matrix; |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
891 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
892 // Mappers handled specially. |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
893 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
894 case umap_ ## UMAP: \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
895 return octave_value (matrix.FCN ()) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
896 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
897 ARRAY_METHOD_MAPPER (abs, abs); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
898 |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
899 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
900 case umap_ ## UMAP: \ |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
901 return octave_value (matrix.map<TYPE> (FCN)) |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
902 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
903 ARRAY_MAPPER (acos, Complex, rc_acos); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
904 ARRAY_MAPPER (acosh, Complex, rc_acosh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
905 ARRAY_MAPPER (angle, double, ::arg); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
906 ARRAY_MAPPER (arg, double, ::arg); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
907 ARRAY_MAPPER (asin, Complex, rc_asin); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
908 ARRAY_MAPPER (asinh, double, ::asinh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
909 ARRAY_MAPPER (atan, double, ::atan); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
910 ARRAY_MAPPER (atanh, Complex, rc_atanh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
911 ARRAY_MAPPER (erf, double, ::erf); |
9835
1bb1ed717d2f
implement built-in erfinv
Jaroslav Hajek <highegg@gmail.com>
parents:
9813
diff
changeset
|
912 ARRAY_MAPPER (erfinv, double, ::erfinv); |
14770
cb85e836d035
New function: erfcinv (bug #36607)
Axel Mathéi <axel.mathei@gmail.com>
parents:
14469
diff
changeset
|
913 ARRAY_MAPPER (erfcinv, double, ::erfcinv); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
914 ARRAY_MAPPER (erfc, double, ::erfc); |
15696
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15215
diff
changeset
|
915 ARRAY_MAPPER (erfcx, double, ::erfcx); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15215
diff
changeset
|
916 ARRAY_MAPPER (erfi, double, ::erfi); |
2fac72a256ce
Add complex erf,erfc,erfcx,erfi,dawson routines from Faddeeva package.
Steven G. Johnson <stevenj@alum.mit.edu>
parents:
15215
diff
changeset
|
917 ARRAY_MAPPER (dawson, double, ::dawson); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
918 ARRAY_MAPPER (gamma, double, xgamma); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
919 ARRAY_MAPPER (lgamma, Complex, rc_lgamma); |
10414
2a8b1db1e2ca
implement built-in cbrt
Jaroslav Hajek <highegg@gmail.com>
parents:
10315
diff
changeset
|
920 ARRAY_MAPPER (cbrt, double, ::cbrt); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
921 ARRAY_MAPPER (ceil, double, ::ceil); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
922 ARRAY_MAPPER (cos, double, ::cos); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
923 ARRAY_MAPPER (cosh, double, ::cosh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
924 ARRAY_MAPPER (exp, double, ::exp); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
925 ARRAY_MAPPER (expm1, double, ::expm1); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
926 ARRAY_MAPPER (fix, double, ::fix); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
927 ARRAY_MAPPER (floor, double, ::floor); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
928 ARRAY_MAPPER (log, Complex, rc_log); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
929 ARRAY_MAPPER (log2, Complex, rc_log2); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
930 ARRAY_MAPPER (log10, Complex, rc_log10); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
931 ARRAY_MAPPER (log1p, Complex, rc_log1p); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
932 ARRAY_MAPPER (round, double, xround); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
933 ARRAY_MAPPER (roundb, double, xroundb); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
934 ARRAY_MAPPER (signum, double, ::signum); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
935 ARRAY_MAPPER (sin, double, ::sin); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
936 ARRAY_MAPPER (sinh, double, ::sinh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
937 ARRAY_MAPPER (sqrt, Complex, rc_sqrt); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
938 ARRAY_MAPPER (tan, double, ::tan); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
939 ARRAY_MAPPER (tanh, double, ::tanh); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
940 ARRAY_MAPPER (isnan, bool, xisnan); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
941 ARRAY_MAPPER (isna, bool, octave_is_NA); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
942 ARRAY_MAPPER (isinf, bool, xisinf); |
21013
7f4c6d594e3d
Finish renaming mapper function finite to isfinite.
Rik <rik@octave.org>
parents:
20955
diff
changeset
|
943 ARRAY_MAPPER (isfinite, bool, xfinite); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
944 |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
9689
diff
changeset
|
945 default: // Attempt to go via dense matrix. |
9813
8fa32b527d9a
improve & partially revert previous change
Jaroslav Hajek <highegg@gmail.com>
parents:
9812
diff
changeset
|
946 return octave_base_sparse<SparseMatrix>::map (umap); |
7503
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
947 } |
8c32f95c2639
convert mapper functions to new format
David Bateman <dbateman@free.fr>
parents:
7193
diff
changeset
|
948 } |