GNU Octave  4.4.1
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) 2004-2018 David Bateman
4 Copyright (C) 1998-2004 Andy Adler
5 
6 This file is part of Octave.
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
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <iostream>
29 #include <limits>
30 #include <vector>
31 
32 #include "dim-vector.h"
33 
34 #include "mxarray.h"
35 #include "ov-base.h"
36 #include "ov-scalar.h"
37 #include "ov-bool.h"
38 #include "ov-bool-mat.h"
39 #include "errwarn.h"
40 #include "ops.h"
41 #include "oct-locbuf.h"
42 
43 #include "oct-hdf5.h"
44 
45 #include "ov-re-sparse.h"
46 #include "ov-cx-sparse.h"
47 #include "ov-bool-sparse.h"
48 
49 #include "ov-base-sparse.h"
50 #include "ov-base-sparse.cc"
51 
52 template class OCTINTERP_API octave_base_sparse<SparseBoolMatrix>;
53 
55  "sparse bool matrix", "logical");
56 
57 static octave_base_value *
59 {
60  const octave_sparse_bool_matrix& v =
61  dynamic_cast<const octave_sparse_bool_matrix&> (a);
62 
63  return
65 }
66 
69 {
72 }
73 
76 {
77  octave_base_value *retval = nullptr;
78 
80  {
81  // Don't use numel, since it can overflow for very large matrices
82  // Note that for the second test, this means it becomes approximative
83  // since it involves a cast to double to avoid issues of overflow
84  if (matrix.rows () == 1 && matrix.cols () == 1)
85  {
86  // Const copy of the matrix, so the right version of () operator used
87  const SparseBoolMatrix tmp (matrix);
88 
89  retval = new octave_bool (tmp (0));
90  }
91  else if (matrix.cols () > 0 && matrix.rows () > 0
92  && (double (matrix.byte_size ()) > double (matrix.rows ())
93  * double (matrix.cols ()) * sizeof (bool)))
95  }
96 
97  return retval;
98 }
99 
100 double
102 {
103  if (isempty ())
104  err_invalid_conversion ("bool sparse matrix", "real scalar");
105 
106  if (numel () > 1)
107  warn_implicit_conversion ("Octave:array-to-scalar",
108  "bool sparse matrix", "real scalar");
109 
110  return matrix(0, 0);
111 }
112 
113 Complex
115 {
116  if (rows () == 0 || columns () == 0)
117  err_invalid_conversion ("bool sparse matrix", "complex scalar");
118 
119  if (numel () > 1)
120  warn_implicit_conversion ("Octave:array-to-scalar",
121  "bool sparse matrix", "complex scalar");
122 
123  return Complex (matrix(0, 0), 0);
124 }
125 
128  char type) const
129 {
131  return tmp.convert_to_str (pad, force, type);
132 }
133 
134 // FIXME: These are inefficient ways of creating full matrices
135 
136 Matrix
138 {
139  return Matrix (matrix.matrix_value ());
140 }
141 
144 {
145  return ComplexMatrix (matrix.matrix_value ());
146 }
147 
150 {
152 }
153 
154 NDArray
156 {
157  return NDArray (Matrix (matrix.matrix_value ()));
158 }
159 
162 {
163  charNDArray retval (dims (), 0);
164  octave_idx_type nc = matrix.cols ();
165  octave_idx_type nr = matrix.rows ();
166 
167  for (octave_idx_type j = 0; j < nc; j++)
168  for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++)
169  retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i));
170 
171  return retval;
172 }
173 
176 {
177  return matrix.matrix_value ();
178 }
179 
182 {
183  return boolNDArray (matrix.matrix_value ());
184 }
185 
188 {
189  return SparseMatrix (this->matrix);
190 }
191 
194 {
195  return SparseComplexMatrix (this->matrix);
196 }
197 
200 {
201  return SparseMatrix (this->matrix);
202 }
203 
204 bool
206 {
207  dim_vector dv = this->dims ();
208  if (dv.ndims () < 1)
209  return false;
210 
211  // Ensure that additional memory is deallocated
213 
214  int nr = dv(0);
215  int nc = dv(1);
216  int nz = nnz ();
217 
218  int32_t itmp;
219  // Use negative value for ndims to be consistent with other formats
220  itmp = -2;
221  os.write (reinterpret_cast<char *> (&itmp), 4);
222 
223  itmp = nr;
224  os.write (reinterpret_cast<char *> (&itmp), 4);
225 
226  itmp = nc;
227  os.write (reinterpret_cast<char *> (&itmp), 4);
228 
229  itmp = nz;
230  os.write (reinterpret_cast<char *> (&itmp), 4);
231 
232  // add one to the printed indices to go from
233  // zero-based to one-based arrays
234  for (int i = 0; i < nc+1; i++)
235  {
236  octave_quit ();
237  itmp = matrix.cidx (i);
238  os.write (reinterpret_cast<char *> (&itmp), 4);
239  }
240 
241  for (int i = 0; i < nz; i++)
242  {
243  octave_quit ();
244  itmp = matrix.ridx (i);
245  os.write (reinterpret_cast<char *> (&itmp), 4);
246  }
247 
248  OCTAVE_LOCAL_BUFFER (char, htmp, nz);
249 
250  for (int i = 0; i < nz; i++)
251  htmp[i] = (matrix.data (i) ? 1 : 0);
252 
253  os.write (htmp, nz);
254 
255  return true;
256 }
257 
258 bool
261 {
262  int32_t nz, nc, nr, tmp;
263  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
264  return false;
265 
266  if (swap)
267  swap_bytes<4> (&tmp);
268 
269  if (tmp != -2)
270  error ("load: only 2-D sparse matrices are supported");
271 
272  if (! is.read (reinterpret_cast<char *> (&nr), 4))
273  return false;
274  if (! is.read (reinterpret_cast<char *> (&nc), 4))
275  return false;
276  if (! is.read (reinterpret_cast<char *> (&nz), 4))
277  return false;
278 
279  if (swap)
280  {
281  swap_bytes<4> (&nr);
282  swap_bytes<4> (&nc);
283  swap_bytes<4> (&nz);
284  }
285 
286  SparseBoolMatrix m (static_cast<octave_idx_type> (nr),
287  static_cast<octave_idx_type> (nc),
288  static_cast<octave_idx_type> (nz));
289 
290  for (int i = 0; i < nc+1; i++)
291  {
292  octave_quit ();
293  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
294  return false;
295  if (swap)
296  swap_bytes<4> (&tmp);
297  m.cidx (i) = tmp;
298  }
299 
300  for (int i = 0; i < nz; i++)
301  {
302  octave_quit ();
303  if (! is.read (reinterpret_cast<char *> (&tmp), 4))
304  return false;
305  if (swap)
306  swap_bytes<4> (&tmp);
307  m.ridx (i) = tmp;
308  }
309 
310  if (! is)
311  return false;
312 
313  OCTAVE_LOCAL_BUFFER (char, htmp, nz);
314 
315  if (! is.read (htmp, nz))
316  return false;
317 
318  for (int i = 0; i < nz; i++)
319  m.data(i) = (htmp[i] ? 1 : 0);
320 
321  if (! m.indices_ok ())
322  return false;
323 
324  matrix = m;
325 
326  return true;
327 }
328 
329 bool
331  bool)
332 {
333  bool retval = false;
334 
335 #if defined (HAVE_HDF5)
336 
337  dim_vector dv = dims ();
338  int empty = save_hdf5_empty (loc_id, name, dv);
339  if (empty)
340  return (empty > 0);
341 
342  // Ensure that additional memory is deallocated
344 #if defined (HAVE_HDF5_18)
345  hid_t group_hid = H5Gcreate (loc_id, name, octave_H5P_DEFAULT,
347 #else
348  hid_t group_hid = H5Gcreate (loc_id, name, 0);
349 #endif
350  if (group_hid < 0)
351  return false;
352 
353  hid_t space_hid, data_hid;
354  space_hid = data_hid = -1;
357  hsize_t hdims[2];
358 
359  space_hid = H5Screate_simple (0, hdims, nullptr);
360  if (space_hid < 0)
361  {
362  H5Gclose (group_hid);
363  return false;
364  }
365 #if defined (HAVE_HDF5_18)
366  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid,
369 #else
370  data_hid = H5Dcreate (group_hid, "nr", H5T_NATIVE_IDX, space_hid,
372 #endif
373  if (data_hid < 0)
374  {
375  H5Sclose (space_hid);
376  H5Gclose (group_hid);
377  return false;
378  }
379 
380  tmp = m.rows ();
381  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL,
383  H5Dclose (data_hid);
384  if (! retval)
385  {
386  H5Sclose (space_hid);
387  H5Gclose (group_hid);
388  return false;
389  }
390 
391 #if defined (HAVE_HDF5_18)
392  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid,
395 #else
396  data_hid = H5Dcreate (group_hid, "nc", H5T_NATIVE_IDX, space_hid,
398 #endif
399  if (data_hid < 0)
400  {
401  H5Sclose (space_hid);
402  H5Gclose (group_hid);
403  return false;
404  }
405 
406  tmp = m.cols ();
407  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
408  octave_H5P_DEFAULT, &tmp) >= 0;
409  H5Dclose (data_hid);
410  if (! retval)
411  {
412  H5Sclose (space_hid);
413  H5Gclose (group_hid);
414  return false;
415  }
416 
417 #if defined (HAVE_HDF5_18)
418  data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, space_hid,
421 #else
422  data_hid = H5Dcreate (group_hid, "nz", H5T_NATIVE_IDX, space_hid,
424 #endif
425  if (data_hid < 0)
426  {
427  H5Sclose (space_hid);
428  H5Gclose (group_hid);
429  return false;
430  }
431 
432  tmp = m.nnz ();
433  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
434  octave_H5P_DEFAULT, &tmp) >= 0;
435  H5Dclose (data_hid);
436  if (! retval)
437  {
438  H5Sclose (space_hid);
439  H5Gclose (group_hid);
440  return false;
441  }
442 
443  H5Sclose (space_hid);
444 
445  hdims[0] = m.cols () + 1;
446  hdims[1] = 1;
447 
448  space_hid = H5Screate_simple (2, hdims, nullptr);
449 
450  if (space_hid < 0)
451  {
452  H5Gclose (group_hid);
453  return false;
454  }
455 
456 #if defined (HAVE_HDF5_18)
457  data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, space_hid,
460 #else
461  data_hid = H5Dcreate (group_hid, "cidx", H5T_NATIVE_IDX, space_hid,
463 #endif
464  if (data_hid < 0)
465  {
466  H5Sclose (space_hid);
467  H5Gclose (group_hid);
468  return false;
469  }
470 
471  octave_idx_type *itmp = m.xcidx ();
472  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
473  octave_H5P_DEFAULT, itmp) >= 0;
474  H5Dclose (data_hid);
475  if (! retval)
476  {
477  H5Sclose (space_hid);
478  H5Gclose (group_hid);
479  return false;
480  }
481 
482  H5Sclose (space_hid);
483 
484  hdims[0] = m.nnz ();
485  hdims[1] = 1;
486 
487  space_hid = H5Screate_simple (2, hdims, nullptr);
488 
489  if (space_hid < 0)
490  {
491  H5Gclose (group_hid);
492  return false;
493  }
494 
495 #if defined (HAVE_HDF5_18)
496  data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, space_hid,
499 #else
500  data_hid = H5Dcreate (group_hid, "ridx", H5T_NATIVE_IDX, space_hid,
502 #endif
503  if (data_hid < 0)
504  {
505  H5Sclose (space_hid);
506  H5Gclose (group_hid);
507  return false;
508  }
509 
510  itmp = m.xridx ();
511  retval = H5Dwrite (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
512  octave_H5P_DEFAULT, itmp) >= 0;
513  H5Dclose (data_hid);
514  if (! retval)
515  {
516  H5Sclose (space_hid);
517  H5Gclose (group_hid);
518  return false;
519  }
520 
521 #if defined (HAVE_HDF5_18)
522  data_hid = H5Dcreate (group_hid, "data", H5T_NATIVE_HBOOL, space_hid,
525 #else
526  data_hid = H5Dcreate (group_hid, "data", H5T_NATIVE_HBOOL, space_hid,
528 #endif
529  if (data_hid < 0)
530  {
531  H5Sclose (space_hid);
532  H5Gclose (group_hid);
533  return false;
534  }
535 
536  OCTAVE_LOCAL_BUFFER (hbool_t, htmp, m.nnz ());
537  for (int i = 0; i < m.nnz (); i++)
538  htmp[i] = m.xdata(i);
539 
540  retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, octave_H5S_ALL, octave_H5S_ALL,
541  octave_H5P_DEFAULT, htmp) >= 0;
542  H5Dclose (data_hid);
543  H5Sclose (space_hid);
544  H5Gclose (group_hid);
545 
546 #else
547  octave_unused_parameter (loc_id);
548  octave_unused_parameter (name);
549 
550  warn_save ("hdf5");
551 #endif
552 
553  return retval;
554 }
555 
556 bool
558 {
559  bool retval = false;
560 
561 #if defined (HAVE_HDF5)
562 
563  octave_idx_type nr, nc, nz;
564  hid_t group_hid, data_hid, space_hid;
565  hsize_t rank;
566 
567  dim_vector dv;
568  int empty = load_hdf5_empty (loc_id, name, dv);
569  if (empty > 0)
570  matrix.resize (dv);
571  if (empty)
572  return (empty > 0);
573 
574 #if defined (HAVE_HDF5_18)
575  group_hid = H5Gopen (loc_id, name, octave_H5P_DEFAULT);
576 #else
577  group_hid = H5Gopen (loc_id, name);
578 #endif
579  if (group_hid < 0) return false;
580 
581 #if defined (HAVE_HDF5_18)
582  data_hid = H5Dopen (group_hid, "nr", octave_H5P_DEFAULT);
583 #else
584  data_hid = H5Dopen (group_hid, "nr");
585 #endif
586  space_hid = H5Dget_space (data_hid);
587  rank = H5Sget_simple_extent_ndims (space_hid);
588 
589  if (rank != 0)
590  {
591  H5Dclose (data_hid);
592  H5Gclose (group_hid);
593  return false;
594  }
595 
596  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
597  octave_H5P_DEFAULT, &nr)
598  < 0)
599  {
600  H5Dclose (data_hid);
601  H5Gclose (group_hid);
602  return false;
603  }
604 
605  H5Dclose (data_hid);
606 
607 #if defined (HAVE_HDF5_18)
608  data_hid = H5Dopen (group_hid, "nc", octave_H5P_DEFAULT);
609 #else
610  data_hid = H5Dopen (group_hid, "nc");
611 #endif
612  space_hid = H5Dget_space (data_hid);
613  rank = H5Sget_simple_extent_ndims (space_hid);
614 
615  if (rank != 0)
616  {
617  H5Dclose (data_hid);
618  H5Gclose (group_hid);
619  return false;
620  }
621 
622  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
623  octave_H5P_DEFAULT, &nc)
624  < 0)
625  {
626  H5Dclose (data_hid);
627  H5Gclose (group_hid);
628  return false;
629  }
630 
631  H5Dclose (data_hid);
632 
633 #if defined (HAVE_HDF5_18)
634  data_hid = H5Dopen (group_hid, "nz", octave_H5P_DEFAULT);
635 #else
636  data_hid = H5Dopen (group_hid, "nz");
637 #endif
638  space_hid = H5Dget_space (data_hid);
639  rank = H5Sget_simple_extent_ndims (space_hid);
640 
641  if (rank != 0)
642  {
643  H5Dclose (data_hid);
644  H5Gclose (group_hid);
645  return false;
646  }
647 
648  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
649  octave_H5P_DEFAULT, &nz)
650  < 0)
651  {
652  H5Dclose (data_hid);
653  H5Gclose (group_hid);
654  return false;
655  }
656 
657  H5Dclose (data_hid);
658 
659  SparseBoolMatrix m (static_cast<octave_idx_type> (nr),
660  static_cast<octave_idx_type> (nc),
661  static_cast<octave_idx_type> (nz));
662 
663 #if defined (HAVE_HDF5_18)
664  data_hid = H5Dopen (group_hid, "cidx", octave_H5P_DEFAULT);
665 #else
666  data_hid = H5Dopen (group_hid, "cidx");
667 #endif
668  space_hid = H5Dget_space (data_hid);
669  rank = H5Sget_simple_extent_ndims (space_hid);
670 
671  if (rank != 2)
672  {
673  H5Sclose (space_hid);
674  H5Dclose (data_hid);
675  H5Gclose (group_hid);
676  return false;
677  }
678 
679  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
680  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
681 
682  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
683 
684  if (static_cast<int> (hdims[0]) != nc + 1
685  || static_cast<int> (hdims[1]) != 1)
686  {
687  H5Sclose (space_hid);
688  H5Dclose (data_hid);
689  H5Gclose (group_hid);
690  return false;
691  }
692 
693  octave_idx_type *itmp = m.xcidx ();
694  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
695  octave_H5P_DEFAULT, itmp)
696  < 0)
697  {
698  H5Sclose (space_hid);
699  H5Dclose (data_hid);
700  H5Gclose (group_hid);
701  return false;
702  }
703 
704  H5Sclose (space_hid);
705  H5Dclose (data_hid);
706 
707 #if defined (HAVE_HDF5_18)
708  data_hid = H5Dopen (group_hid, "ridx", octave_H5P_DEFAULT);
709 #else
710  data_hid = H5Dopen (group_hid, "ridx");
711 #endif
712  space_hid = H5Dget_space (data_hid);
713  rank = H5Sget_simple_extent_ndims (space_hid);
714 
715  if (rank != 2)
716  {
717  H5Sclose (space_hid);
718  H5Dclose (data_hid);
719  H5Gclose (group_hid);
720  return false;
721  }
722 
723  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
724 
725  if (static_cast<int> (hdims[0]) != nz
726  || static_cast<int> (hdims[1]) != 1)
727  {
728  H5Sclose (space_hid);
729  H5Dclose (data_hid);
730  H5Gclose (group_hid);
731  return false;
732  }
733 
734  itmp = m.xridx ();
735  if (H5Dread (data_hid, H5T_NATIVE_IDX, octave_H5S_ALL, octave_H5S_ALL,
736  octave_H5P_DEFAULT, itmp) < 0)
737  {
738  H5Sclose (space_hid);
739  H5Dclose (data_hid);
740  H5Gclose (group_hid);
741  return false;
742  }
743 
744  H5Sclose (space_hid);
745  H5Dclose (data_hid);
746 
747 #if defined (HAVE_HDF5_18)
748  data_hid = H5Dopen (group_hid, "data", octave_H5P_DEFAULT);
749 #else
750  data_hid = H5Dopen (group_hid, "data");
751 #endif
752  space_hid = H5Dget_space (data_hid);
753  rank = H5Sget_simple_extent_ndims (space_hid);
754 
755  if (rank != 2)
756  {
757  H5Sclose (space_hid);
758  H5Dclose (data_hid);
759  H5Gclose (group_hid);
760  return false;
761  }
762 
763  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
764 
765  if (static_cast<int> (hdims[0]) != nz
766  || static_cast<int> (hdims[1]) != 1)
767  {
768  H5Sclose (space_hid);
769  H5Dclose (data_hid);
770  H5Gclose (group_hid);
771  return false;
772  }
773 
774  OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nz);
775 
776  if (H5Dread (data_hid, H5T_NATIVE_HBOOL, octave_H5S_ALL, octave_H5S_ALL,
777  octave_H5P_DEFAULT, htmp) >= 0
778  && m.indices_ok ())
779  {
780  retval = true;
781 
782  for (int i = 0; i < nz; i++)
783  m.xdata(i) = htmp[i];
784 
785  matrix = m;
786  }
787 
788  H5Sclose (space_hid);
789  H5Dclose (data_hid);
790  H5Gclose (group_hid);
791 
792 #else
793  octave_unused_parameter (loc_id);
794  octave_unused_parameter (name);
795 
796  warn_load ("hdf5");
797 #endif
798 
799  return retval;
800 }
801 
802 mxArray *
804 {
805  mwSize nz = nzmax ();
807  nz, mxREAL);
808  bool *pr = static_cast<bool *> (retval->get_data ());
809  mwIndex *ir = retval->get_ir ();
810  mwIndex *jc = retval->get_jc ();
811 
812  for (mwIndex i = 0; i < nz; i++)
813  {
814  pr[i] = matrix.data (i);
815  ir[i] = matrix.ridx (i);
816  }
817 
818  for (mwIndex i = 0; i < columns () + 1; i++)
819  jc[i] = matrix.cidx (i);
820 
821  return retval;
822 }
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6704
double double_value(bool=false) const
void resize(octave_idx_type r, octave_idx_type c)
Definition: Sparse.cc:950
T * data(void)
Definition: Sparse.h:486
charNDArray char_array_value(bool=false) const
OCTAVE_IDX_TYPE mwSize
Definition: mxarray.in.h:93
octave_idx_type nnz(void) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
boolNDArray bool_array_value(bool=false) const
const octave_hdf5_id octave_H5S_ALL
boolMatrix matrix_value(void) const
Definition: boolSparse.cc:248
mxArray * as_mxArray(void) const
octave_idx_type * cidx(void)
Definition: Sparse.h:508
octave_value as_double(void) const
void error(const char *fmt,...)
Definition: error.cc:578
bool save_binary(std::ostream &os, bool &save_as_floats)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180
SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:953
ComplexMatrix complex_matrix_value(bool=false) const
void warn_load(const char *type) const
Definition: ov-base.cc:1097
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
bool swap
Definition: load-save.cc:738
octave_idx_type nnz(void) const
Actual number of nonzero terms.
Definition: Sparse.h:240
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
Definition: ov-struct.cc:1736
nd deftypefn *std::string name
Definition: sysdep.cc:647
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:60
static int static_type_id(void)
Definition: ov-re-sparse.h:160
type_conv_info numeric_conversion_function(void) const
NDArray array_value(bool=false) const
octave_idx_type rows(void) const
Definition: ov-base.h:316
double tmp
Definition: data.cc:6252
octave_value retval
Definition: data.cc:6246
octave_idx_type * ridx(void)
Definition: Sparse.h:495
int64_t octave_hdf5_id
octave_idx_type * xridx(void)
Definition: Sparse.h:501
void warn_save(const char *type) const
Definition: ov-base.cc:1106
idx type
Definition: ov.cc:3114
Definition: dMatrix.h:36
void mxArray
Definition: mex.h:55
friend class octave_value
Definition: ov-base.h:228
Complex complex_value(bool=false) const
boolMatrix bool_matrix_value(bool=false) const
octave_idx_type cols(void) const
Definition: Sparse.h:259
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition: ls-hdf5.cc:897
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:68
bool indices_ok(void) const
Definition: Sparse.h:661
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
T * xdata(void)
Definition: Sparse.h:488
octave_idx_type numel(void) const
octave_idx_type nzmax(void) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:338
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Matrix matrix_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
#define H5T_NATIVE_IDX
Definition: oct-hdf5.h:39
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:41
Sparse< T > maybe_compress(bool remove_zeros=false)
Definition: Sparse.h:438
bool Vsparse_auto_mutate
Definition: ov-base.cc:101
for i
Definition: data.cc:5264
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type columns(void) const
Definition: ov-base.h:323
bool isempty(void) const
Definition: ov-base.h:359
octave_base_value * try_narrowing_conversion(void)
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:295
std::complex< double > Complex
Definition: oct-cmplx.h:31
size_t byte_size(void) const
Definition: Sparse.h:271
octave_idx_type * xcidx(void)
Definition: Sparse.h:514
OCTAVE_IDX_TYPE mwIndex
Definition: mxarray.in.h:94
write the output to stdout if nargout is
Definition: load-save.cc:1612
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
octave::stream os
Definition: file-io.cc:627
octave_idx_type rows(void) const
Definition: Sparse.h:258