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