GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-str-mat.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-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 <cctype>
31 
32 #include <istream>
33 #include <ostream>
34 #include <vector>
35 
36 #include "data-conv.h"
37 #include "lo-ieee.h"
38 #include "mach-info.h"
39 #include "mx-base.h"
40 #include "oct-locbuf.h"
41 
42 #include "byte-swap.h"
43 #include "defun.h"
44 #include "errwarn.h"
45 #include "ls-ascii-helper.h"
46 #include "ls-hdf5.h"
47 #include "ls-oct-text.h"
48 #include "ls-utils.h"
49 #include "ovl.h"
50 #include "oct-hdf5.h"
51 #include "oct-stream.h"
52 #include "ops.h"
53 #include "ov-scalar.h"
54 #include "ov-re-mat.h"
55 #include "ov-str-mat.h"
56 #include "pr-output.h"
57 #include "utils.h"
58 
59 
62  "char");
63 
64 static octave_base_value *
65 default_numeric_conversion_function (const octave_base_value& a)
66 {
67  octave_base_value *retval = nullptr;
68 
69  const octave_char_matrix_str& v
70  = dynamic_cast<const octave_char_matrix_str&> (a);
71 
72  NDArray nda = v.array_value (true);
73 
74  if (nda.numel () == 1)
75  retval = new octave_scalar (nda(0));
76  else
77  retval = new octave_matrix (nda);
78 
79  return retval;
80 }
81 
84 {
85  return octave_base_value::type_conv_info (default_numeric_conversion_function,
87 }
88 
91  bool resize_ok, char type)
92 {
93  octave_value retval;
94 
95  octave_idx_type len = idx.length ();
96 
97  // If we catch an indexing error in index_vector, we flag an error in
98  // index k. Ensure it is the right value before each idx_vector call.
99  // Same variable as used in the for loop in the default case.
100 
101  octave_idx_type k = 0;
102 
103  try
104  {
105  switch (len)
106  {
107  case 0:
108  retval = octave_value (m_matrix, type);
109  break;
110 
111  case 1:
112  {
113  octave::idx_vector i = idx (0).index_vector ();
114 
115  retval = octave_value (charNDArray (m_matrix.index (i, resize_ok)),
116  type);
117  }
118  break;
119 
120  case 2:
121  {
122  octave::idx_vector i = idx (0).index_vector ();
123  k = 1;
124  octave::idx_vector j = idx (1).index_vector ();
125 
126  retval = octave_value (charNDArray (m_matrix.index (i, j, resize_ok)),
127  type);
128  }
129  break;
130 
131  default:
132  {
134 
135  for (k = 0; k < len; k++)
136  idx_vec(k) = idx(k).index_vector ();
137 
138  retval = octave_value (charNDArray (m_matrix.index (idx_vec, resize_ok)), type);
139  }
140  break;
141  }
142  }
143  catch (octave::index_exception& ie)
144  {
145  // Rethrow to allow more info to be reported later.
146  ie.set_pos_if_unset (len, k+1);
147  throw;
148  }
149 
150  return retval;
151 }
152 
154 octave_char_matrix_str::resize (const dim_vector& dv, bool fill) const
155 {
156  charNDArray retval (m_matrix);
157  if (fill)
158  retval.resize (dv, 0);
159  else
160  retval.resize (dv);
161  return octave_value (retval, is_sq_string () ? '\'' : '"');
162 }
163 
164 #define CHAR_MATRIX_CONV(TNAME, FCN) \
165  \
166  if (! force_string_conv) \
167  err_invalid_conversion ("string", TNAME); \
168  \
169  warn_implicit_conversion ("Octave:str-to-num", "string", TNAME); \
170  \
171  return octave_char_matrix::FCN ()
172 
173 double
174 octave_char_matrix_str::double_value (bool force_string_conv) const
175 {
176  CHAR_MATRIX_CONV ("real scalar", double_value);
177 }
178 
179 Complex
180 octave_char_matrix_str::complex_value (bool force_string_conv) const
181 {
182  CHAR_MATRIX_CONV ("complex scalar", complex_value);
183 }
184 
185 Matrix
186 octave_char_matrix_str::matrix_value (bool force_string_conv) const
187 {
188  CHAR_MATRIX_CONV ("real matrix", matrix_value);
189 }
190 
192 octave_char_matrix_str::complex_matrix_value (bool force_string_conv) const
193 {
194  CHAR_MATRIX_CONV ("complex matrix", complex_matrix_value);
195 }
196 
197 NDArray
198 octave_char_matrix_str::array_value (bool force_string_conv) const
199 {
200  CHAR_MATRIX_CONV ("real N-D array", array_value);
201 }
202 
204 octave_char_matrix_str::complex_array_value (bool force_string_conv) const
205 {
206  CHAR_MATRIX_CONV ("complex N-D array", complex_array_value);
207 }
208 
211 {
212  string_vector retval;
213 
214  if (m_matrix.ndims () != 2)
215  error ("invalid conversion of charNDArray to string_vector");
216 
217  charMatrix chm (m_matrix);
218 
219  octave_idx_type n = chm.rows ();
220 
221  retval.resize (n);
222 
223  for (octave_idx_type i = 0; i < n; i++)
224  retval[i] = chm.row_as_string (i);
225 
226  return retval;
227 }
228 
229 std::string
231 {
232  if (m_matrix.ndims () != 2)
233  error ("invalid conversion of charNDArray to string");
234 
235  charMatrix chm (m_matrix);
236 
237  if (chm.rows () > 1)
238  warning_with_id ("Octave:charmat-truncated",
239  "multi-row character matrix converted to a string, only the first row is used");
240 
241  // FIXME: Is this correct?
242  return chm.row_as_string (0);
243 }
244 
245 /*
246 %!test <*49536>
247 %! warning ("on", "Octave:charmat-truncated", "local");
248 %! s = char ("this", "is", "a", "char", "matrix");
249 %! fail ("sprintf (s)", ...
250 %! "warning", ...
251 %! "multi-row character matrix converted to a string");
252 */
253 
256 {
257  Array<std::string> retval;
258 
259  if (m_matrix.ndims () != 2)
260  error ("cellstr: cannot convert multidimensional arrays");
261 
262  const charMatrix chm (m_matrix);
263  octave_idx_type nr = chm.rows ();
264  retval.clear (nr, 1);
265  for (octave_idx_type i = 0; i < nr; i++)
266  retval.xelem (i) = chm.row_as_string (i);
267 
268  return retval;
269 }
270 
271 void
273  bool pr_as_read_syntax) const
274 {
275  octave_print_internal (os, m_matrix, pr_as_read_syntax,
276  current_print_indent_level (), true);
277 }
278 
279 void
280 octave_char_matrix_str::short_disp (std::ostream& os) const
281 {
282  if (m_matrix.ndims () == 2 && numel () > 0)
283  {
284  charMatrix chm (m_matrix);
285  std::string tmp = chm.row_as_string (0);
286 
287  // FIXME: should this be configurable?
288  std::size_t max_len = 100;
289 
290  os << (tmp.length () > max_len ? tmp.substr (0, 100) : tmp);
291  }
292 }
293 
294 std::string
296  octave_idx_type i,
297  octave_idx_type) const
298 {
299  if (i == 0)
300  {
301  if (rows () == 1)
302  {
303  std::string retval = string_value ();
304 
305  if (! is_sq_string ())
306  retval = octave::undo_string_escapes (retval);
307 
308  return retval;
309  }
310  else if (is_zero_by_zero ())
311  return "";
312  }
313 
314  std::string tname = type_name ();
315  dim_vector dv = m_matrix.dims ();
316  std::string dimstr = dv.str ();
317  return "[" + dimstr + " " + tname + "]";
318 }
319 
320 bool
322 {
323  dim_vector dv = dims ();
324  if (dv.ndims () > 2)
325  {
326  charNDArray tmp = char_array_value ();
327  os << "# ndims: " << dv.ndims () << "\n";
328  for (int i=0; i < dv.ndims (); i++)
329  os << ' ' << dv(i);
330  os << "\n";
331  os.write (tmp.data (), dv.numel ());
332  os << "\n";
333  }
334  else
335  {
336  // Keep this case, rather than use generic code above for
337  // backward compatibility. Makes load_ascii much more complex!!
338  charMatrix chm = char_matrix_value ();
339  octave_idx_type elements = chm.rows ();
340  os << "# elements: " << elements << "\n";
341  for (octave_idx_type i = 0; i < elements; i++)
342  {
343  unsigned len = chm.cols ();
344  os << "# length: " << len << "\n";
345  std::string tstr = chm.row_as_string (i);
346  const char *tmp = tstr.data ();
347  if (tstr.length () > len)
348  panic_impossible ();
349  os.write (tmp, len);
350  os << "\n";
351  }
352  }
353 
354  return true;
355 }
356 
357 bool
359 {
360  string_vector keywords(3);
361 
362  keywords[0] = "ndims";
363  keywords[1] = "elements";
364  keywords[2] = "length";
365 
366  std::string kw;
367  int val = 0;
368 
369  if (! extract_keyword (is, keywords, kw, val, true))
370  error ("load: failed to extract number of rows and columns");
371 
372  if (kw == "ndims")
373  {
374  int mdims = val;
375 
376  if (mdims < 0)
377  error ("load: failed to extract matrix size");
378 
379  dim_vector dv;
380  dv.resize (mdims);
381 
382  for (int i = 0; i < mdims; i++)
383  is >> dv(i);
384 
385  if (! is)
386  error ("load: failed to read dimensions");
387 
388  charNDArray tmp(dv);
389 
390  if (tmp.isempty ())
391  m_matrix = tmp;
392  else
393  {
394  char *ftmp = tmp.fortran_vec ();
395 
397 
398  if (! is.read (ftmp, dv.numel ()) || ! is)
399  error ("load: failed to load string constant");
400 
401  m_matrix = tmp;
402  }
403  }
404  else if (kw == "elements")
405  {
406  int elements = val;
407 
408  if (elements < 0)
409  error ("load: failed to extract number of string elements");
410 
411  // FIXME: need to be able to get max length before doing anything.
412 
413  charMatrix chm (elements, 0);
414  int max_len = 0;
415  for (int i = 0; i < elements; i++)
416  {
417  int len;
418  if (! extract_keyword (is, "length", len) || len < 0)
419  error ("load: failed to extract string length for element %d",
420  i+1);
421 
422  // Use this instead of a C-style character
423  // buffer so that we can properly handle
424  // embedded NUL characters.
425  charMatrix tmp (1, len);
426  char *ptmp = tmp.fortran_vec ();
427 
428  if (len > 0 && ! is.read (ptmp, len))
429  error ("load: failed to load string constant");
430 
431  if (len > max_len)
432  {
433  max_len = len;
434  chm.resize (elements, max_len, 0);
435  }
436 
437  chm.insert (tmp, i, 0);
438  }
439 
440  m_matrix = chm;
441  }
442  else if (kw == "length")
443  {
444  int len = val;
445 
446  if (len >= 0)
447  {
448  // This is cruft for backward compatibility,
449  // but relatively harmless.
450 
451  // Use this instead of a C-style character buffer so
452  // that we can properly handle embedded NUL characters.
453  charMatrix tmp (1, len);
454  char *ptmp = tmp.fortran_vec ();
455 
456  if (len > 0 && ! is.read (ptmp, len))
457  error ("load: failed to load string constant");
458 
459  if (! is)
460  error ("load: failed to load string constant");
461 
462  m_matrix = tmp;
463  }
464  }
465  else
466  panic_impossible ();
467 
468  return true;
469 }
470 
471 bool
473  bool /* save_as_floats */)
474 {
475  dim_vector dv = dims ();
476  if (dv.ndims () < 1)
477  return false;
478 
479  // Use negative value for ndims to differentiate with old format!!
480  int32_t tmp = - dv.ndims ();
481  os.write (reinterpret_cast<char *> (&tmp), 4);
482  for (int i=0; i < dv.ndims (); i++)
483  {
484  tmp = dv(i);
485  os.write (reinterpret_cast<char *> (&tmp), 4);
486  }
487 
489  os.write (m.data (), dv.numel ());
490  return true;
491 }
492 
493 bool
494 octave_char_matrix_str::load_binary (std::istream& is, bool swap,
496 {
497  int32_t elements;
498  if (! is.read (reinterpret_cast<char *> (&elements), 4))
499  return false;
500  if (swap)
501  swap_bytes<4> (&elements);
502 
503  if (elements < 0)
504  {
505  int32_t mdims = - elements;
506  int32_t di;
507  dim_vector dv;
508  dv.resize (mdims);
509 
510  for (int i = 0; i < mdims; i++)
511  {
512  if (! is.read (reinterpret_cast<char *> (&di), 4))
513  return false;
514  if (swap)
515  swap_bytes<4> (&di);
516  dv(i) = di;
517  }
518 
519  // Convert an array with a single dimension to be a row vector.
520  // Octave should never write files like this, other software
521  // might.
522 
523  if (mdims == 1)
524  {
525  mdims = 2;
526  dv.resize (mdims);
527  dv(1) = dv(0);
528  dv(0) = 1;
529  }
530 
531  charNDArray m(dv);
532  char *tmp = m.fortran_vec ();
533  is.read (tmp, dv.numel ());
534 
535  if (! is)
536  return false;
537 
538  m_matrix = m;
539  }
540  else
541  {
542  charMatrix chm (elements, 0);
543  int max_len = 0;
544  for (int i = 0; i < elements; i++)
545  {
546  int32_t len;
547  if (! is.read (reinterpret_cast<char *> (&len), 4))
548  return false;
549  if (swap)
550  swap_bytes<4> (&len);
551  charMatrix btmp (1, len);
552  char *pbtmp = btmp.fortran_vec ();
553  if (! is.read (pbtmp, len))
554  return false;
555  if (len > max_len)
556  {
557  max_len = len;
558  chm.resize (elements, max_len, 0);
559  }
560  chm.insert (btmp, i, 0);
561  }
562  m_matrix = chm;
563  }
564  return true;
565 }
566 
567 bool
569  bool /* save_as_floats */)
570 {
571  bool retval = false;
572 
573 #if defined (HAVE_HDF5)
574 
575  dim_vector dv = dims ();
576  int empty = save_hdf5_empty (loc_id, name, dv);
577  if (empty)
578  return (empty > 0);
579 
580  int rank = dv.ndims ();
581  hid_t space_hid, data_hid;
582  space_hid = data_hid = -1;
584 
585  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
586 
587  // Octave uses column-major, while HDF5 uses row-major ordering
588  for (int i = 0; i < rank; i++)
589  hdims[i] = dv(rank-i-1);
590 
591  space_hid = H5Screate_simple (rank, hdims, nullptr);
592  if (space_hid < 0)
593  return false;
594 #if defined (HAVE_HDF5_18)
595  data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_CHAR, space_hid,
598 #else
599  data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_CHAR, space_hid,
601 #endif
602  if (data_hid < 0)
603  {
604  H5Sclose (space_hid);
605  return false;
606  }
607 
608  OCTAVE_LOCAL_BUFFER (char, s, dv.numel ());
609 
610  for (int i = 0; i < dv.numel (); ++i)
611  s[i] = m(i);
612 
613  retval = H5Dwrite (data_hid, H5T_NATIVE_CHAR, octave_H5S_ALL, octave_H5S_ALL,
614  octave_H5P_DEFAULT, s) >= 0;
615 
616  H5Dclose (data_hid);
617  H5Sclose (space_hid);
618 
619 #else
620  octave_unused_parameter (loc_id);
621  octave_unused_parameter (name);
622 
623  warn_save ("hdf5");
624 #endif
625 
626  return retval;
627 }
628 
629 bool
631 {
632  bool retval = false;
633 
634 #if defined (HAVE_HDF5)
635 
636  dim_vector dv;
637  int empty = load_hdf5_empty (loc_id, name, dv);
638  if (empty > 0)
639  m_matrix.resize (dv);
640  if (empty)
641  return (empty > 0);
642 
643 #if defined (HAVE_HDF5_18)
644  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
645 #else
646  hid_t data_hid = H5Dopen (loc_id, name);
647 #endif
648  hid_t space_hid = H5Dget_space (data_hid);
649  hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
650  hid_t type_hid = H5Dget_type (data_hid);
651  hid_t type_class_hid = H5Tget_class (type_hid);
652 
653  if (type_class_hid == H5T_INTEGER)
654  {
655  if (rank < 1)
656  {
657  H5Tclose (type_hid);
658  H5Sclose (space_hid);
659  H5Dclose (data_hid);
660  return false;
661  }
662 
663  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
664  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
665 
666  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
667 
668  // Octave uses column-major, while HDF5 uses row-major ordering
669  if (rank == 1)
670  {
671  dv.resize (2);
672  dv(0) = 1;
673  dv(1) = hdims[0];
674  }
675  else
676  {
677  dv.resize (rank);
678  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
679  dv(j) = hdims[i];
680  }
681 
682  charNDArray m (dv);
683  char *str = m.fortran_vec ();
684  if (H5Dread (data_hid, H5T_NATIVE_CHAR, octave_H5S_ALL, octave_H5S_ALL,
685  octave_H5P_DEFAULT, str) >= 0)
686  {
687  retval = true;
688  m_matrix = m;
689  }
690 
691  H5Tclose (type_hid);
692  H5Sclose (space_hid);
693  H5Dclose (data_hid);
694  return true;
695  }
696  else
697  {
698  // This is cruft for backward compatibility and easy data importation
699  if (rank == 0)
700  {
701  // a single string:
702  int slen = H5Tget_size (type_hid);
703  if (slen < 0)
704  {
705  H5Tclose (type_hid);
706  H5Sclose (space_hid);
707  H5Dclose (data_hid);
708  return false;
709  }
710  else
711  {
712  OCTAVE_LOCAL_BUFFER (char, s, slen+1);
713  // create datatype for (null-terminated) string to read into:
714  hid_t st_id = H5Tcopy (H5T_C_S1);
715  H5Tset_size (st_id, slen+1);
716  if (H5Dread (data_hid, st_id, octave_H5S_ALL,
718  {
719  H5Tclose (st_id);
720  H5Tclose (type_hid);
721  H5Sclose (space_hid);
722  H5Dclose (data_hid);
723  return false;
724  }
725 
726  m_matrix = charMatrix (s);
727 
728  H5Tclose (st_id);
729  H5Tclose (type_hid);
730  H5Sclose (space_hid);
731  H5Dclose (data_hid);
732  return true;
733  }
734  }
735  else if (rank == 1)
736  {
737  // string vector
738  hsize_t elements, maxdim;
739  H5Sget_simple_extent_dims (space_hid, &elements, &maxdim);
740  int slen = H5Tget_size (type_hid);
741  if (slen < 0)
742  {
743  H5Tclose (type_hid);
744  H5Sclose (space_hid);
745  H5Dclose (data_hid);
746  return false;
747  }
748  else
749  {
750  // hdf5 string arrays store strings of all the
751  // same physical length (I think), which is
752  // slightly wasteful, but oh well.
753 
754  OCTAVE_LOCAL_BUFFER (char, s, elements * (slen+1));
755 
756  // create datatype for (null-terminated) string
757  // to read into:
758  hid_t st_id = H5Tcopy (H5T_C_S1);
759  H5Tset_size (st_id, slen+1);
760 
761  if (H5Dread (data_hid, st_id, octave_H5S_ALL,
763  {
764  H5Tclose (st_id);
765  H5Tclose (type_hid);
766  H5Sclose (space_hid);
767  H5Dclose (data_hid);
768  return false;
769  }
770 
771  charMatrix chm (elements, slen, ' ');
772  for (hsize_t i = 0; i < elements; ++i)
773  {
774  chm.insert (s + i*(slen+1), i, 0);
775  }
776 
777  m_matrix = chm;
778 
779  H5Tclose (st_id);
780  H5Tclose (type_hid);
781  H5Sclose (space_hid);
782  H5Dclose (data_hid);
783  return true;
784  }
785  }
786  else
787  {
788  H5Tclose (type_hid);
789  H5Sclose (space_hid);
790  H5Dclose (data_hid);
791  return false;
792  }
793  }
794 
795 #else
796  octave_unused_parameter (loc_id);
797  octave_unused_parameter (name);
798 
799  warn_load ("hdf5");
800 #endif
801 
802  return retval;
803 }
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:130
T * fortran_vec()
Size of the specified dimension.
Definition: Array-base.cc:1764
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
Definition: Array-base.cc:710
void clear()
Definition: Array-base.cc:109
int ndims() const
Size of the specified dimension.
Definition: Array.h:671
octave_idx_type rows() const
Definition: Array.h:459
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array-base.cc:1023
const T * data() const
Size of the specified dimension.
Definition: Array.h:663
octave_idx_type cols() const
Definition: Array.h:469
bool isempty() const
Size of the specified dimension.
Definition: Array.h:651
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:503
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:524
octave_idx_type numel() const
Number of elements in the array.
Definition: Array.h:414
Definition: dMatrix.h:42
void resize(octave_idx_type nr, octave_idx_type nc, char rfv=0)
Definition: chMatrix.h:98
charMatrix & insert(const char *s, octave_idx_type r, octave_idx_type c)
Definition: chMatrix.cc:59
std::string row_as_string(octave_idx_type, bool strip_ws=false) const
Definition: chMatrix.cc:82
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
std::string str(char sep='x') const
Definition: dim-vector.cc:68
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:335
void resize(int n, int fill_value=0)
Definition: dim-vector.h:272
octave_idx_type ndims() const
Number of dimensions.
Definition: dim-vector.h:257
octave_idx_type numel() const
Definition: ov-base-mat.h:122
octave_idx_type rows() const
Definition: ov-base.h:374
int current_print_indent_level() const
Definition: ov-base.h:920
bool is_zero_by_zero() const
Definition: ov-base.h:419
void warn_load(const char *type) const
Definition: ov-base.cc:1157
virtual bool is_sq_string() const
Definition: ov-base.h:445
friend class octave_value
Definition: ov-base.h:269
void warn_save(const char *type) const
Definition: ov-base.cc:1166
void short_disp(std::ostream &os) const
Definition: ov-str-mat.cc:280
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-str-mat.cc:192
NDArray array_value(bool=false) const
Definition: ov-str-mat.cc:198
std::string type_name() const
Definition: ov-str-mat.h:184
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-str-mat.cc:272
bool load_ascii(std::istream &is)
Definition: ov-str-mat.cc:358
Array< std::string > cellstr_value() const
Definition: ov-str-mat.cc:255
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-str-mat.cc:630
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-str-mat.cc:494
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-str-mat.cc:568
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov-str-mat.cc:154
string_vector string_vector_value(bool pad=false) const
Definition: ov-str-mat.cc:210
Matrix matrix_value(bool=false) const
Definition: ov-str-mat.cc:186
Complex complex_value(bool=false) const
Definition: ov-str-mat.cc:180
bool save_ascii(std::ostream &os)
Definition: ov-str-mat.cc:321
double double_value(bool=false) const
Definition: ov-str-mat.cc:174
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
Definition: ov-str-mat.cc:295
octave_value do_index_op_internal(const octave_value_list &idx, bool resize_ok, char type='"')
Definition: ov-str-mat.cc:90
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-str-mat.cc:204
std::string string_value(bool force=false) const
Definition: ov-str-mat.cc:230
type_conv_info numeric_conversion_function() const
Definition: ov-str-mat.cc:83
bool save_binary(std::ostream &os, bool save_as_floats)
Definition: ov-str-mat.cc:472
charMatrix char_matrix_value(bool=false) const
Definition: ov-ch-mat.h:142
charNDArray char_array_value(bool=false) const
Definition: ov-ch-mat.h:145
static int static_type_id()
Definition: ov-re-mat.h:249
octave_idx_type length() const
Definition: ovl.h:113
void resize(octave_idx_type n, const std::string &rfv="")
Definition: str-vec.h:95
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:1078
void() error(const char *fmt,...)
Definition: error.cc:988
#define panic_impossible()
Definition: error.h:503
octave::idx_vector idx_vector
Definition: idx-vector.h:1022
void skip_preceeding_newline(std::istream &is)
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
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:84
float_format
Definition: mach-info.h:38
T octave_idx_type m
Definition: mx-inlines.cc:781
octave_idx_type n
Definition: mx-inlines.cc:761
std::string undo_string_escapes(const std::string &s)
Definition: utils.cc:1036
std::complex< double > Complex
Definition: oct-cmplx.h:33
int64_t octave_hdf5_id
#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
#define CHAR_MATRIX_CONV(TNAME, FCN)
Definition: ov-str-mat.cc:164
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
Definition: pr-output.cc:1761
F77_RET_T len
Definition: xerbla.cc:61