|
7 | 7 | clear data2hdf h52data opt; |
8 | 8 |
|
9 | 9 | opt.releaseid = 0; |
| 10 | +opt.isoctave = 0; |
10 | 11 | vers = ver('MATLAB'); |
11 | 12 | if (~isempty(vers)) |
12 | 13 | opt.releaseid = datenum(vers(1).Date); |
| 14 | + opt.skipempty = (opt.releaseid < datenum('1-Jan-2015')); |
| 15 | +else |
| 16 | + opt.isoctave = 1; |
| 17 | + opt.skipempty = 0; |
13 | 18 | end |
14 | | -opt.skipempty = (opt.releaseid < datenum('1-Jan-2015')); |
15 | 19 |
|
16 | 20 | testequal = @isequal; |
17 | 21 | if (exist('isequaln', 'builtin')) |
|
113 | 117 | testequal(data2hdf, h52data.data2hdf); |
114 | 118 |
|
115 | 119 | fprintf(1, '\n%%=================================================\n'); |
116 | | -fprintf(1, '%% a 3-D array in annotated array form (EasyH5 1.9 or earlier)\n'); |
| 120 | +fprintf(1, '%% a 3-D array in annotated array form (JSONLab 1.9 or earlier)\n'); |
117 | 121 | fprintf(1, '%%=================================================\n\n'); |
118 | 122 |
|
119 | 123 | data2hdf = reshape(1:(2 * 4 * 6), [2, 4, 6]); |
120 | 124 | saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
121 | 125 | h52data = loadh5('test.h5'); |
122 | 126 | testequal(data2hdf, h52data.data2hdf); |
123 | 127 |
|
124 | | -fprintf(1, '\n%%=================================================\n'); |
125 | | -fprintf(1, '%% a complex number\n'); |
126 | | -fprintf(1, '%%=================================================\n\n'); |
| 128 | +if (~opt.isoctave) |
127 | 129 |
|
128 | | -data2hdf = 1 + 2i; |
129 | | -saveh5(data2hdf, 'test.h5'); |
130 | | -h52data = loadh5('test.h5'); |
131 | | -testequal(data2hdf, h52data.data2hdf); |
| 130 | + fprintf(1, '\n%%=================================================\n'); |
| 131 | + fprintf(1, '%% a complex number\n'); |
| 132 | + fprintf(1, '%%=================================================\n\n'); |
132 | 133 |
|
133 | | -fprintf(1, '\n%%=================================================\n'); |
134 | | -fprintf(1, '%% a complex matrix\n'); |
135 | | -fprintf(1, '%%=================================================\n\n'); |
| 134 | + data2hdf = 1 + 2i; |
| 135 | + saveh5(data2hdf, 'test.h5'); |
| 136 | + h52data = loadh5('test.h5'); |
| 137 | + testequal(data2hdf, h52data.data2hdf); |
136 | 138 |
|
137 | | -data2hdf = magic(6); |
138 | | -data2hdf = data2hdf(:, 1:3) + data2hdf(:, 4:6) * 1i; |
139 | | -saveh5(data2hdf, 'test.h5'); |
140 | | -h52data = loadh5('test.h5'); |
141 | | -testequal(data2hdf, h52data.data2hdf); |
| 139 | + fprintf(1, '\n%%=================================================\n'); |
| 140 | + fprintf(1, '%% a complex matrix\n'); |
| 141 | + fprintf(1, '%%=================================================\n\n'); |
| 142 | + |
| 143 | + data2hdf = magic(6); |
| 144 | + data2hdf = data2hdf(:, 1:3) + data2hdf(:, 4:6) * 1i; |
| 145 | + saveh5(data2hdf, 'test.h5'); |
| 146 | + h52data = loadh5('test.h5'); |
| 147 | + testequal(data2hdf, h52data.data2hdf); |
| 148 | + |
| 149 | +end |
142 | 150 |
|
143 | 151 | fprintf(1, '\n%%=================================================\n'); |
144 | 152 | fprintf(1, '%% MATLAB special constants\n'); |
|
153 | 161 | fprintf(1, '%% a real sparse matrix\n'); |
154 | 162 | fprintf(1, '%%=================================================\n\n'); |
155 | 163 |
|
156 | | -data2hdf = sprand(10, 10, 0.1); |
157 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
158 | | -h52data = loadh5('test.h5'); |
159 | | -testequal(data2hdf, h52data.data2hdf); |
| 164 | +if (~opt.isoctave) |
160 | 165 |
|
161 | | -fprintf(1, '\n%%=================================================\n'); |
162 | | -fprintf(1, '%% a complex sparse matrix\n'); |
163 | | -fprintf(1, '%%=================================================\n\n'); |
164 | | - |
165 | | -data2hdf = data2hdf - data2hdf * 1i; |
166 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
167 | | -h52data = loadh5('test.h5'); |
168 | | -testequal(data2hdf, h52data.data2hdf); |
| 166 | + data2hdf = sprand(10, 10, 0.1); |
| 167 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 168 | + h52data = loadh5('test.h5'); |
| 169 | + testequal(data2hdf, h52data.data2hdf); |
169 | 170 |
|
170 | | -fprintf(1, '\n%%=================================================\n'); |
171 | | -fprintf(1, '%% an all-zero sparse matrix\n'); |
172 | | -fprintf(1, '%%=================================================\n\n'); |
| 171 | + fprintf(1, '\n%%=================================================\n'); |
| 172 | + fprintf(1, '%% a complex sparse matrix\n'); |
| 173 | + fprintf(1, '%%=================================================\n\n'); |
173 | 174 |
|
174 | | -data2hdf = sparse(2, 3); |
175 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
176 | | -h52data = loadh5('test.h5'); |
177 | | -if (~opt.skipempty) |
| 175 | + data2hdf = data2hdf - data2hdf * 1i; |
| 176 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 177 | + h52data = loadh5('test.h5'); |
178 | 178 | testequal(data2hdf, h52data.data2hdf); |
179 | | -end |
180 | 179 |
|
181 | | -fprintf(1, '\n%%=================================================\n'); |
182 | | -fprintf(1, '%% an empty sparse matrix\n'); |
183 | | -fprintf(1, '%%=================================================\n\n'); |
| 180 | + fprintf(1, '\n%%=================================================\n'); |
| 181 | + fprintf(1, '%% an all-zero sparse matrix\n'); |
| 182 | + fprintf(1, '%%=================================================\n\n'); |
| 183 | + |
| 184 | + data2hdf = sparse(2, 3); |
| 185 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 186 | + h52data = loadh5('test.h5'); |
| 187 | + if (~opt.skipempty) |
| 188 | + testequal(data2hdf, h52data.data2hdf); |
| 189 | + end |
| 190 | + |
| 191 | + fprintf(1, '\n%%=================================================\n'); |
| 192 | + fprintf(1, '%% an empty sparse matrix\n'); |
| 193 | + fprintf(1, '%%=================================================\n\n'); |
| 194 | + |
| 195 | + data2hdf = sparse([]); |
| 196 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 197 | + h52data = loadh5('test.h5'); |
| 198 | + if (~opt.skipempty) |
| 199 | + testequal(data2hdf, h52data.data2hdf); |
| 200 | + end |
184 | 201 |
|
185 | | -data2hdf = sparse([]); |
186 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
187 | | -h52data = loadh5('test.h5'); |
188 | | -if (~opt.skipempty) |
189 | | - testequal(data2hdf, h52data.data2hdf); |
190 | 202 | end |
191 | 203 |
|
192 | 204 | fprintf(1, '\n%%=================================================\n'); |
|
211 | 223 | testequal(data2hdf, h52data.data2hdf); |
212 | 224 | end |
213 | 225 |
|
214 | | -fprintf(1, '\n%%=================================================\n'); |
215 | | -fprintf(1, '%% a sparse real column vector\n'); |
216 | | -fprintf(1, '%%=================================================\n\n'); |
| 226 | +if (~opt.isoctave) |
217 | 227 |
|
218 | | -data2hdf = sparse([0, 3, 0, 1, 4]'); |
219 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
220 | | -h52data = loadh5('test.h5'); |
221 | | -testequal(data2hdf, h52data.data2hdf); |
| 228 | + fprintf(1, '\n%%=================================================\n'); |
| 229 | + fprintf(1, '%% a sparse real column vector\n'); |
| 230 | + fprintf(1, '%%=================================================\n\n'); |
222 | 231 |
|
223 | | -fprintf(1, '\n%%=================================================\n'); |
224 | | -fprintf(1, '%% a sparse complex column vector\n'); |
225 | | -fprintf(1, '%%=================================================\n\n'); |
| 232 | + data2hdf = sparse([0, 3, 0, 1, 4]'); |
| 233 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 234 | + h52data = loadh5('test.h5'); |
| 235 | + testequal(data2hdf, h52data.data2hdf); |
226 | 236 |
|
227 | | -data2hdf = data2hdf - 1i * data2hdf; |
228 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
229 | | -h52data = loadh5('test.h5'); |
230 | | -testequal(data2hdf, h52data.data2hdf); |
| 237 | + fprintf(1, '\n%%=================================================\n'); |
| 238 | + fprintf(1, '%% a sparse complex column vector\n'); |
| 239 | + fprintf(1, '%%=================================================\n\n'); |
231 | 240 |
|
232 | | -fprintf(1, '\n%%=================================================\n'); |
233 | | -fprintf(1, '%% a sparse real row vector\n'); |
234 | | -fprintf(1, '%%=================================================\n\n'); |
| 241 | + data2hdf = data2hdf - 1i * data2hdf; |
| 242 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 243 | + h52data = loadh5('test.h5'); |
| 244 | + testequal(data2hdf, h52data.data2hdf); |
235 | 245 |
|
236 | | -data2hdf = sparse([0, 3, 0, 1, 4]); |
237 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
238 | | -h52data = loadh5('test.h5'); |
239 | | -testequal(data2hdf, h52data.data2hdf); |
| 246 | + fprintf(1, '\n%%=================================================\n'); |
| 247 | + fprintf(1, '%% a sparse real row vector\n'); |
| 248 | + fprintf(1, '%%=================================================\n\n'); |
240 | 249 |
|
241 | | -fprintf(1, '\n%%=================================================\n'); |
242 | | -fprintf(1, '%% a sparse complex row vector\n'); |
243 | | -fprintf(1, '%%=================================================\n\n'); |
| 250 | + data2hdf = sparse([0, 3, 0, 1, 4]); |
| 251 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 252 | + h52data = loadh5('test.h5'); |
| 253 | + testequal(data2hdf, h52data.data2hdf); |
244 | 254 |
|
245 | | -data2hdf = data2hdf - 1i * data2hdf; |
246 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
247 | | -h52data = loadh5('test.h5'); |
248 | | -testequal(data2hdf, h52data.data2hdf); |
| 255 | + fprintf(1, '\n%%=================================================\n'); |
| 256 | + fprintf(1, '%% a sparse complex row vector\n'); |
| 257 | + fprintf(1, '%%=================================================\n\n'); |
| 258 | + |
| 259 | + data2hdf = data2hdf - 1i * data2hdf; |
| 260 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 261 | + h52data = loadh5('test.h5'); |
| 262 | + testequal(data2hdf, h52data.data2hdf); |
| 263 | + |
| 264 | +end |
249 | 265 |
|
250 | 266 | fprintf(1, '\n%%=================================================\n'); |
251 | 267 | fprintf(1, '%% a structure\n'); |
|
281 | 297 | h52data = loadh5('test.h5', 'regroup', 1); |
282 | 298 | testequal(data2hdf, h52data.data2hdf); |
283 | 299 |
|
284 | | -fprintf(1, '\n%%=================================================\n'); |
285 | | -fprintf(1, '%% a function handle\n'); |
286 | | -fprintf(1, '%%=================================================\n\n'); |
| 300 | +if (~opt.isoctave) |
287 | 301 |
|
288 | | -data2hdf = @(x) x + 1; |
289 | | -saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
290 | | -h52data = loadh5('test.h5'); |
291 | | -testequal(data2hdf, h52data.data2hdf); |
| 302 | + fprintf(1, '\n%%=================================================\n'); |
| 303 | + fprintf(1, '%% a function handle\n'); |
| 304 | + fprintf(1, '%%=================================================\n\n'); |
| 305 | + |
| 306 | + data2hdf = @(x) x + 1; |
| 307 | + saveh5(data2hdf, 'test.h5'); % nestarray for 4-D or above is not working |
| 308 | + h52data = loadh5('test.h5'); |
| 309 | + testequal(data2hdf, h52data.data2hdf); |
| 310 | + |
| 311 | +end |
292 | 312 |
|
293 | 313 | fprintf(1, '\n%%=================================================\n'); |
294 | 314 | fprintf(1, '%% a 2D cell array\n'); |
|
0 commit comments