Mercurial > octave
annotate libinterp/corefcn/ls-hdf5.h @ 31234:a1318deb4584
sparse-xpow.cc: Improve consistency between sparse and full matrices (bug #63080)
sparse-xpow.cc: Return 0x0 matrix for empty inputs of all sizes.
Return early for all-zeros matrix with positive power.
Add FIXME for all-zeros matrix with negative power.
Add BISTs.
author | Arun Giridhar <arungiridhar@gmail.com> |
---|---|
date | Tue, 20 Sep 2022 09:00:02 -0400 |
parents | 83f9f8bda883 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30155
diff
changeset
|
3 // Copyright (C) 2003-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
4634 | 25 |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20264
diff
changeset
|
26 #if ! defined (octave_ls_hdf5_h) |
4634 | 27 #define octave_ls_hdf5_h 1 |
28 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
29 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21211
diff
changeset
|
30 |
25438
cb1606f78f6b
prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents:
25054
diff
changeset
|
31 #include <iosfwd> |
23442
53f5f8231c37
allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents:
23440
diff
changeset
|
32 |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
33 #include "oct-hdf5-types.h" |
23442
53f5f8231c37
allow most header files to be compiled separately
John W. Eaton <jwe@octave.org>
parents:
23440
diff
changeset
|
34 #include "ov.h" |
8676 | 35 |
4634 | 36 // first, we need to define our own dummy stream subclass, since |
37 // HDF5 needs to do its own file i/o | |
38 | |
39 // hdf5_fstreambase is used for both input and output streams, modeled | |
40 // on the fstreambase class in <fstream.h> | |
41 | |
42 class hdf5_fstreambase : virtual public std::ios | |
43 { | |
44 public: | |
45 | |
46 // HDF5 uses an "id" to refer to an open file | |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
47 octave_hdf5_id file_id; |
4634 | 48 |
49 // keep track of current item index in the file | |
50 int current_item; | |
51 | |
11584
cda4aa780d58
Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11523
diff
changeset
|
52 hdf5_fstreambase () : file_id (-1), current_item () { } |
4634 | 53 |
6760 | 54 ~hdf5_fstreambase () { close (); } |
55 | |
30346
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30155
diff
changeset
|
56 OCTINTERP_API hdf5_fstreambase (const char *name, int mode, |
91c6288781ba
maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
30155
diff
changeset
|
57 int /* prot */ = 0); |
4634 | 58 |
29233
665c9ed14c97
Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27932
diff
changeset
|
59 OCTINTERP_API void close (void); |
4634 | 60 |
29233
665c9ed14c97
Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27932
diff
changeset
|
61 OCTINTERP_API void open (const char *name, int mode, int); |
25693
038fb01854a0
Save to hdf5 file with non-ASCII chars on Windows.
Markus Mützel <markus.muetzel@gmx.de>
parents:
25438
diff
changeset
|
62 |
29233
665c9ed14c97
Set API tags in files in libinterp/corefcn (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27932
diff
changeset
|
63 OCTINTERP_API void open_create (const char *name, int mode); |
4634 | 64 }; |
65 | |
66 // input and output streams, subclassing istream and ostream | |
67 // so that we can pass them for stream parameters in the functions below. | |
68 | |
69 class hdf5_ifstream : public hdf5_fstreambase, public std::istream | |
70 { | |
71 public: | |
72 | |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23470
diff
changeset
|
73 hdf5_ifstream () : hdf5_fstreambase (), std::istream (nullptr) { } |
4634 | 74 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21355
diff
changeset
|
75 hdf5_ifstream (const char *name, int mode = std::ios::in | std::ios::binary, |
10313 | 76 int prot = 0) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23470
diff
changeset
|
77 : hdf5_fstreambase (name, mode, prot), std::istream (nullptr) { } |
4634 | 78 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21355
diff
changeset
|
79 void open (const char *name, int mode = std::ios::in | std::ios::binary, |
10313 | 80 int prot = 0) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
81 { hdf5_fstreambase::open (name, mode, prot); } |
4634 | 82 }; |
83 | |
84 class hdf5_ofstream : public hdf5_fstreambase, public std::ostream | |
85 { | |
86 public: | |
87 | |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23470
diff
changeset
|
88 hdf5_ofstream () : hdf5_fstreambase (), std::ostream (nullptr) { } |
4634 | 89 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21355
diff
changeset
|
90 hdf5_ofstream (const char *name, int mode = std::ios::out | std::ios::binary, |
10313 | 91 int prot = 0) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23470
diff
changeset
|
92 : hdf5_fstreambase (name, mode, prot), std::ostream (nullptr) { } |
4634 | 93 |
21662
5b9868c2e212
maint: Octave coding convention cleanups.
Rik <rik@octave.org>
parents:
21355
diff
changeset
|
94 void open (const char *name, int mode = std::ios::out | std::ios::binary, |
10313 | 95 int prot = 0) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 { hdf5_fstreambase::open (name, mode, prot); } |
4634 | 97 }; |
98 | |
4687 | 99 // Callback data structure for passing data to hdf5_read_next_data, below. |
100 | |
27932
b018f553fd85
maint: Use Octave coding conventions in libinterp/
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
101 struct hdf5_callback_data |
4687 | 102 { |
30155
14b098a6ba46
maint: Use public: qualifier in structs that are really classes.
Rik <rik@octave.org>
parents:
29359
diff
changeset
|
103 public: |
4687 | 104 hdf5_callback_data (void) |
105 : name (), global (false), tc (), doc () { } | |
106 | |
107 // the following fields are set by hdf5_read_data on successful return: | |
108 | |
109 // the name of the variable | |
110 std::string name; | |
111 | |
112 // whether it is global | |
113 bool global; | |
114 | |
115 // the value of the variable, in Octave form | |
116 octave_value tc; | |
117 | |
118 // a documentation string (NULL if none) | |
119 std::string doc; | |
120 }; | |
121 | |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
122 extern OCTINTERP_API octave_hdf5_id |
21355
28d9bce20aa7
eliminate HAVE_HDF5 macros from public header files
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
123 save_type_to_hdf5 (save_type st); |
4687 | 124 |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
125 extern OCTINTERP_API octave_hdf5_id |
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
126 hdf5_make_complex_type (octave_hdf5_id num_type); |
4687 | 127 |
6693 | 128 extern OCTINTERP_API bool |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
129 hdf5_types_compatible (octave_hdf5_id t1, octave_hdf5_id t2); |
4687 | 130 |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
131 extern OCTINTERP_API octave_hdf5_err |
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
132 hdf5_read_next_data (octave_hdf5_id group_id, const char *name, void *dv); |
4687 | 133 |
22028
5c949eecb6dd
use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents:
22022
diff
changeset
|
134 extern OCTINTERP_API octave_hdf5_err |
23449
c763214a8260
maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents:
23442
diff
changeset
|
135 hdf5_h5g_iterate (octave_hdf5_id loc_id, const char *name, int *idx, |
22028
5c949eecb6dd
use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents:
22022
diff
changeset
|
136 void *operator_data); |
5c949eecb6dd
use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents:
22022
diff
changeset
|
137 |
6693 | 138 extern OCTINTERP_API bool |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
139 add_hdf5_data (octave_hdf5_id loc_id, const octave_value& tc, |
10313 | 140 const std::string& name, const std::string& doc, |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23449
diff
changeset
|
141 bool mark_global, bool save_as_floats); |
4687 | 142 |
6693 | 143 extern OCTINTERP_API int |
23440
f15f0d8b78c8
pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents:
23433
diff
changeset
|
144 save_hdf5_empty (octave_hdf5_id loc_id, const char *name, const dim_vector& d); |
4805 | 145 |
6693 | 146 extern OCTINTERP_API int |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
147 load_hdf5_empty (octave_hdf5_id loc_id, const char *name, dim_vector& d); |
4805 | 148 |
6693 | 149 extern OCTINTERP_API std::string |
4687 | 150 read_hdf5_data (std::istream& is, const std::string& filename, bool& global, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 octave_value& tc, std::string& doc, |
17709
5415a9cd61d4
Implement faster partial loading of HDF5 files.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
152 const string_vector& argv, int argv_idx, int argc); |
4634 | 153 |
6693 | 154 extern OCTINTERP_API bool |
4634 | 155 save_hdf5_data (std::ostream& os, const octave_value& tc, |
10313 | 156 const std::string& name, const std::string& doc, |
23470
a41fdb801db6
use mark_global and mark_persistent consistently
John W. Eaton <jwe@octave.org>
parents:
23449
diff
changeset
|
157 bool mark_global, bool save_as_floats); |
4634 | 158 |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
159 extern OCTINTERP_API bool |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
160 hdf5_check_attr (octave_hdf5_id loc_id, const char *attr_name); |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
161 |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
162 extern OCTINTERP_API bool |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
163 hdf5_get_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id, |
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
164 const char *attr_name, void *buf); |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
165 |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
166 extern OCTINTERP_API octave_hdf5_err |
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
167 hdf5_add_attr (octave_hdf5_id loc_id, const char *attr_name); |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
168 |
22028
5c949eecb6dd
use int64_t for octave_hdf5_id (bug #47858)
Stefan Miereis <stefan.miereis@gmx.de>
parents:
22022
diff
changeset
|
169 |
20264
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
170 extern OCTINTERP_API octave_hdf5_err |
bfe66db8addb
don't include hdf5.h or use HDF5 typedefs in public header files (bug #43180)
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
171 hdf5_add_scalar_attr (octave_hdf5_id loc_id, octave_hdf5_id type_id, |
11176
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
172 const char *attr_name, void *buf); |
2271261f088a
Address precision issue in ranges saved to HDF5 files
David Bateman <dbateman@free.fr>
parents:
10313
diff
changeset
|
173 |
4634 | 174 #endif |