GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-cell.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1999-2015 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <iomanip>
29 #include <iostream>
30 #include <sstream>
31 #include <vector>
32 #include <queue>
33 
34 #include "Array-util.h"
35 #include "byte-swap.h"
36 #include "lo-utils.h"
37 #include "quit.h"
38 #include "oct-locbuf.h"
39 
40 #include "defun.h"
41 #include "error.h"
42 #include "mxarray.h"
43 #include "ov-cell.h"
44 #include "oct-obj.h"
45 #include "oct-hdf5.h"
46 #include "unwind-prot.h"
47 #include "utils.h"
48 #include "ov-base-mat.h"
49 #include "ov-base-mat.cc"
50 #include "ov-re-mat.h"
51 #include "ov-scalar.h"
52 #include "pr-output.h"
53 #include "ov-scalar.h"
54 #include "gripes.h"
55 
56 #include "ls-oct-ascii.h"
57 #include "ls-oct-binary.h"
58 #include "ls-hdf5.h"
59 #include "ls-utils.h"
60 
61 // Cell is able to handle octave_value indexing by itself, so just forward
62 // everything.
63 
64 template <>
67  bool resize_ok)
68 {
69  return matrix.index (idx, resize_ok);
70 }
71 
72 template <>
73 void
75 {
76  matrix.assign (idx, rhs);
77 }
78 
79 template <>
80 void
82  octave_value rhs)
83 {
84  // FIXME: Really?
85  if (rhs.is_cell ())
86  matrix.assign (idx, rhs.cell_value ());
87  else
88  matrix.assign (idx, Cell (rhs));
89 }
90 
91 template <>
92 void
94 {
95  matrix.delete_elements (idx);
96 }
97 
98 // FIXME: this list of specializations is becoming so long that we should
99 // really ask whether octave_cell should inherit from octave_base_matrix at all.
100 
101 template <>
104 {
105  if (n < matrix.numel ())
106  return Cell (matrix(n));
107  else
108  return octave_value ();
109 }
110 
111 template <>
112 bool
114  const octave_value& x)
115 {
116  const octave_cell *xrep =
117  dynamic_cast<const octave_cell *> (&x.get_rep ());
118 
119  bool retval = xrep && xrep->matrix.numel () == 1 && n < matrix.numel ();
120  if (retval)
121  matrix(n) = xrep->matrix(0);
122 
123  return retval;
124 }
125 
126 template class octave_base_matrix<Cell>;
127 
128 
130 
131 static void
133 {
134  error ("assignment to cell array failed");
135 }
136 
138 octave_cell::subsref (const std::string& type,
139  const std::list<octave_value_list>& idx,
140  int nargout,
141  const std::list<octave_lvalue> *lvalue_list)
142 {
143  octave_value_list retval;
144 
145  switch (type[0])
146  {
147  case '(':
148  retval(0) = do_index_op (idx.front ());
149  break;
150 
151  case '{':
152  {
153  octave_value tmp = do_index_op (idx.front ());
154 
155  if (! error_state)
156  {
157  Cell tcell = tmp.cell_value ();
158 
159  if (tcell.length () == 1)
160  retval(0) = tcell(0,0);
161  else
162  retval = octave_value (octave_value_list (tcell), true);
163  }
164  }
165  break;
166 
167  case '.':
168  {
169  std::string nm = type_name ();
170  error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
171  }
172  break;
173 
174  default:
175  panic_impossible ();
176  }
177 
178  // FIXME: perhaps there should be an
179  // octave_value_list::next_subsref member function? See also
180  // octave_user_function::subsref.
181 
182  if (idx.size () > 1)
183  retval = (lvalue_list
184  ? retval(0).next_subsref (nargout, type, idx, lvalue_list)
185  : retval(0).next_subsref (nargout, type, idx));
186 
187  return retval;
188 }
189 
191 octave_cell::subsref (const std::string& type,
192  const std::list<octave_value_list>& idx,
193  bool auto_add)
194 {
195  octave_value retval;
196 
197  switch (type[0])
198  {
199  case '(':
200  retval = do_index_op (idx.front (), auto_add);
201  break;
202 
203  case '{':
204  {
205  octave_value tmp = do_index_op (idx.front (), auto_add);
206 
207  if (! error_state)
208  {
209  const Cell tcell = tmp.cell_value ();
210 
211  if (tcell.length () == 1)
212  retval = tcell(0,0);
213  else
214  retval = octave_value (octave_value_list (tcell), true);
215  }
216  }
217  break;
218 
219  case '.':
220  {
221  std::string nm = type_name ();
222  error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
223  }
224  break;
225 
226  default:
227  panic_impossible ();
228  }
229 
230  // FIXME: perhaps there should be an
231  // octave_value_list::next_subsref member function? See also
232  // octave_user_function::subsref.
233 
234  if (idx.size () > 1)
235  retval = retval.next_subsref (auto_add, type, idx);
236 
237  return retval;
238 }
239 
241 octave_cell::subsasgn (const std::string& type,
242  const std::list<octave_value_list>& idx,
243  const octave_value& rhs)
244 {
245  octave_value retval;
246 
247  int n = type.length ();
248 
249  octave_value t_rhs = rhs;
250 
252 
253  if (idx.front ().empty ())
254  {
255  error ("missing index in indexed assignment");
256  return retval;
257  }
258 
259  if (n > 1)
260  {
261  switch (type[0])
262  {
263  case '(':
264  {
265  if (is_empty () && type[1] == '.')
266  {
267  // Allow conversion of empty cell array to some other
268  // type in cases like
269  //
270  // x = {}; x(i).f = rhs
271 
272  octave_value tmp = octave_value::empty_conv (type, rhs);
273 
274  return tmp.subsasgn (type, idx, rhs);
275  }
276  else
277  {
278  octave_value tmp = do_index_op (idx.front (), true);
279 
280  if (! tmp.is_defined ())
281  tmp = octave_value::empty_conv (type.substr (1), rhs);
282 
283  if (! error_state)
284  {
285  std::list<octave_value_list> next_idx (idx);
286 
287  next_idx.erase (next_idx.begin ());
288 
289  tmp.make_unique ();
290 
291  t_rhs = tmp.subsasgn (type.substr (1), next_idx, rhs);
292  }
293  }
294  }
295  break;
296 
297  case '{':
298  {
299  matrix.make_unique ();
300  Cell tmpc = matrix.index (idx.front (), true);
301 
302  if (! error_state)
303  {
304  std::list<octave_value_list> next_idx (idx);
305 
306  next_idx.erase (next_idx.begin ());
307 
308  std::string next_type = type.substr (1);
309 
310  if (tmpc.numel () == 1)
311  {
312  octave_value tmp = tmpc(0);
313  tmpc = Cell ();
314 
315  if (! tmp.is_defined () || tmp.is_zero_by_zero ())
316  {
317  tmp = octave_value::empty_conv (type.substr (1), rhs);
318  tmp.make_unique (); // probably a no-op.
319  }
320  else
321  // optimization: ignore copy still stored inside array.
322  tmp.make_unique (1);
323 
324  if (! error_state)
325  t_rhs = tmp.subsasgn (next_type, next_idx, rhs);
326  }
327  else
329  }
330  }
331  break;
332 
333  case '.':
334  {
335  if (is_empty ())
336  {
337  // Do nothing; the next branch will handle it.
338  }
339  else
340  {
341  std::string nm = type_name ();
342  error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
343  }
344  }
345  break;
346 
347  default:
348  panic_impossible ();
349  }
350  }
351 
352  if (! error_state)
353  {
354  switch (type[0])
355  {
356  case '(':
357  {
358  octave_value_list i = idx.front ();
359 
360  if (t_rhs.is_cell ())
362  else if (t_rhs.is_null_value ())
364  else
366 
367  if (! error_state)
368  {
369  count++;
370  retval = octave_value (this);
371  }
372  else
374  }
375  break;
376 
377  case '{':
378  {
379  octave_value_list idxf = idx.front ();
380 
381  if (t_rhs.is_cs_list ())
382  {
383  Cell tmp_cell = Cell (t_rhs.list_value ());
384 
385  // Inquire the proper shape of the RHS.
386 
387  dim_vector didx = dims ().redim (idxf.length ());
388  for (octave_idx_type k = 0; k < idxf.length (); k++)
389  if (! idxf(k).is_magic_colon ()) didx(k) = idxf(k).numel ();
390 
391  if (didx.numel () == tmp_cell.numel ())
392  tmp_cell = tmp_cell.reshape (didx);
393 
394 
395  octave_base_matrix<Cell>::assign (idxf, tmp_cell);
396  }
397  else if (idxf.all_scalars ()
398  || do_index_op (idxf, true).numel () == 1)
399  // Regularize a null matrix if stored into a cell.
401  Cell (t_rhs.storable_value ()));
402  else if (! error_state)
404 
405  if (! error_state)
406  {
407  count++;
408  retval = octave_value (this);
409  }
410  else
412  }
413  break;
414 
415  case '.':
416  {
417  if (is_empty ())
418  {
419  // Allow conversion of empty cell array to some other
420  // type in cases like
421  //
422  // x = {}; x.f = rhs
423 
424  octave_value tmp = octave_value::empty_conv (type, rhs);
425 
426  return tmp.subsasgn (type, idx, rhs);
427  }
428  else
429  {
430  std::string nm = type_name ();
431  error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
432  }
433  }
434  break;
435 
436  default:
437  panic_impossible ();
438  }
439  }
440 
441  return retval;
442 }
443 
444 bool
446 {
447  bool retval;
448  if (cellstr_cache.get ())
449  retval = true;
450  else
451  {
452  retval = matrix.is_cellstr ();
453  // Allocate empty cache to mark that this is indeed a cellstr.
454  if (retval)
455  cellstr_cache.reset (new Array<std::string> ());
456  }
457 
458  return retval;
459 }
460 
461 void
463 {
466 }
467 
468 void
470 {
473 }
474 
475 
476 void
478 {
481 }
482 
483 size_t
485 {
486  size_t retval = 0;
487 
488  for (octave_idx_type i = 0; i < numel (); i++)
489  retval += matrix(i).byte_size ();
490 
491  return retval;
492 }
493 
496 {
497  octave_value retval;
498 
499  if (is_cellstr ())
500  {
502 
503  tmp = tmp.sort (dim, mode);
504 
505  // We already have the cache.
506  retval = new octave_cell (tmp);
507  }
508  else
509  error ("sort: only cell arrays of character strings may be sorted");
510 
511  return retval;
512 }
513 
516  sortmode mode) const
517 {
518  octave_value retval;
519 
520  if (is_cellstr ())
521  {
523 
524  tmp = tmp.sort (sidx, dim, mode);
525 
526  // We already have the cache.
527  retval = new octave_cell (tmp);
528  }
529  else
530  error ("sort: only cell arrays of character strings may be sorted");
531 
532  return retval;
533 }
534 
535 sortmode
537 {
538  sortmode retval = UNSORTED;
539 
540  if (is_cellstr ())
541  {
543 
544  retval = tmp.is_sorted (mode);
545  }
546  else
547  error ("issorted: A is not a cell array of strings");
548 
549  return retval;
550 }
551 
552 
555 {
556  Array<octave_idx_type> retval;
557 
558  if (is_cellstr ())
559  {
561 
562  retval = tmp.sort_rows_idx (mode);
563  }
564  else
565  error ("sortrows: only cell arrays of character strings may be sorted");
566 
567  return retval;
568 }
569 
570 sortmode
572 {
573  sortmode retval = UNSORTED;
574 
575  if (is_cellstr ())
576  {
578 
579  retval = tmp.is_sorted_rows (mode);
580  }
581  else
582  error ("issorted: A is not a cell array of strings");
583 
584  return retval;
585 }
586 
587 bool
589 {
590  error ("invalid conversion from cell array to logical value");
591  return false;
592 }
593 
596 {
597  return octave_value_list (matrix);
598 }
599 
601 octave_cell::all_strings (bool pad) const
602 {
603  string_vector retval;
604 
605  octave_idx_type nel = numel ();
606 
607  int n_elts = 0;
608 
609  octave_idx_type max_len = 0;
610 
611  std::queue<string_vector> strvec_queue;
612 
613  for (octave_idx_type i = 0; i < nel; i++)
614  {
615  string_vector s = matrix(i).all_strings ();
616 
617  if (error_state)
618  return retval;
619 
620  octave_idx_type s_len = s.length ();
621 
622  n_elts += s_len ? s_len : 1;
623 
624  octave_idx_type s_max_len = s.max_length ();
625 
626  if (s_max_len > max_len)
627  max_len = s_max_len;
628 
629  strvec_queue.push (s);
630  }
631 
632  retval = string_vector (n_elts);
633 
634  octave_idx_type k = 0;
635 
636  for (octave_idx_type i = 0; i < nel; i++)
637  {
638  const string_vector s = strvec_queue.front ();
639  strvec_queue.pop ();
640 
641  octave_idx_type s_len = s.length ();
642 
643  if (s_len)
644  {
645  for (octave_idx_type j = 0; j < s_len; j++)
646  {
647  std::string t = s[j];
648  int t_len = t.length ();
649 
650  if (pad && max_len > t_len)
651  t += std::string (max_len - t_len, ' ');
652 
653  retval[k++] = t;
654  }
655  }
656  else if (pad)
657  retval[k++] = std::string (max_len, ' ');
658  else
659  retval[k++] = std::string ();
660  }
661 
662  return retval;
663 }
664 
667 {
668  Array<std::string> retval;
669 
670  if (is_cellstr ())
671  {
672  if (cellstr_cache->is_empty ())
674 
675  return *cellstr_cache;
676  }
677  else
678  error ("invalid conversion from cell array to array of strings");
679 
680  return retval;
681 }
682 
683 bool
685 {
686  return true;
687 }
688 
689 void
690 octave_cell::print (std::ostream& os, bool)
691 {
692  print_raw (os);
693 }
694 
695 void
696 octave_cell::print_raw (std::ostream& os, bool) const
697 {
698  int nd = matrix.ndims ();
699 
700  if (nd == 2)
701  {
702  octave_idx_type nr = rows ();
703  octave_idx_type nc = columns ();
704 
705  if (nr > 0 && nc > 0)
706  {
707  newline (os);
708  indent (os);
709  os << "{";
710  newline (os);
711 
713 
714  for (octave_idx_type j = 0; j < nc; j++)
715  {
716  for (octave_idx_type i = 0; i < nr; i++)
717  {
718  octave_quit ();
719 
720  std::ostringstream buf;
721  buf << "[" << i+1 << "," << j+1 << "]";
722 
723  octave_value val = matrix(i,j);
724 
725  val.print_with_name (os, buf.str ());
726  }
727  }
728 
730 
731  indent (os);
732  os << "}";
733  newline (os);
734  }
735  else
736  {
737  indent (os);
738  os << "{}";
740  os << "(" << nr << "x" << nc << ")";
741  newline (os);
742  }
743  }
744  else
745  {
746  indent (os);
747  dim_vector dv = matrix.dims ();
748  os << "{" << dv.str () << " Cell Array}";
749  newline (os);
750  }
751 }
752 
753 void
754 octave_cell::short_disp (std::ostream& os) const
755 {
756  os << (matrix.is_empty () ? "{}" : "...");
757 }
758 
759 #define CELL_ELT_TAG "<cell-element>"
760 
761 bool
762 octave_cell::save_ascii (std::ostream& os)
763 {
764  dim_vector d = dims ();
765  if (d.length () > 2)
766  {
767  os << "# ndims: " << d.length () << "\n";
768 
769  for (int i = 0; i < d.length (); i++)
770  os << " " << d (i);
771  os << "\n";
772 
773  Cell tmp = cell_value ();
774 
775  for (octave_idx_type i = 0; i < d.numel (); i++)
776  {
777  octave_value o_val = tmp.elem (i);
778 
779  // Recurse to print sub-value.
780  bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
781 
782  if (! b)
783  return ! os.fail ();
784  }
785  }
786  else
787  {
788  // Keep this case, rather than use generic code above for backward
789  // compatiability. Makes load_ascii much more complex!!
790  os << "# rows: " << rows () << "\n"
791  << "# columns: " << columns () << "\n";
792 
793  Cell tmp = cell_value ();
794 
795  for (octave_idx_type j = 0; j < tmp.cols (); j++)
796  {
797  for (octave_idx_type i = 0; i < tmp.rows (); i++)
798  {
799  octave_value o_val = tmp.elem (i, j);
800 
801  // Recurse to print sub-value.
802  bool b = save_ascii_data (os, o_val, CELL_ELT_TAG, false, 0);
803 
804  if (! b)
805  return ! os.fail ();
806  }
807 
808  os << "\n";
809  }
810  }
811 
812  return true;
813 }
814 
815 bool
816 octave_cell::load_ascii (std::istream& is)
817 {
818  bool success = true;
819 
821 
823 
824  keywords[0] = "ndims";
825  keywords[1] = "rows";
826 
827  std::string kw;
828  octave_idx_type val = 0;
829 
830  if (extract_keyword (is, keywords, kw, val, true))
831  {
832  if (kw == "ndims")
833  {
834  int mdims = static_cast<int> (val);
835 
836  if (mdims >= 0)
837  {
838  dim_vector dv;
839  dv.resize (mdims);
840 
841  for (int i = 0; i < mdims; i++)
842  is >> dv(i);
843 
844  Cell tmp(dv);
845 
846  for (octave_idx_type i = 0; i < dv.numel (); i++)
847  {
848  octave_value t2;
849  bool dummy;
850 
851  // recurse to read cell elements
852  std::string nm = read_ascii_data (is, std::string (),
853  dummy, t2, i);
854 
855  if (nm == CELL_ELT_TAG)
856  {
857  if (is)
858  tmp.elem (i) = t2;
859  }
860  else
861  {
862  error ("load: cell array element had unexpected name");
863  success = false;
864  break;
865  }
866  }
867 
868  if (is)
869  matrix = tmp;
870  else
871  {
872  error ("load: failed to load matrix constant");
873  success = false;
874  }
875  }
876  else
877  {
878  error ("load: failed to extract number of rows and columns");
879  success = false;
880  }
881  }
882  else if (kw == "rows")
883  {
884  octave_idx_type nr = val;
885  octave_idx_type nc = 0;
886 
887  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
888  {
889  if (nr > 0 && nc > 0)
890  {
891  Cell tmp (nr, nc);
892 
893  for (octave_idx_type j = 0; j < nc; j++)
894  {
895  for (octave_idx_type i = 0; i < nr; i++)
896  {
897  octave_value t2;
898  bool dummy;
899 
900  // recurse to read cell elements
901  std::string nm = read_ascii_data (is, std::string (),
902  dummy, t2, i);
903 
904  if (nm == CELL_ELT_TAG)
905  {
906  if (is)
907  tmp.elem (i, j) = t2;
908  }
909  else
910  {
911  error ("load: cell array element had unexpected name");
912  success = false;
913  goto cell_read_error;
914  }
915  }
916  }
917 
918  cell_read_error:
919 
920  if (is)
921  matrix = tmp;
922  else
923  {
924  error ("load: failed to load cell element");
925  success = false;
926  }
927  }
928  else if (nr == 0 || nc == 0)
929  matrix = Cell (nr, nc);
930  else
931  panic_impossible ();
932  }
933  else
934  {
935  error ("load: failed to extract number of rows and columns for cell array");
936  success = false;
937  }
938  }
939  else
940  panic_impossible ();
941  }
942  else
943  {
944  error ("load: failed to extract number of rows and columns");
945  success = false;
946  }
947 
948  return success;
949 }
950 
951 bool
952 octave_cell::save_binary (std::ostream& os, bool& save_as_floats)
953 {
954  dim_vector d = dims ();
955  if (d.length () < 1)
956  return false;
957 
958  // Use negative value for ndims
959  int32_t di = - d.length ();
960  os.write (reinterpret_cast<char *> (&di), 4);
961  for (int i = 0; i < d.length (); i++)
962  {
963  di = d(i);
964  os.write (reinterpret_cast<char *> (&di), 4);
965  }
966 
967  Cell tmp = cell_value ();
968 
969  for (octave_idx_type i = 0; i < d.numel (); i++)
970  {
971  octave_value o_val = tmp.elem (i);
972 
973  // Recurse to print sub-value.
974  bool b = save_binary_data (os, o_val, CELL_ELT_TAG, "", 0,
975  save_as_floats);
976 
977  if (! b)
978  return false;
979  }
980 
981  return true;
982 }
983 
984 bool
985 octave_cell::load_binary (std::istream& is, bool swap,
987 {
989 
990  bool success = true;
991  int32_t mdims;
992  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
993  return false;
994  if (swap)
995  swap_bytes<4> (&mdims);
996  if (mdims >= 0)
997  return false;
998 
999  mdims = -mdims;
1000  int32_t di;
1001  dim_vector dv;
1002  dv.resize (mdims);
1003 
1004  for (int i = 0; i < mdims; i++)
1005  {
1006  if (! is.read (reinterpret_cast<char *> (&di), 4))
1007  return false;
1008  if (swap)
1009  swap_bytes<4> (&di);
1010  dv(i) = di;
1011  }
1012 
1013  // Convert an array with a single dimension to be a row vector.
1014  // Octave should never write files like this, other software
1015  // might.
1016 
1017  if (mdims == 1)
1018  {
1019  mdims = 2;
1020  dv.resize (mdims);
1021  dv(1) = dv(0);
1022  dv(0) = 1;
1023  }
1024 
1025  octave_idx_type nel = dv.numel ();
1026  Cell tmp(dv);
1027 
1028  for (octave_idx_type i = 0; i < nel; i++)
1029  {
1030  octave_value t2;
1031  bool dummy;
1032  std::string doc;
1033 
1034  // recurse to read cell elements
1035  std::string nm = read_binary_data (is, swap, fmt, std::string (),
1036  dummy, t2, doc);
1037 
1038  if (nm == CELL_ELT_TAG)
1039  {
1040  if (is)
1041  tmp.elem (i) = t2;
1042  }
1043  else
1044  {
1045  error ("load: cell array element had unexpected name");
1046  success = false;
1047  break;
1048  }
1049  }
1050 
1051  if (is)
1052  matrix = tmp;
1053  else
1054  {
1055  error ("load: failed to load matrix constant");
1056  success = false;
1057  }
1058 
1059  return success;
1060 }
1061 
1062 void *
1064 {
1066  return matrix.mex_get_data ();
1067 }
1068 
1069 bool
1070 octave_cell::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats)
1071 {
1072 #if defined (HAVE_HDF5)
1073 
1074  dim_vector dv = dims ();
1075  int empty = save_hdf5_empty (loc_id, name, dv);
1076  if (empty)
1077  return (empty > 0);
1078 
1079  hsize_t rank = dv.length ();
1080  hid_t space_hid, data_hid, size_hid;
1081  space_hid = data_hid = size_hid = -1;
1082 
1083 #if HAVE_HDF5_18
1084  data_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
1085 #else
1086  data_hid = H5Gcreate (loc_id, name, 0);
1087 #endif
1088 
1089  if (data_hid < 0)
1090  return false;
1091 
1092  // Have to save cell array shape, since can't have a
1093  // dataset of groups....
1094 
1095  space_hid = H5Screate_simple (1, &rank, 0);
1096 
1097  if (space_hid < 0)
1098  {
1099  H5Gclose (data_hid);
1100  return false;
1101  }
1102 
1103  OCTAVE_LOCAL_BUFFER (octave_idx_type, hdims, rank);
1104 
1105  // Octave uses column-major, while HDF5 uses row-major ordering
1106  for (hsize_t i = 0; i < rank; i++)
1107  hdims[i] = dv(rank-i-1);
1108 
1109 #if HAVE_HDF5_18
1110  size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid,
1111  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
1112 #else
1113  size_hid = H5Dcreate (data_hid, "dims", H5T_NATIVE_IDX, space_hid,
1114  H5P_DEFAULT);
1115 #endif
1116  if (size_hid < 0)
1117  {
1118  H5Sclose (space_hid);
1119  H5Gclose (data_hid);
1120  return false;
1121  }
1122 
1123  if (H5Dwrite (size_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
1124  H5P_DEFAULT, hdims) < 0)
1125  {
1126  H5Dclose (size_hid);
1127  H5Sclose (space_hid);
1128  H5Gclose (data_hid);
1129  return false;
1130  }
1131 
1132  H5Dclose (size_hid);
1133  H5Sclose (space_hid);
1134 
1135  // Recursively add each element of the cell to this group.
1136 
1137  Cell tmp = cell_value ();
1138 
1139  octave_idx_type nel = dv.numel ();
1140 
1141  for (octave_idx_type i = 0; i < nel; i++)
1142  {
1143  std::ostringstream buf;
1144  int digits = static_cast<int> (gnulib::floor (::log10 (static_cast<double>
1145  (nel)) + 1.0));
1146  buf << "_" << std::setw (digits) << std::setfill ('0') << i;
1147  std::string s = buf.str ();
1148 
1149  if (! add_hdf5_data (data_hid, tmp.elem (i), s.c_str (), "", false,
1150  save_as_floats))
1151  {
1152  H5Gclose (data_hid);
1153  return false;
1154  }
1155  }
1156 
1157  H5Gclose (data_hid);
1158 
1159  return true;
1160 
1161 #else
1162  gripe_save ("hdf5");
1163  return false;
1164 #endif
1165 }
1166 
1167 bool
1169 {
1170  bool retval = false;
1171 
1172 #if defined (HAVE_HDF5)
1173 
1175 
1176  dim_vector dv;
1177  int empty = load_hdf5_empty (loc_id, name, dv);
1178  if (empty > 0)
1179  matrix.resize (dv);
1180  if (empty)
1181  return (empty > 0);
1182 
1183 #if HAVE_HDF5_18
1184  hid_t group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
1185 #else
1186  hid_t group_id = H5Gopen (loc_id, name);
1187 #endif
1188 
1189  if (group_id < 0)
1190  return false;
1191 
1192 #if HAVE_HDF5_18
1193  hid_t data_hid = H5Dopen (group_id, "dims", H5P_DEFAULT);
1194 #else
1195  hid_t data_hid = H5Dopen (group_id, "dims");
1196 #endif
1197  hid_t space_hid = H5Dget_space (data_hid);
1198  hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
1199  if (rank != 1)
1200  {
1201  H5Dclose (data_hid);
1202  H5Gclose (group_id);
1203  return false;
1204  }
1205 
1206  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
1207  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
1208 
1209  H5Sget_simple_extent_dims (space_hid, hdims, maxdims);
1210 
1211  // Octave uses column-major, while HDF5 uses row-major ordering.
1212 
1213  dv.resize (hdims[0]);
1214 
1215  OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, hdims[0]);
1216 
1217  if (H5Dread (data_hid, H5T_NATIVE_IDX, H5S_ALL, H5S_ALL,
1218  H5P_DEFAULT, tmp) < 0)
1219  {
1220  H5Dclose (data_hid);
1221  H5Gclose (group_id);
1222  return false;
1223  }
1224 
1225  H5Dclose (data_hid);
1226  H5Gclose (group_id);
1227 
1228  for (hsize_t i = 0, j = hdims[0] - 1; i < hdims[0]; i++, j--)
1229  dv(j) = tmp[i];
1230 
1231  hdf5_callback_data dsub;
1232 
1233  herr_t retval2 = -1;
1234 
1235  Cell m (dv);
1236 
1237  int current_item = 0;
1238 
1239  hsize_t num_obj = 0;
1240 #if HAVE_HDF5_18
1241  group_id = H5Gopen (loc_id, name, H5P_DEFAULT);
1242 #else
1243  group_id = H5Gopen (loc_id, name);
1244 #endif
1245  H5Gget_num_objs (group_id, &num_obj);
1246  H5Gclose (group_id);
1247 
1248  for (octave_idx_type i = 0; i < dv.numel (); i++)
1249  {
1250 
1251  if (current_item >= static_cast<int> (num_obj))
1252  retval2 = -1;
1253  else
1254  retval2 = H5Giterate (loc_id, name, &current_item,
1255  hdf5_read_next_data, &dsub);
1256 
1257  if (retval2 <= 0)
1258  break;
1259 
1260  octave_value ov = dsub.tc;
1261  m.elem (i) = ov;
1262 
1263  }
1264 
1265  if (retval2 >= 0)
1266  {
1267  matrix = m;
1268  retval = true;
1269  }
1270 
1271 #else
1272  gripe_load ("hdf5");
1273 #endif
1274 
1275  return retval;
1276 }
1277 
1278 DEFUN (iscell, args, ,
1279  "-*- texinfo -*-\n\
1280 @deftypefn {Built-in Function} {} iscell (@var{x})\n\
1281 Return true if @var{x} is a cell array object.\n\
1282 @seealso{ismatrix, isstruct, iscellstr, isa}\n\
1283 @end deftypefn")
1284 {
1285  octave_value retval;
1286 
1287  if (args.length () == 1)
1288  retval = args(0).is_cell ();
1289  else
1290  print_usage ();
1291 
1292  return retval;
1293 }
1294 
1295 DEFUN (cell, args, ,
1296  "-*- texinfo -*-\n\
1297 @deftypefn {Built-in Function} {} cell (@var{n})\n\
1298 @deftypefnx {Built-in Function} {} cell (@var{m}, @var{n})\n\
1299 @deftypefnx {Built-in Function} {} cell (@var{m}, @var{n}, @var{k}, @dots{})\n\
1300 @deftypefnx {Built-in Function} {} cell ([@var{m} @var{n} @dots{}])\n\
1301 Create a new cell array object.\n\
1302 \n\
1303 If invoked with a single scalar integer argument, return a square\n\
1304 @nospell{NxN} cell array. If invoked with two or more scalar integer\n\
1305 arguments, or a vector of integer values, return an array with the given\n\
1306 dimensions.\n\
1307 @seealso{cellstr, mat2cell, num2cell, struct2cell}\n\
1308 @end deftypefn")
1309 {
1310  octave_value retval;
1311 
1312  int nargin = args.length ();
1313 
1314  dim_vector dims;
1315 
1316  switch (nargin)
1317  {
1318  case 0:
1319  dims = dim_vector (0, 0);
1320  break;
1321 
1322  case 1:
1323  get_dimensions (args(0), "cell", dims);
1324  break;
1325 
1326  default:
1327  {
1328  dims.resize (nargin);
1329 
1330  for (int i = 0; i < nargin; i++)
1331  {
1332  dims(i) = args(i).is_empty () ? 0 : args(i).nint_value ();
1333 
1334  if (error_state)
1335  {
1336  error ("cell: expecting scalar arguments");
1337  break;
1338  }
1339  }
1340  }
1341  break;
1342  }
1343 
1344  if (! error_state)
1345  {
1346  dims.chop_trailing_singletons ();
1347 
1348  check_dimensions (dims, "cell");
1349 
1350  if (! error_state)
1351  retval = Cell (dims, Matrix ());
1352  }
1353 
1354  return retval;
1355 }
1356 
1357 DEFUN (iscellstr, args, ,
1358  "-*- texinfo -*-\n\
1359 @deftypefn {Built-in Function} {} iscellstr (@var{cell})\n\
1360 Return true if every element of the cell array @var{cell} is a character\n\
1361 string.\n\
1362 @seealso{ischar}\n\
1363 @end deftypefn")
1364 {
1365  octave_value retval;
1366 
1367  if (args.length () == 1)
1368  retval = args(0).is_cellstr ();
1369  else
1370  print_usage ();
1371 
1372  return retval;
1373 }
1374 
1375 // Note that since Fcellstr calls Fiscellstr, we need to have
1376 // Fiscellstr defined first (to provide a declaration) and also we
1377 // should keep it in the same file (so we don't have to provide a
1378 // declaration) and so we don't have to use feval to call it.
1379 
1380 DEFUN (cellstr, args, ,
1381  "-*- texinfo -*-\n\
1382 @deftypefn {Built-in Function} {@var{cstr} =} cellstr (@var{strmat})\n\
1383 Create a new cell array object from the elements of the string array\n\
1384 @var{strmat}.\n\
1385 \n\
1386 Each row of @var{strmat} becomes an element of @var{cstr}. Any trailing\n\
1387 spaces in a row are deleted before conversion.\n\
1388 \n\
1389 To convert back from a cellstr to a character array use @code{char}.\n\
1390 @seealso{cell, char}\n\
1391 @end deftypefn")
1392 {
1393  octave_value retval;
1394 
1395  if (args.length () == 1)
1396  {
1397  octave_value_list tmp = Fiscellstr (args, 1);
1398 
1399  if (tmp(0).is_true ())
1400  retval = args(0);
1401  else
1402  {
1403  string_vector s = args(0).all_strings ();
1404 
1405  if (! error_state)
1406  retval = (s.is_empty ()
1407  ? Cell (octave_value (std::string ()))
1408  : Cell (s, true));
1409  else
1410  error ("cellstr: argument STRING must be a 2-D character array");
1411  }
1412  }
1413  else
1414  print_usage ();
1415 
1416  return retval;
1417 }
1418 
1419 DEFUN (struct2cell, args, ,
1420  "-*- texinfo -*-\n\
1421 @deftypefn {Built-in Function} {@var{c} =} struct2cell (@var{s})\n\
1422 Create a new cell array from the objects stored in the struct object.\n\
1423 \n\
1424 If @var{f} is the number of fields in the structure, the resulting cell\n\
1425 array will have a dimension vector corresponding to\n\
1426 @code{[@var{f} size(@var{s})]}. For example:\n\
1427 \n\
1428 @example\n\
1429 @group\n\
1430 s = struct (\"name\", @{\"Peter\", \"Hannah\", \"Robert\"@},\n\
1431  \"age\", @{23, 16, 3@});\n\
1432 c = struct2cell (s)\n\
1433  @result{} c = @{2x1x3 Cell Array@}\n\
1434 c(1,1,:)(:)\n\
1435  @result{}\n\
1436  @{\n\
1437  [1,1] = Peter\n\
1438  [2,1] = Hannah\n\
1439  [3,1] = Robert\n\
1440  @}\n\
1441 c(2,1,:)(:)\n\
1442  @result{}\n\
1443  @{\n\
1444  [1,1] = 23\n\
1445  [2,1] = 16\n\
1446  [3,1] = 3\n\
1447  @}\n\
1448 @end group\n\
1449 @end example\n\
1450 \n\
1451 @seealso{cell2struct, fieldnames}\n\
1452 @end deftypefn")
1453 {
1454  octave_value retval;
1455 
1456  int nargin = args.length ();
1457 
1458  if (nargin == 1)
1459  {
1460  const octave_map m = args(0).map_value ();
1461 
1462  if (! error_state)
1463  {
1464  const dim_vector m_dv = m.dims ();
1465 
1466  octave_idx_type num_fields = m.nfields ();
1467 
1468  // The resulting dim_vector should have dimensions:
1469  // [numel(fields) size(struct)]
1470  // except if the struct is a column vector.
1471 
1472  dim_vector result_dv;
1473  if (m_dv (m_dv.length () - 1) == 1)
1474  result_dv.resize (m_dv.length ());
1475  else
1476  result_dv.resize (m_dv.length () + 1); // Add 1 for the fields.
1477 
1478  result_dv(0) = num_fields;
1479 
1480  for (int i = 1; i < result_dv.length (); i++)
1481  result_dv(i) = m_dv(i-1);
1482 
1483  NoAlias<Cell> c (result_dv);
1484 
1485  octave_idx_type n_elts = m.numel ();
1486 
1487  // Fill c in one sweep. Note that thanks to octave_map structure,
1488  // we don't need a key lookup at all.
1489  for (octave_idx_type j = 0; j < n_elts; j++)
1490  for (octave_idx_type i = 0; i < num_fields; i++)
1491  c(i,j) = m.contents(i)(j);
1492 
1493  retval = c;
1494  }
1495  else
1496  error ("struct2cell: argument S must be a structure");
1497  }
1498  else
1499  print_usage ();
1500 
1501  return retval;
1502 }
1503 
1504 /*
1505 %!test
1506 %! keys = cellstr (char (floor (rand (11,10)*24+65)))';
1507 %! vals = cellfun (@(x) mat2cell (rand (19,1), ones (19,1), 1), ...
1508 %! mat2cell ([1:11]', ones (11,1), 1), "uniformoutput", false)';
1509 %! s = struct ([keys; vals]{:});
1510 %! t = cell2struct ([vals{:}], keys, 2);
1511 %! assert (s, t);
1512 %! assert (struct2cell (s), [vals{:}]');
1513 %! assert (fieldnames (s), keys');
1514 */
1515 
1516 mxArray *
1518 {
1519  mxArray *retval = new mxArray (dims ());
1520 
1521  mxArray **elts = static_cast<mxArray **> (retval->get_data ());
1522 
1523  mwSize nel = numel ();
1524 
1525  const octave_value *p = matrix.data ();
1526 
1527  for (mwIndex i = 0; i < nel; i++)
1528  elts[i] = new mxArray (p[i]);
1529 
1530  return retval;
1531 }
1532 
1535 {
1536  switch (umap)
1537  {
1538 #define FORWARD_MAPPER(UMAP) \
1539  case umap_ ## UMAP: \
1540  return matrix.UMAP ()
1541  FORWARD_MAPPER (xisalnum);
1542  FORWARD_MAPPER (xisalpha);
1544  FORWARD_MAPPER (xiscntrl);
1545  FORWARD_MAPPER (xisdigit);
1546  FORWARD_MAPPER (xisgraph);
1547  FORWARD_MAPPER (xislower);
1548  FORWARD_MAPPER (xisprint);
1549  FORWARD_MAPPER (xispunct);
1550  FORWARD_MAPPER (xisspace);
1551  FORWARD_MAPPER (xisupper);
1552  FORWARD_MAPPER (xisxdigit);
1554  FORWARD_MAPPER (xtolower);
1555  FORWARD_MAPPER (xtoupper);
1556 
1557  default:
1558  return octave_base_value::map (umap);
1559  }
1560 }
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-cell.cc:554
octave_value map(unary_mapper_t umap) const
Definition: ov-cell.cc:1534
void get_dimensions(const octave_value &a, const char *warn_for, dim_vector &dim)
Definition: utils.cc:1141
const Cell & contents(const_iterator p) const
Definition: oct-map.h:314
bool is_true(const std::string &s)
Definition: mkoctfile.cc:373
bool is_empty(void) const
Definition: Array.h:472
Definition: Cell.h:35
std::string str(char sep= 'x') const
Definition: dim-vector.cc:63
bool save_ascii(std::ostream &os)
Definition: ov-cell.cc:762
octave_refcount< octave_idx_type > count
Definition: ov-base.h:818
bool is_true(void) const
Definition: ov-cell.cc:588
const std::string & name(void) const
Definition: jit-typeinfo.h:142
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
Definition: ov-base-mat.cc:519
void increment_indent_level(void) const
Definition: ov-base.h:799
octave_idx_type columns(void) const
Definition: ov-base.h:301
Cell reshape(const dim_vector &new_dims) const
Definition: Cell.h:90
octave_idx_type max_length(void) const
Definition: str-vec.h:75
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Sort by rows returns only indices.
Definition: Array.cc:2086
void assign(const octave_value_list &idx, const MT &rhs)
Definition: ov-base-mat.cc:216
int ndims(void) const
Definition: Array.h:487
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
octave_value tc
Definition: ls-hdf5.h:150
sortmode
Definition: oct-sort.h:103
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:275
void gripe_load(const char *type) const
Definition: ov-base.cc:1258
static int xtoascii(int c)
Definition: ov-ch-mat.cc:169
octave_idx_type length(void) const
Definition: oct-obj.h:89
void delete_elements(const octave_value_list &idx)
Definition: ov-cell.cc:477
void delete_elements(const octave_value_list &idx)
Definition: ov-base-mat.cc:378
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
Definition: ov-cell.cc:985
bool is_defined(void) const
Definition: ov.h:520
void * mex_get_data(void) const
Give a pointer to the data in mex format.
Definition: Array.h:605
octave_idx_type numel(void) const
Definition: ov-base-mat.h:103
void resize(int n, int fill_value=0)
Definition: dim-vector.h:287
static void gripe_failed_assignment(void)
Definition: ov-cell.cc:132
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-cell.cc:495
void error(const char *fmt,...)
Definition: error.cc:476
Cell cell_value(void) const
Definition: ov-cell.h:136
void indent(std::ostream &os) const
Definition: ov-base.cc:1481
void * get_data(void) const
Definition: mxarray.h:433
#define FORWARD_MAPPER(UMAP)
std::auto_ptr< Array< std::string > > cellstr_cache
Definition: ov-cell.h:181
void make_unique(void)
Definition: ov.h:326
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:164
void gripe_save(const char *type) const
Definition: ov-base.cc:1267
bool is_cell(void) const
Definition: ov.h:529
octave_value_list list_value(void) const
Definition: ov-cell.cc:595
T & elem(octave_idx_type n)
Definition: Array.h:380
octave_idx_type numel(void) const
Definition: oct-map.h:372
herr_t hdf5_read_next_data(hid_t group_id, const char *name, void *dv)
Definition: ls-hdf5.cc:249
OCTAVE_EXPORT octave_value_list Fiscellstr(const octave_value_list &args, int)
Definition: ov-cell.cc:1363
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-cell.cc:696
void newline(std::ostream &os) const
Definition: ov-base.cc:1500
bool is_empty(void) const
Definition: ov-base.h:335
static void check_dimensions(octave_idx_type &nr, octave_idx_type &nc, const char *warnfor)
Definition: utils.cc:1108
octave_idx_type rows(void) const
Definition: Array.h:313
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:361
F77_RET_T const double const double double * d
int load_hdf5_empty(hid_t loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:790
void gripe_indexed_cs_list(void)
Definition: gripes.cc:223
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov.cc:1414
Cell cell_value(void) const
Definition: ov.cc:1566
OCTAVE_EMPTY_CPP_ARG std::string type_name(void) const
Definition: ov-cell.h:184
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov-cell.cc:690
size_t byte_size(void) const
Definition: ov-cell.cc:484
size_t byte_size(void) const
Definition: Array.h:333
Array< std::string > cellstr_value(void) const
Definition: Cell.cc:146
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-ascii.cc:80
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:59
bool is_null_value(void) const
Definition: ov.h:592
Array< T > sort(int dim=0, sortmode mode=ASCENDING) const
Definition: Array.cc:1766
void gripe_nonbraced_cs_list_assignment(void)
Definition: gripes.cc:229
octave_idx_type nfields(void) const
Definition: oct-map.h:327
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
Definition: ov-base-mat.cc:133
octave_idx_type numel(const octave_value_list &idx)
Definition: ov.h:395
void make_unique(void)
Definition: Array.h:104
Array< std::string > cellstr_value(void) const
Definition: ov-cell.cc:666
bool add_hdf5_data(hid_t loc_id, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
Definition: ls-hdf5.cc:868
bool save_ascii_data(std::ostream &os, const octave_value &val_arg, const std::string &name, bool mark_as_global, int precision)
const T * data(void) const
Definition: Array.h:479
int error_state
Definition: error.cc:101
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1033
dim_vector dims(void) const
Definition: oct-map.h:400
void clear_cellstr_cache(void) const
Definition: ov-cell.h:178
bool is_cellstr(void) const
Definition: ov.h:532
#define panic_impossible()
Definition: error.h:33
std::string read_binary_data(std::istream &is, bool swap, oct_mach_info::float_format fmt, const std::string &filename, bool &global, octave_value &tc, std::string &doc)
dim_vector redim(int n) const
Definition: dim-vector.cc:266
bool is_cellstr(void) const
Definition: Cell.cc:127
octave_idx_type length(void) const
Definition: ov.cc:1525
Definition: dMatrix.h:35
mxArray * as_mxArray(void) const
Definition: ov-cell.cc:1517
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-cell.cc:1168
void * mex_get_data(void) const
Definition: ov-cell.cc:1063
void decrement_indent_level(void) const
Definition: ov-base.h:802
void mxArray
Definition: mex.h:53
friend class octave_value
Definition: ov-base.h:206
dim_vector dims(void) const
Definition: ov-base-mat.h:101
sortmode is_sorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2051
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-cell.h:74
octave_idx_type length(void) const
Number of elements in the array.
Definition: Array.h:267
#define H5T_NATIVE_IDX
Definition: ls-hdf5.h:209
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-cell.cc:1070
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
Definition: Array.h:762
bool Vprint_empty_dimensions
Definition: pr-output.cc:75
string_vector all_strings(bool pad=false) const
Definition: ov-cell.cc:601
bool print_as_scalar(void) const
Definition: ov-cell.cc:684
octave_cell(void)
Definition: ov-cell.h:52
bool save_binary(std::ostream &os, bool &save_as_floats)
Definition: ov-cell.cc:952
bool save_binary_data(std::ostream &os, const octave_value &tc, const std::string &name, const std::string &doc, bool mark_as_global, bool save_as_floats)
const octave_base_value & get_rep(void) const
Definition: ov.h:1085
bool is_cs_list(void) const
Definition: ov.h:586
void print_with_name(std::ostream &os, const std::string &name) const
Definition: ov.h:1040
Cell index(const octave_value_list &idx, bool resize_ok=false) const
Definition: Cell.cc:159
octave_value fast_elem_extract(octave_idx_type n) const
Definition: ov-base-mat.cc:509
int save_hdf5_empty(hid_t loc_id, const char *name, const dim_vector d)
Definition: ls-hdf5.cc:740
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1276
bool is_cellstr(void) const
Definition: ov-cell.cc:445
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
Definition: ov-cell.cc:241
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-cell.cc:571
static const pair_type keywords[]
Definition: help.cc:445
octave_value_list list_value(void) const
Definition: ov.cc:1633
void assign(const octave_value_list &idx, const Cell &rhs)
Definition: ov-cell.cc:462
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:282
void short_disp(std::ostream &os) const
Definition: ov-cell.cc:754
bool all_scalars(void) const
Definition: oct-obj.cc:181
octave_idx_type cols(void) const
Definition: Array.h:321
bool load_ascii(std::istream &is)
Definition: ov-cell.cc:816
sortmode is_sorted(sortmode mode=UNSORTED) const
Definition: ov-cell.cc:536
octave_value storable_value(void) const
Definition: ov.cc:1930
void chop_trailing_singletons(void)
Definition: dim-vector.h:214
int length(void) const
Definition: dim-vector.h:281
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2105
bool is_zero_by_zero(void) const
Definition: ov.h:680
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
Definition: ov.cc:1317
octave_idx_type rows(void) const
Definition: ov-base.h:294
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
Definition: ov.cc:2829
F77_RET_T const double * x
static int xisascii(int c)
Definition: ov-ch-mat.cc:160
std::string read_ascii_data(std::istream &is, const std::string &filename, bool &global, octave_value &tc, octave_idx_type count)
#define CELL_ELT_TAG
Definition: ov-cell.cc:759