GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-bool-sparse.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1998-2024 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <istream>
31 #include <ostream>
32 #include <vector>
33 
34 #include "dim-vector.h"
35 
36 #include "mxarray.h"
37 #include "ov-base.h"
38 #include "ov-scalar.h"
39 #include "ov-bool.h"
40 #include "ov-bool-mat.h"
41 #include "errwarn.h"
42 #include "ops.h"
43 #include "oct-locbuf.h"
44 
45 #include "oct-hdf5.h"
46 
47 #include "ov-re-sparse.h"
48 #include "ov-cx-sparse.h"
49 #include "ov-bool-sparse.h"
50 
51 #include "ov-base-sparse.h"
52 #include "ov-base-sparse.cc"
53 
55 
57  "sparse bool matrix", "logical");
58 
59 static octave_base_value *
60 default_numeric_conversion_function (const octave_base_value& a)
61 {
63  = dynamic_cast<const octave_sparse_bool_matrix&> (a);
64 
65  return
67 }
68 
71 {
72  return octave_base_value::type_conv_info (default_numeric_conversion_function,
74 }
75 
76 double
78 {
79  if (isempty ())
80  err_invalid_conversion ("bool sparse matrix", "real scalar");
81 
82  if (numel () > 1)
83  warn_implicit_conversion ("Octave:array-to-scalar",
84  "bool sparse matrix", "real scalar");
85 
86  return matrix(0, 0);
87 }
88 
89 Complex
91 {
92  if (rows () == 0 || columns () == 0)
93  err_invalid_conversion ("bool sparse matrix", "complex scalar");
94 
95  if (numel () > 1)
96  warn_implicit_conversion ("Octave:array-to-scalar",
97  "bool sparse matrix", "complex scalar");
98 
99  return Complex (matrix(0, 0), 0);
100 }
101 
104  char type) const
105 {
107  return tmp.convert_to_str (pad, force, type);
108 }
109 
110 // FIXME: These are inefficient ways of creating full matrices
111 
112 Matrix
114 {
115  return Matrix (matrix.matrix_value ());
116 }
117 
120 {
121  return ComplexMatrix (matrix.matrix_value ());
122 }
123 
126 {
128 }
129 
130 NDArray
132 {
133  return NDArray (Matrix (matrix.matrix_value ()));
134 }
135 
138 {
139  charNDArray retval (dims (), 0);
140  octave_idx_type nc = matrix.cols ();
141  octave_idx_type nr = matrix.rows ();
142 
143  for (octave_idx_type j = 0; j < nc; j++)
144  for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
145  retval(matrix.ridx (i) + nr * j) = static_cast<char> (matrix.data (i));
146 
147  return retval;
148 }
149 
152 {
153  return matrix.matrix_value ();
154 }
155 
158 {
159  return boolNDArray (matrix.matrix_value ());
160 }
161 
164 {
165  return SparseMatrix (this->matrix);
166 }
167 
170 {
171  return SparseComplexMatrix (this->matrix);
172 }
173 
176 {
177  return SparseMatrix (this->matrix);
178 }
179 
180 bool
182 {
183  dim_vector dv = this->dims ();
184  if (dv.ndims () < 1)
185  return false;
186 
187  // Ensure that additional memory is deallocated
189 
190  octave_idx_type nr = dv(0);
191  octave_idx_type nc = dv(1);
192  octave_idx_type nz = nnz ();
193 
194  // For compatiblity, indices are always saved with 4 bytes
195 #if OCTAVE_SIZEOF_IDX_TYPE == OCTAVE_SIZEOF_INT
196  if (nr < 0 || nc < 0 || nz < 0)
197  return false;
198 #else
200  if (nr < 0 || nr > max_val || nc < 0 || nc > max_val
201  || nz < 0 || nz > max_val)
202  return false;
203 #endif
204 
205  int32_t itmp;
206  // Use negative value for ndims to be consistent with other formats
207  itmp = -2;
208  os.write (reinterpret_cast<char *> (&itmp), 4);
209 
210  itmp = nr;
211  os.write (reinterpret_cast<char *> (&itmp), 4);
212 
213  itmp = nc;
214  os.write (reinterpret_cast<char *> (&itmp), 4);
215 
216  itmp = nz;
217  os.write (reinterpret_cast<char *> (&itmp), 4);
218 
219  // add one to the printed indices to go from
220  // zero-based to one-based arrays
221  for (int i = 0; i < nc+1; i++)
222  {
223  octave_quit ();
224  itmp = matrix.cidx (i);
225  os.write (reinterpret_cast<char *> (&itmp), 4);
226  }
227 
228  for (int i = 0; i < nz; i++)
229  {
230  octave_quit ();
231  itmp = matrix.ridx (i);
232  os.write (reinterpret_cast<char *> (&itmp), 4);
233  }
234 
235  OCTAVE_LOCAL_BUFFER (char, htmp, nz);
236 
237  for (int i = 0; i < nz; i++)
238  htmp[i] = (matrix.data (i) ? 1 : 0);
239 
240  os.write (htmp, nz);
241 
242  return true;
243 }
244 
245 bool
246 octave_sparse_bool_matrix::load_binary (std::istream& is, bool swap,
248 {
249  int32_t nz, nc, nr, tmp;
250  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
251  return false;
252 
253  if (swap)
254  swap_bytes<4> (&tmp);
255 
256  if (tmp != -2)
257  error ("load: only 2-D sparse matrices are supported");
258 
259  if (! is.read (reinterpret_cast<char *> (&nr), 4))
260  return false;
261  if (! is.read (reinterpret_cast<char *> (&nc), 4))
262  return false;
263  if (! is.read (reinterpret_cast<char *> (&nz), 4))
264  return false;
265 
266  if (swap)
267  {
268  swap_bytes<4> (&nr);
269  swap_bytes<4> (&nc);
270  swap_bytes<4> (&nz);
271  }
272 
273  SparseBoolMatrix m (static_cast<octave_idx_type> (nr),
274  static_cast<octave_idx_type> (nc),
275  static_cast<octave_idx_type> (nz));
276 
277  for (int i = 0; i < nc+1; i++)
278  {
279  octave_quit ();
280  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
281  return false;
282  if (swap)
283  swap_bytes<4> (&tmp);
284  m.cidx (i) = tmp;
285  }
286 
287  for (int i = 0; i < nz; i++)
288  {
289  octave_quit ();
290  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
291  return false;
292  if (swap)
293  swap_bytes<4> (&tmp);
294  m.ridx (i) = tmp;
295  }
296 
297  if (! is)
298  return false;
299 
300  OCTAVE_LOCAL_BUFFER (char, htmp, nz);
301 
302  if (! is.read (htmp, nz))
303  return false;
304 
305  for (int i = 0; i < nz; i++)
306  m.data(i) = (htmp[i] ? 1 : 0);
307 
308  if (! m.indices_ok ())
309  return false;
310 
311  matrix = m;
312 
313  return true;
314 }
315 
316 bool
318  bool)
319 {
320  bool retval = false;
321 
322 #if defined (HAVE_HDF5)
323 
324  dim_vector dv = dims ();
325  int empty = save_hdf5_empty (loc_id, name, dv);
326  if (empty)
327  return (empty > 0);
328 
329  // Ensure that additional memory is deallocated
331 #if defined (HAVE_HDF5_18)
332  hid_t group_hid = H5Gcreate (loc_id, name, octave_H5P_DEFAULT,
334 #else
335  hid_t group_hid = H5Gcreate (loc_id, name, 0);
336 #endif
337  if (group_hid < 0)
338  return false;
339 
340  hid_t space_hid, data_hid;
341  space_hid = data_hid = -1;
343  octave_idx_type tmp;
344  hsize_t hdims[2];
345 
346  space_hid = H5Screate_simple (0, hdims, nullptr);
347  if (space_hid < 0)
348  {
349  H5Gclose (group_hid);
350  return false;
351  }
352 #if defined (HAVE_HDF5_18)
353  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid,
356 #else
357  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid,
359 #endif
360  if (data_hid < 0)
361  {
362  H5Sclose (space_hid);
363  H5Gclose (group_hid);
364  return false;
365  }
366 
367  tmp = m.rows ();
368  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL,
369  octave_H5S_ALL, octave_H5P_DEFAULT, &tmp) >= 0;
370  H5Dclose (data_hid);
371  if (! retval)
372  {
373  H5Sclose (space_hid);
374  H5Gclose (group_hid);
375  return false;
376  }
377 
378 #if defined (HAVE_HDF5_18)
379  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid,
382 #else
383  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid,
385 #endif
386  if (data_hid < 0)
387  {
388  H5Sclose (space_hid);
389  H5Gclose (group_hid);
390  return false;
391  }
392 
393  tmp = m.cols ();
394  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
395  octave_H5P_DEFAULT, &tmp) >= 0;
396  H5Dclose (data_hid);
397  if (! retval)
398  {
399  H5Sclose (space_hid);
400  H5Gclose (group_hid);
401  return false;
402  }
403 
404 #if defined (HAVE_HDF5_18)
405  data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, space_hid,
408 #else
409  data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, space_hid,
411 #endif
412  if (data_hid < 0)
413  {
414  H5Sclose (space_hid);
415  H5Gclose (group_hid);
416  return false;
417  }
418 
419  tmp = m.nnz ();
420  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
421  octave_H5P_DEFAULT, &tmp) >= 0;
422  H5Dclose (data_hid);
423  if (! retval)
424  {
425  H5Sclose (space_hid);
426  H5Gclose (group_hid);
427  return false;
428  }
429 
430  H5Sclose (space_hid);
431 
432  hdims[0] = m.cols () + 1;
433  hdims[1] = 1;
434 
435  space_hid = H5Screate_simple (2, hdims, nullptr);
436 
437  if (space_hid < 0)
438  {
439  H5Gclose (group_hid);
440  return false;
441  }
442 
443 #if defined (HAVE_HDF5_18)
444  data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, space_hid,
447 #else
448  data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, space_hid,
450 #endif
451  if (data_hid < 0)
452  {
453  H5Sclose (space_hid);
454  H5Gclose (group_hid);
455  return false;
456  }
457 
458  octave_idx_type *itmp = m.xcidx ();
459  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
460  octave_H5P_DEFAULT, itmp) >= 0;
461  H5Dclose (data_hid);
462  if (! retval)
463  {
464  H5Sclose (space_hid);
465  H5Gclose (group_hid);
466  return false;
467  }
468 
469  H5Sclose (space_hid);
470 
471  hdims[0] = m.nnz ();
472  hdims[1] = 1;
473 
474  space_hid = H5Screate_simple (2, hdims, nullptr);
475 
476  if (space_hid < 0)
477  {
478  H5Gclose (group_hid);
479  return false;
480  }
481 
482 #if defined (HAVE_HDF5_18)
483  data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, space_hid,
486 #else
487  data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, space_hid,
489 #endif
490  if (data_hid < 0)
491  {
492  H5Sclose (space_hid);
493  H5Gclose (group_hid);
494  return false;
495  }
496 
497  itmp = m.xridx ();
498  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
499  octave_H5P_DEFAULT, itmp) >= 0;
500  H5Dclose (data_hid);
501  if (! retval)
502  {
503  H5Sclose (space_hid);
504  H5Gclose (group_hid);
505  return false;
506  }
507 
508 #if defined (HAVE_HDF5_18)
509  data_hid = H5Dcreate (group_hid, "data", H5T_NATIVE_HBOOL, space_hid,
512 #else
513  data_hid = H5Dcreate (group_hid, "data", H5T_NATIVE_HBOOL, space_hid,
515 #endif
516  if (data_hid < 0)
517  {
518  H5Sclose (space_hid);
519  H5Gclose (group_hid);
520  return false;
521  }
522 
523  OCTAVE_LOCAL_BUFFER (hbool_t, htmp, m.nnz ());
524  for (int i = 0; i < m.nnz (); i++)
525  htmp[i] = m.xdata(i);
526 
527  retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, octave_H5S_ALL, octave_H5S_ALL,
528  octave_H5P_DEFAULT, htmp) >= 0;
529  H5Dclose (data_hid);
530  H5Sclose (space_hid);
531  H5Gclose (group_hid);
532 
533 #else
534  octave_unused_parameter (loc_id);
535  octave_unused_parameter (name);
536 
537  warn_save ("hdf5");
538 #endif
539 
540  return retval;
541 }
542 
543 bool
545 {
546  bool retval = false;
547 
548 #if defined (HAVE_HDF5)
549 
550  octave_idx_type nr, nc, nz;
551  hid_t group_hid, data_hid, space_hid;
552  hsize_t rank;
553 
554  dim_vector dv;
555  int empty = load_hdf5_empty (loc_id, name, dv);
556  if (empty > 0)
557  matrix.resize (dv);
558  if (empty)
559  return (empty > 0);
560 
561 #if defined (HAVE_HDF5_18)
562  group_hid = H5Gopen (loc_id, name, octave_H5P_DEFAULT);
563 #else
564  group_hid = H5Gopen (loc_id, name);
565 #endif
566  if (group_hid < 0) return false;
567 
568 #if defined (HAVE_HDF5_18)
569  data_hid = H5Dopen (group_hid, "nr", octave_H5P_DEFAULT);
570 #else
571  data_hid = H5Dopen (group_hid, "nr");
572 #endif
573  space_hid = H5Dget_space (data_hid);
574  rank = H5Sget_simple_extent_ndims (space_hid);
575 
576  if (rank != 0)
577  {
578  H5Dclose (data_hid);
579  H5Gclose (group_hid);
580  return false;
581  }
582 
583  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
584  octave_H5P_DEFAULT, &nr)
585  < 0)
586  {
587  H5Dclose (data_hid);
588  H5Gclose (group_hid);
589  return false;
590  }
591 
592  H5Dclose (data_hid);
593 
594 #if defined (HAVE_HDF5_18)
595  data_hid = H5Dopen (group_hid, "nc", octave_H5P_DEFAULT);
596 #else
597  data_hid = H5Dopen (group_hid, "nc");
598 #endif
599  space_hid = H5Dget_space (data_hid);
600  rank = H5Sget_simple_extent_ndims (space_hid);
601 
602  if (rank != 0)
603  {
604  H5Dclose (data_hid);
605  H5Gclose (group_hid);
606  return false;
607  }
608 
609  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
610  octave_H5P_DEFAULT, &nc)
611  < 0)
612  {
613  H5Dclose (data_hid);
614  H5Gclose (group_hid);
615  return false;
616  }
617 
618  H5Dclose (data_hid);
619 
620 #if defined (HAVE_HDF5_18)
621  data_hid = H5Dopen (group_hid, "nz", octave_H5P_DEFAULT);
622 #else
623  data_hid = H5Dopen (group_hid, "nz");
624 #endif
625  space_hid = H5Dget_space (data_hid);
626  rank = H5Sget_simple_extent_ndims (space_hid);
627 
628  if (rank != 0)
629  {
630  H5Dclose (data_hid);
631  H5Gclose (group_hid);
632  return false;
633  }
634 
635  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
636  octave_H5P_DEFAULT, &nz)
637  < 0)
638  {
639  H5Dclose (data_hid);
640  H5Gclose (group_hid);
641  return false;
642  }
643 
644  H5Dclose (data_hid);
645 
646  SparseBoolMatrix m (static_cast<octave_idx_type> (nr),
647  static_cast<octave_idx_type> (nc),
648  static_cast<octave_idx_type> (nz));
649 
650 #if defined (HAVE_HDF5_18)
651  data_hid = H5Dopen (group_hid, "cidx", octave_H5P_DEFAULT);
652 #else
653  data_hid = H5Dopen (group_hid, "cidx");
654 #endif
655  space_hid = H5Dget_space (data_hid);
656  rank = H5Sget_simple_extent_ndims (space_hid);
657 
658  if (rank != 2)
659  {
660  H5Sclose (space_hid);
661  H5Dclose (data_hid);
662  H5Gclose (group_hid);
663  return false;
664  }
665 
666  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
667  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
668 
669  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
670 
671  if (static_cast<int> (hdims[0]) != nc + 1
672  || static_cast<int> (hdims[1]) != 1)
673  {
674  H5Sclose (space_hid);
675  H5Dclose (data_hid);
676  H5Gclose (group_hid);
677  return false;
678  }
679 
680  octave_idx_type *itmp = m.xcidx ();
681  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
682  octave_H5P_DEFAULT, itmp)
683  < 0)
684  {
685  H5Sclose (space_hid);
686  H5Dclose (data_hid);
687  H5Gclose (group_hid);
688  return false;
689  }
690 
691  H5Sclose (space_hid);
692  H5Dclose (data_hid);
693 
694 #if defined (HAVE_HDF5_18)
695  data_hid = H5Dopen (group_hid, "ridx", octave_H5P_DEFAULT);
696 #else
697  data_hid = H5Dopen (group_hid, "ridx");
698 #endif
699  space_hid = H5Dget_space (data_hid);
700  rank = H5Sget_simple_extent_ndims (space_hid);
701 
702  if (rank != 2)
703  {
704  H5Sclose (space_hid);
705  H5Dclose (data_hid);
706  H5Gclose (group_hid);
707  return false;
708  }
709 
710  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
711 
712  if (static_cast<int> (hdims[0]) != nz
713  || static_cast<int> (hdims[1]) != 1)
714  {
715  H5Sclose (space_hid);
716  H5Dclose (data_hid);
717  H5Gclose (group_hid);
718  return false;
719  }
720 
721  itmp = m.xridx ();
722  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
723  octave_H5P_DEFAULT, itmp) < 0)
724  {
725  H5Sclose (space_hid);
726  H5Dclose (data_hid);
727  H5Gclose (group_hid);
728  return false;
729  }
730 
731  H5Sclose (space_hid);
732  H5Dclose (data_hid);
733 
734 #if defined (HAVE_HDF5_18)
735  data_hid = H5Dopen (group_hid, "data", octave_H5P_DEFAULT);
736 #else
737  data_hid = H5Dopen (group_hid, "data");
738 #endif
739  space_hid = H5Dget_space (data_hid);
740  rank = H5Sget_simple_extent_ndims (space_hid);
741 
742  if (rank != 2)
743  {
744  H5Sclose (space_hid);
745  H5Dclose (data_hid);
746  H5Gclose (group_hid);
747  return false;
748  }
749 
750  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
751 
752  if (static_cast<int> (hdims[0]) != nz
753  || static_cast<int> (hdims[1]) != 1)
754  {
755  H5Sclose (space_hid);
756  H5Dclose (data_hid);
757  H5Gclose (group_hid);
758  return false;
759  }
760 
761  OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nz);
762 
763  if (H5Dread (data_hid, H5T_NATIVE_HBOOL, octave_H5S_ALL, octave_H5S_ALL,
764  octave_H5P_DEFAULT, htmp) >= 0
765  && m.indices_ok ())
766  {
767  retval = true;
768 
769  for (int i = 0; i < nz; i++)
770  m.xdata(i) = htmp[i];
771 
772  matrix = m;
773  }
774 
775  H5Sclose (space_hid);
776  H5Dclose (data_hid);
777  H5Gclose (group_hid);
778 
779 #else
780  octave_unused_parameter (loc_id);
781  octave_unused_parameter (name);
782 
783  warn_load ("hdf5");
784 #endif
785 
786  return retval;
787 }
788 
789 mxArray *
791 {
792  mwSize nz = nzmax ();
793  mwSize nr = rows ();
794  mwSize nc = columns ();
795 
796  mxArray *retval = new mxArray (interleaved, mxLOGICAL_CLASS, nr, nc, nz,
797  mxREAL);
798 
799  mxLogical *pd = static_cast<mxLogical *> (retval->get_data ());
800  mwIndex *ir = retval->get_ir ();
801 
802  const bool *pdata = matrix.data ();
803  const octave_idx_type *pridx = matrix.ridx ();
804 
805  for (mwIndex i = 0; i < nz; i++)
806  {
807  pd[i] = pdata[i];
808 
809  ir[i] = pridx[i];
810  }
811 
812  mwIndex *jc = retval->get_jc ();
813 
814  const octave_idx_type *pcidx = matrix.cidx ();
815 
816  for (mwIndex i = 0; i < nc + 1; i++)
817  jc[i] = pcidx[i];
818 
819  return retval;
820 }
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
Definition: dMatrix.h:42
boolMatrix matrix_value() const
Definition: boolSparse.cc:248
octave_idx_type cols() const
Definition: Sparse.h:352
octave_idx_type * cidx()
Definition: Sparse.h:596
void resize(octave_idx_type r, octave_idx_type c)
Definition: Sparse.cc:993
T * data()
Definition: Sparse.h:574
octave_idx_type * ridx()
Definition: Sparse.h:583
Sparse< T, Alloc > maybe_compress(bool remove_zeros=false)
Definition: Sparse.h:531
octave_idx_type rows() const
Definition: Sparse.h:351
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
octave_idx_type ndims() const
Number of dimensions.
Definition: dim-vector.h:257
mwIndex * get_ir() const
Definition: mxarray.h:554
mwIndex * get_jc() const
Definition: mxarray.h:556
void * get_data() const
Definition: mxarray.h:473
octave_idx_type rows() const
Definition: ov-base.h:374
octave_idx_type columns() const
Definition: ov-base.h:381
void warn_load(const char *type) const
Definition: ov-base.cc:1157
bool isempty() const
Definition: ov-base.h:417
friend class octave_value
Definition: ov-base.h:269
void warn_save(const char *type) const
Definition: ov-base.cc:1166
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_value as_double() const
double double_value(bool=false) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
type_conv_info numeric_conversion_function() const
NDArray array_value(bool=false) const
Complex complex_value(bool=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
charNDArray char_array_value(bool=false) const
ComplexMatrix complex_matrix_value(bool=false) const
boolMatrix bool_matrix_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
SparseMatrix sparse_matrix_value(bool=false) const
SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
bool save_binary(std::ostream &os, bool save_as_floats)
Matrix matrix_value(bool=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
mxArray * as_mxArray(bool interleaved) const
boolNDArray bool_array_value(bool=false) const
static int static_type_id()
Definition: ov-re-sparse.h:153
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov.h:1307
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void() error(const char *fmt,...)
Definition: error.cc:988
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:71
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:344
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition: ls-hdf5.cc:1249
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:1306
float_format
Definition: mach-info.h:38
void mxArray
Definition: mex.h:58
T octave_idx_type m
Definition: mx-inlines.cc:781
@ mxLOGICAL_CLASS
Definition: mxtypes.h:61
int64_t mwIndex
Definition: mxtypes.h:125
@ mxREAL
Definition: mxtypes.h:80
unsigned char mxLogical
Definition: mxtypes.h:89
int64_t mwSize
Definition: mxtypes.h:124
std::complex< double > Complex
Definition: oct-cmplx.h:33
int64_t octave_hdf5_id
#define H5T_NATIVE_IDX
Definition: oct-hdf5.h:42
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:235