GNU Octave  4.2.1
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
pt-mat.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <iostream>
28 
29 #include "oct-locbuf.h"
30 #include "quit.h"
31 
32 #include "data.h"
33 #include "defun.h"
34 #include "error.h"
35 #include "errwarn.h"
36 #include "oct-map.h"
37 #include "ovl.h"
38 #include "pt-arg-list.h"
39 #include "pt-bp.h"
40 #include "pt-exp.h"
41 #include "pt-mat.h"
42 #include "pt-walk.h"
43 #include "utils.h"
44 #include "ov.h"
45 #include "variables.h"
46 
47 #include "ov-cx-mat.h"
48 #include "ov-flt-cx-mat.h"
49 #include "ov-re-sparse.h"
50 #include "ov-cx-sparse.h"
51 
52 // The character to fill with when creating string arrays.
53 char Vstring_fill_char = ' ';
54 
55 // General matrices. This list type is much more work to handle than
56 // constant matrices, but it allows us to construct matrices from
57 // other matrices, variables, and functions.
58 
59 // But first, some internal classes that make our job much easier.
60 
61 class
63 {
64 private:
65 
66  class
68  {
69  public:
70 
72  : count (1), dv (0, 0), all_str (false),
73  all_sq_str (false), all_dq_str (false),
74  some_str (false), all_real (false), all_cmplx (false),
75  all_mt (true), any_cell (false), any_sparse (false),
76  any_class (false), all_1x1 (false),
77  first_elem_is_struct (false), class_nm (), ok (false)
78  { }
79 
81  : count (1), dv (0, 0), all_str (false), all_sq_str (false),
82  some_str (false), all_real (false), all_cmplx (false),
83  all_mt (true), any_cell (false), any_sparse (false),
84  any_class (false), all_1x1 (! row.empty ()),
85  first_elem_is_struct (false), class_nm (), ok (false)
86  { init (row); }
87 
88  ~tm_row_const_rep (void) { }
89 
91 
93 
94  bool all_str;
95  bool all_sq_str;
96  bool all_dq_str;
97  bool some_str;
98  bool all_real;
99  bool all_cmplx;
100  bool all_mt;
101  bool any_cell;
103  bool any_class;
104  bool all_1x1;
106 
108 
109  bool ok;
110 
111  void do_init_element (const octave_value&, bool&);
112 
113  void init (const tree_argument_list&);
114 
115  void cellify (void);
116 
117  private:
118 
120 
121  tm_row_const_rep& operator = (const tm_row_const_rep&);
122 
123  };
124 
125 public:
126 
129 
131  : rep (0) { }
132 
134  : rep (new tm_row_const_rep (row)) { }
135 
137  : rep (x.rep)
138  {
139  if (rep)
140  rep->count++;
141  }
142 
143  tm_row_const& operator = (const tm_row_const& x)
144  {
145  if (this != &x && rep != x.rep)
146  {
147  if (rep && --rep->count == 0)
148  delete rep;
149 
150  rep = x.rep;
151 
152  if (rep)
153  rep->count++;
154  }
155 
156  return *this;
157  }
158 
160  {
161  if (rep && --rep->count == 0)
162  delete rep;
163  }
164 
165  octave_idx_type rows (void) { return rep->dv(0); }
166  octave_idx_type cols (void) { return rep->dv(1); }
167 
168  bool empty (void) const { return rep->empty (); }
169 
170  size_t length (void) const { return rep->length (); }
171 
172  dim_vector dims (void) { return rep->dv; }
173 
174  bool all_strings_p (void) const { return rep->all_str; }
175  bool all_sq_strings_p (void) const { return rep->all_sq_str; }
176  bool all_dq_strings_p (void) const { return rep->all_dq_str; }
177  bool some_strings_p (void) const { return rep->some_str; }
178  bool all_real_p (void) const { return rep->all_real; }
179  bool all_complex_p (void) const { return rep->all_cmplx; }
180  bool all_empty_p (void) const { return rep->all_mt; }
181  bool any_cell_p (void) const { return rep->any_cell; }
182  bool any_sparse_p (void) const { return rep->any_sparse; }
183  bool any_class_p (void) const { return rep->any_class; }
184  bool all_1x1_p (void) const { return rep->all_1x1; }
185  bool first_elem_struct_p (void) const { return rep->first_elem_is_struct; }
186 
187  std::string class_name (void) const { return rep->class_nm; }
188 
189  void cellify (void) { rep->cellify (); }
190 
191  operator bool () const { return (rep && rep->ok); }
192 
193  iterator begin (void) { return rep->begin (); }
194  const_iterator begin (void) const { return rep->begin (); }
195 
196  iterator end (void) { return rep->end (); }
197  const_iterator end (void) const { return rep->end (); }
198 
199 private:
200 
202 };
203 
206 {
208 
209  if (c1 == c2)
210  retval = c1;
211  else if (c1.empty ())
212  retval = c2;
213  else if (c2.empty ())
214  retval = c1;
215  else if (c1 == "class" || c2 == "class")
216  retval = "class";
217  else
218  {
219  bool c1_is_int = (c1 == "int8" || c1 == "uint8"
220  || c1 == "int16" || c1 == "uint16"
221  || c1 == "int32" || c1 == "uint32"
222  || c1 == "int64" || c1 == "uint64");
223  bool c2_is_int = (c2 == "int8" || c2 == "uint8"
224  || c2 == "int16" || c2 == "uint16"
225  || c2 == "int32" || c2 == "uint32"
226  || c2 == "int64" || c2 == "uint64");
227 
228  bool c1_is_char = (c1 == "char");
229  bool c2_is_char = (c2 == "char");
230 
231  bool c1_is_double = (c1 == "double");
232  bool c2_is_double = (c2 == "double");
233 
234  bool c1_is_single = (c1 == "single");
235  bool c2_is_single = (c2 == "single");
236 
237  bool c1_is_logical = (c1 == "logical");
238  bool c2_is_logical = (c2 == "logical");
239 
240  bool c1_is_built_in_type
241  = (c1_is_int || c1_is_char || c1_is_double || c1_is_single
242  || c1_is_logical);
243 
244  bool c2_is_built_in_type
245  = (c2_is_int || c2_is_char || c2_is_double || c2_is_single
246  || c2_is_logical);
247 
248  // Order is important here...
249 
250  if (c1 == "struct" && c2 == c1)
251  retval = c1;
252  else if (c1 == "cell" || c2 == "cell")
253  retval = "cell";
254  else if (c1_is_char && c2_is_built_in_type)
255  retval = c1;
256  else if (c2_is_char && c1_is_built_in_type)
257  retval = c2;
258  else if (c1_is_int && c2_is_built_in_type)
259  retval = c1;
260  else if (c2_is_int && c1_is_built_in_type)
261  retval = c2;
262  else if (c1_is_single && c2_is_built_in_type)
263  retval = c1;
264  else if (c2_is_single && c1_is_built_in_type)
265  retval = c2;
266  else if (c1_is_double && c2_is_built_in_type)
267  retval = c1;
268  else if (c2_is_double && c1_is_built_in_type)
269  retval = c2;
270  else if (c1_is_logical && c2_is_logical)
271  retval = c1;
272  }
273 
274  return retval;
275 }
276 
277 OCTAVE_NORETURN static
278 void
279 eval_error (const char *msg, const dim_vector& x, const dim_vector& y)
280 {
281  error ("%s (%s vs %s)", msg, x.str ().c_str (), y.str ().c_str ());
282 }
283 
284 void
286  bool& first_elem)
287 {
288  std::string this_elt_class_nm
289  = val.is_object () ? std::string ("class") : val.class_name ();
290 
291  class_nm = get_concat_class (class_nm, this_elt_class_nm);
292 
293  dim_vector this_elt_dv = val.dims ();
294 
295  if (! this_elt_dv.zero_by_zero ())
296  {
297  all_mt = false;
298 
299  if (first_elem)
300  {
301  if (val.is_map ())
302  first_elem_is_struct = true;
303 
304  first_elem = false;
305  }
306  }
307 
308  append (val);
309 
310  if (all_str && ! val.is_string ())
311  all_str = false;
312 
313  if (all_sq_str && ! val.is_sq_string ())
314  all_sq_str = false;
315 
316  if (all_dq_str && ! val.is_dq_string ())
317  all_dq_str = false;
318 
319  if (! some_str && val.is_string ())
320  some_str = true;
321 
322  if (all_real && ! val.is_real_type ())
323  all_real = false;
324 
325  if (all_cmplx && ! (val.is_complex_type () || val.is_real_type ()))
326  all_cmplx = false;
327 
328  if (! any_cell && val.is_cell ())
329  any_cell = true;
330 
331  if (! any_sparse && val.is_sparse_type ())
332  any_sparse = true;
333 
334  if (! any_class && val.is_object ())
335  any_class = true;
336 
337  // Special treatment of sparse matrices to avoid out-of-memory error
338  all_1x1 = all_1x1 && ! val.is_sparse_type () && val.numel () == 1;
339 }
340 
341 void
343 {
344  all_str = true;
345  all_sq_str = true;
346  all_dq_str = true;
347  all_real = true;
348  all_cmplx = true;
349  any_cell = false;
350  any_sparse = false;
351  any_class = false;
352 
353  bool first_elem = true;
354 
356  p != row.end ();
357  p++)
358  {
359  octave_quit ();
360 
361  tree_expression *elt = *p;
362 
363  octave_value tmp = elt->rvalue1 ();
364 
365  if (tmp.is_undefined ())
366  {
367  ok = true;
368  return;
369  }
370  else
371  {
372  if (tmp.is_cs_list ())
373  {
374  octave_value_list tlst = tmp.list_value ();
375 
376  for (octave_idx_type i = 0; i < tlst.length (); i++)
377  {
378  octave_quit ();
379 
380  do_init_element (tlst(i), first_elem);
381  }
382  }
383  else
384  do_init_element (tmp, first_elem);
385  }
386  }
387 
388  if (any_cell && ! any_class && ! first_elem_is_struct)
389  cellify ();
390 
391  first_elem = true;
392 
393  for (iterator p = begin (); p != end (); p++)
394  {
395  octave_quit ();
396 
397  octave_value val = *p;
398 
399  dim_vector this_elt_dv = val.dims ();
400 
401  if (! this_elt_dv.zero_by_zero ())
402  {
403  all_mt = false;
404 
405  if (first_elem)
406  {
407  first_elem = false;
408  dv = this_elt_dv;
409  }
410  else if ((! any_class) && (! dv.hvcat (this_elt_dv, 1)))
411  eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
412  }
413  }
414 
415  ok = true;
416 }
417 
418 void
420 {
421  bool elt_changed = false;
422 
423  for (iterator p = begin (); p != end (); p++)
424  {
425  octave_quit ();
426 
427  if (! p->is_cell ())
428  {
429  elt_changed = true;
430 
431  if (p->is_empty ())
432  *p = Cell ();
433  else
434  *p = Cell (*p);
435  }
436  }
437 
438  if (elt_changed)
439  {
440  bool first_elem = true;
441 
442  for (iterator p = begin (); p != end (); p++)
443  {
444  octave_quit ();
445 
446  octave_value val = *p;
447 
448  dim_vector this_elt_dv = val.dims ();
449 
450  if (! this_elt_dv.zero_by_zero ())
451  {
452  if (first_elem)
453  {
454  first_elem = false;
455  dv = this_elt_dv;
456  }
457  else if (! dv.hvcat (this_elt_dv, 1))
458  eval_error ("horizontal dimensions mismatch", dv, this_elt_dv);
459  }
460  }
461  }
462 }
463 
464 class
466 {
467 public:
468 
469  tm_const (const tree_matrix& tm)
470  : dv (0, 0), all_str (false), all_sq_str (false), all_dq_str (false),
471  some_str (false), all_real (false), all_cmplx (false),
472  all_mt (true), any_cell (false), any_sparse (false),
473  any_class (false), class_nm (), ok (false)
474  { init (tm); }
475 
476  ~tm_const (void) { }
477 
478  octave_idx_type rows (void) const { return dv.elem (0); }
479  octave_idx_type cols (void) const { return dv.elem (1); }
480 
481  dim_vector dims (void) const { return dv; }
482 
483  bool all_strings_p (void) const { return all_str; }
484  bool all_sq_strings_p (void) const { return all_sq_str; }
485  bool all_dq_strings_p (void) const { return all_dq_str; }
486  bool some_strings_p (void) const { return some_str; }
487  bool all_real_p (void) const { return all_real; }
488  bool all_complex_p (void) const { return all_cmplx; }
489  bool all_empty_p (void) const { return all_mt; }
490  bool any_cell_p (void) const { return any_cell; }
491  bool any_sparse_p (void) const { return any_sparse; }
492  bool any_class_p (void) const { return any_class; }
493  bool all_1x1_p (void) const { return all_1x1; }
494 
495  std::string class_name (void) const { return class_nm; }
496 
497  operator bool () const { return ok; }
498 
499 private:
500 
502 
503  bool all_str;
506  bool some_str;
507  bool all_real;
508  bool all_cmplx;
509  bool all_mt;
510  bool any_cell;
512  bool any_class;
513  bool all_1x1;
514 
516 
517  bool ok;
518 
519  tm_const (void);
520 
521  tm_const (const tm_const&);
522 
523  tm_const& operator = (const tm_const&);
524 
525  void init (const tree_matrix& tm);
526 };
527 
528 void
530 {
531  all_str = true;
532  all_sq_str = true;
533  all_dq_str = true;
534  all_real = true;
535  all_cmplx = true;
536  any_cell = false;
537  any_sparse = false;
538  any_class = false;
539  all_1x1 = ! tm.empty ();
540 
541  bool first_elem = true;
542  bool first_elem_is_struct = false;
543 
544  // Just eval and figure out if what we have is complex or all
545  // strings. We can't check columns until we know that this is a
546  // numeric matrix -- collections of strings can have elements of
547  // different lengths.
548 
549  for (tree_matrix::const_iterator p = tm.begin (); p != tm.end (); p++)
550  {
551  octave_quit ();
552 
553  tree_argument_list *elt = *p;
554 
555  tm_row_const tmp (*elt);
556 
557  if (first_elem)
558  {
559  first_elem_is_struct = tmp.first_elem_struct_p ();
560 
561  first_elem = false;
562  }
563 
564  if (tmp && ! tmp.empty ())
565  {
566  if (all_str && ! tmp.all_strings_p ())
567  all_str = false;
568 
569  if (all_sq_str && ! tmp.all_sq_strings_p ())
570  all_sq_str = false;
571 
572  if (all_dq_str && ! tmp.all_dq_strings_p ())
573  all_dq_str = false;
574 
575  if (! some_str && tmp.some_strings_p ())
576  some_str = true;
577 
578  if (all_real && ! tmp.all_real_p ())
579  all_real = false;
580 
581  if (all_cmplx && ! tmp.all_complex_p ())
582  all_cmplx = false;
583 
584  if (all_mt && ! tmp.all_empty_p ())
585  all_mt = false;
586 
587  if (! any_cell && tmp.any_cell_p ())
588  any_cell = true;
589 
590  if (! any_sparse && tmp.any_sparse_p ())
591  any_sparse = true;
592 
593  if (! any_class && tmp.any_class_p ())
594  any_class = true;
595 
596  all_1x1 = all_1x1 && tmp.all_1x1_p ();
597 
598  append (tmp);
599  }
600  else
601  break;
602  }
603 
604  if (any_cell && ! any_class && ! first_elem_is_struct)
605  {
606  for (iterator q = begin (); q != end (); q++)
607  {
608  octave_quit ();
609 
610  q->cellify ();
611  }
612  }
613 
614  first_elem = true;
615 
616  for (iterator q = begin (); q != end (); q++)
617  {
618  octave_quit ();
619 
620  tm_row_const elt = *q;
621 
622  octave_idx_type this_elt_nr = elt.rows ();
623  octave_idx_type this_elt_nc = elt.cols ();
624 
625  std::string this_elt_class_nm = elt.class_name ();
626  class_nm = get_concat_class (class_nm, this_elt_class_nm);
627 
628  dim_vector this_elt_dv = elt.dims ();
629 
630  all_mt = false;
631 
632  if (first_elem)
633  {
634  first_elem = false;
635 
636  dv = this_elt_dv;
637  }
638  else if (all_str && dv.ndims () == 2
639  && this_elt_dv.ndims () == 2)
640  {
641  // FIXME: this is Octave's specialty.
642  // Character matrices allow rows of unequal length.
643  if (this_elt_nc > cols ())
644  dv(1) = this_elt_nc;
645  dv(0) += this_elt_nr;
646  }
647  else if ((! any_class) && (! dv.hvcat (this_elt_dv, 0)))
648  eval_error ("vertical dimensions mismatch", dv, this_elt_dv);
649  }
650 
651  ok = true;
652 }
653 
656 {
657  if (nargout > 1)
658  error ("invalid number of output arguments for matrix list");
659 
660  return rvalue1 (nargout);
661 }
662 
663 void
665 {
666  if (! (all_dq_strings_p || all_sq_strings_p))
667  warning_with_id ("Octave:mixed-string-concat",
668  "concatenation of different character string types may have unintended consequences");
669 }
670 
671 template <typename TYPE, typename T>
672 static void
674  tm_const& tmp)
675 {
676  octave_idx_type r = 0;
677  octave_idx_type c = 0;
678 
679  for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
680  {
681  tm_row_const row = *p;
682  // Skip empty arrays to allow looser rules.
683  if (row.dims ().any_zero ())
684  continue;
685 
686  for (tm_row_const::iterator q = row.begin ();
687  q != row.end ();
688  q++)
689  {
690  octave_quit ();
691 
692  TYPE ra = octave_value_extract<TYPE> (*q);
693 
694  // Skip empty arrays to allow looser rules.
695 
696  if (! ra.is_empty ())
697  {
698  result.insert (ra, r, c);
699 
700  c += ra.columns ();
701  }
702  }
703 
704  r += row.rows ();
705  c = 0;
706  }
707 }
708 
709 template <typename TYPE, typename T>
710 static void
712  const dim_vector& dv,
713  tm_const& tmp)
714 {
715  if (dv.any_zero ())
716  {
717  result = Array<T> (dv);
718  return;
719  }
720 
721  if (tmp.length () == 1)
722  {
723  // If possible, forward the operation to liboctave.
724  // Single row.
725  tm_row_const& row = tmp.front ();
727  && row.all_1x1_p ())
728  {
729  // Optimize all scalars case.
730  result.clear (dv);
731  assert (static_cast<size_t> (result.numel ()) == row.length ());
732  octave_idx_type i = 0;
733  for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
734  result(i++) = octave_value_extract<T> (*q);
735 
736  return;
737  }
738 
739  octave_idx_type ncols = row.length ();
740  octave_idx_type i = 0;
741  OCTAVE_LOCAL_BUFFER (Array<T>, array_list, ncols);
742 
743  for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
744  {
745  octave_quit ();
746 
747  array_list[i] = octave_value_extract<TYPE> (*q);
748  i++;
749  }
750 
751  result = Array<T>::cat (-2, ncols, array_list);
752  }
753  else
754  {
755  result = Array<T> (dv);
756  single_type_concat<TYPE> (result, tmp);
757  }
758 }
759 
760 template <typename TYPE, typename T>
761 static void
763  const dim_vector& dv,
764  tm_const& tmp)
765 {
766  if (dv.any_zero ())
767  {
768  result = Sparse<T> (dv);
769  return;
770  }
771 
772  // Sparse matrices require preallocation for efficient indexing; besides,
773  // only horizontal concatenation can be efficiently handled by indexing.
774  // So we just cat all rows through liboctave, then cat the final column.
775  octave_idx_type nrows = tmp.length ();
776  octave_idx_type j = 0;
777  OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_row_list, nrows);
778  for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
779  {
780  tm_row_const row = *p;
781  octave_idx_type ncols = row.length ();
782  octave_idx_type i = 0;
783  OCTAVE_LOCAL_BUFFER (Sparse<T>, sparse_list, ncols);
784 
785  for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
786  {
787  octave_quit ();
788 
789  sparse_list[i] = octave_value_extract<TYPE> (*q);
790  i++;
791  }
792 
793  Sparse<T> stmp = Sparse<T>::cat (-2, ncols, sparse_list);
794  sparse_row_list[j] = stmp;
795  j++;
796  }
797 
798  result = Sparse<T>::cat (-1, nrows, sparse_row_list);
799 }
800 
801 template <typename MAP>
802 static void
804  const dim_vector& dv,
805  tm_const& tmp)
806 {
807  if (dv.any_zero ())
808  {
809  result = octave_map (dv);
810  return;
811  }
812 
813  octave_idx_type nrows = tmp.length ();
814  octave_idx_type j = 0;
815  OCTAVE_LOCAL_BUFFER (octave_map, map_row_list, nrows);
816  for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
817  {
818  tm_row_const row = *p;
819  octave_idx_type ncols = row.length ();
820  octave_idx_type i = 0;
821  OCTAVE_LOCAL_BUFFER (MAP, map_list, ncols);
822 
823  for (tm_row_const::iterator q = row.begin (); q != row.end (); q++)
824  {
825  octave_quit ();
826 
827  map_list[i] = octave_value_extract<MAP> (*q);
828  i++;
829  }
830 
831  octave_map mtmp = octave_map::cat (-2, ncols, map_list);
832  map_row_list[j] = mtmp;
833  j++;
834  }
835 
836  result = octave_map::cat (-1, nrows, map_row_list);
837 }
838 
839 template <typename TYPE>
840 static octave_value
842  tm_const& tmp)
843 {
844  TYPE result;
845 
846  single_type_concat<TYPE> (result, dv, tmp);
847 
848  return result;
849 }
850 
851 template <>
854  tm_const& tmp)
855 {
857 
858  if (tmp.all_1x1_p ())
859  single_type_concat<octave_scalar_map> (result, dv, tmp);
860  else
861  single_type_concat<octave_map> (result, dv, tmp);
862 
863  return result;
864 }
865 
866 static octave_value
868 {
870 
872 
873  octave_idx_type j = 0;
874  for (tm_const::iterator p = tmc.begin (); p != tmc.end (); p++)
875  {
876  octave_quit ();
877 
878  tm_row_const tmrc = *p;
879 
880  if (tmrc.length () == 1)
881  rows(j++) = *(tmrc.begin ());
882  else
883  {
885 
886  octave_idx_type i = 0;
887  for (tm_row_const::iterator q = tmrc.begin (); q != tmrc.end (); q++)
888  row(i++) = *q;
889 
890  rows(j++) = do_class_concat (row, "horzcat", 1);
891  }
892  }
893 
894  if (rows.length () == 1)
895  retval = rows(0);
896  else
897  retval = do_class_concat (rows, "vertcat", 0);
898 
899  return retval;
900 }
901 
904 {
906 
907  bool all_strings_p = false;
908  bool all_sq_strings_p = false;
909  bool all_dq_strings_p = false;
910  bool all_empty_p = false;
911  bool all_real_p = false;
912  bool any_sparse_p = false;
913  bool any_class_p = false;
914  bool frc_str_conv = false;
915 
916  tm_const tmp (*this);
917 
918  if (tmp && ! tmp.empty ())
919  {
920  dim_vector dv = tmp.dims ();
921  all_strings_p = tmp.all_strings_p ();
922  all_sq_strings_p = tmp.all_sq_strings_p ();
923  all_dq_strings_p = tmp.all_dq_strings_p ();
924  all_empty_p = tmp.all_empty_p ();
925  all_real_p = tmp.all_real_p ();
926  any_sparse_p = tmp.any_sparse_p ();
927  any_class_p = tmp.any_class_p ();
928  frc_str_conv = tmp.some_strings_p ();
929 
930  // Try to speed up the common cases.
931 
932  std::string result_type = tmp.class_name ();
933 
934  if (any_class_p)
935  {
936  retval = do_class_concat (tmp);
937  }
938  else if (result_type == "double")
939  {
940  if (any_sparse_p)
941  {
942  if (all_real_p)
943  retval = do_single_type_concat<SparseMatrix> (dv, tmp);
944  else
945  retval = do_single_type_concat<SparseComplexMatrix> (dv, tmp);
946  }
947  else
948  {
949  if (all_real_p)
950  retval = do_single_type_concat<NDArray> (dv, tmp);
951  else
952  retval = do_single_type_concat<ComplexNDArray> (dv, tmp);
953  }
954  }
955  else if (result_type == "single")
956  {
957  if (all_real_p)
958  retval = do_single_type_concat<FloatNDArray> (dv, tmp);
959  else
960  retval = do_single_type_concat<FloatComplexNDArray> (dv, tmp);
961  }
962  else if (result_type == "char")
963  {
964  char type = all_dq_strings_p ? '"' : '\'';
965 
966  if (! all_strings_p)
967  warn_implicit_conversion ("Octave:num-to-str",
968  "numeric", result_type);
969  else
970  maybe_warn_string_concat (all_dq_strings_p, all_sq_strings_p);
971 
973 
974  single_type_concat<charNDArray> (result, tmp);
975 
976  retval = octave_value (result, type);
977  }
978  else if (result_type == "logical")
979  {
980  if (any_sparse_p)
981  retval = do_single_type_concat<SparseBoolMatrix> (dv, tmp);
982  else
983  retval = do_single_type_concat<boolNDArray> (dv, tmp);
984  }
985  else if (result_type == "int8")
986  retval = do_single_type_concat<int8NDArray> (dv, tmp);
987  else if (result_type == "int16")
988  retval = do_single_type_concat<int16NDArray> (dv, tmp);
989  else if (result_type == "int32")
990  retval = do_single_type_concat<int32NDArray> (dv, tmp);
991  else if (result_type == "int64")
992  retval = do_single_type_concat<int64NDArray> (dv, tmp);
993  else if (result_type == "uint8")
994  retval = do_single_type_concat<uint8NDArray> (dv, tmp);
995  else if (result_type == "uint16")
996  retval = do_single_type_concat<uint16NDArray> (dv, tmp);
997  else if (result_type == "uint32")
998  retval = do_single_type_concat<uint32NDArray> (dv, tmp);
999  else if (result_type == "uint64")
1000  retval = do_single_type_concat<uint64NDArray> (dv, tmp);
1001  else if (result_type == "cell")
1002  retval = do_single_type_concat<Cell> (dv, tmp);
1003  else if (result_type == "struct")
1005  else
1006  {
1007  // The line below might seem crazy, since we take a copy of
1008  // the first argument, resize it to be empty and then resize
1009  // it to be full. This is done since it means that there is
1010  // no recopying of data, as would happen if we used a single
1011  // resize. It should be noted that resize operation is also
1012  // significantly slower than the do_cat_op function, so it
1013  // makes sense to have an empty matrix and copy all data.
1014  //
1015  // We might also start with a empty octave_value using
1016  //
1017  // ctmp = octave_value_typeinfo::lookup_type
1018  // (tmp.begin() -> begin() -> type_name());
1019  //
1020  // and then directly resize. However, for some types there
1021  // might be some additional setup needed, and so this should
1022  // be avoided.
1023 
1024  octave_value ctmp;
1025 
1026  // Find the first non-empty object
1027 
1028  if (any_sparse_p)
1029  {
1030  // Start with sparse matrix to avoid issues memory issues
1031  // with things like [ones(1,4),sprandn(1e8,4,1e-4)]
1032  if (all_real_p)
1033  ctmp = octave_sparse_matrix ().resize (dv);
1034  else
1035  ctmp = octave_sparse_complex_matrix ().resize (dv);
1036  }
1037  else
1038  {
1039  for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
1040  {
1041  octave_quit ();
1042 
1043  tm_row_const row = *p;
1044 
1045  for (tm_row_const::iterator q = row.begin ();
1046  q != row.end (); q++)
1047  {
1048  octave_quit ();
1049 
1050  ctmp = *q;
1051 
1052  if (! ctmp.all_zero_dims ())
1053  goto found_non_empty;
1054  }
1055  }
1056 
1057  ctmp = (*(tmp.begin () -> begin ()));
1058 
1059  found_non_empty:
1060 
1061  if (! all_empty_p)
1062  ctmp = ctmp.resize (dim_vector (0,0)).resize (dv);
1063  }
1064 
1065  // Now, extract the values from the individual elements and
1066  // insert them in the result matrix.
1067 
1068  int dv_len = dv.ndims ();
1069  octave_idx_type ntmp = dv_len > 1 ? dv_len : 2;
1070  Array<octave_idx_type> ra_idx (dim_vector (ntmp, 1), 0);
1071 
1072  for (tm_const::iterator p = tmp.begin (); p != tmp.end (); p++)
1073  {
1074  octave_quit ();
1075 
1076  tm_row_const row = *p;
1077 
1078  for (tm_row_const::iterator q = row.begin ();
1079  q != row.end ();
1080  q++)
1081  {
1082  octave_quit ();
1083 
1084  octave_value elt = *q;
1085 
1086  if (elt.is_empty ())
1087  continue;
1088 
1089  ctmp = do_cat_op (ctmp, elt, ra_idx);
1090 
1091  ra_idx (1) += elt.columns ();
1092  }
1093 
1094  ra_idx (0) += row.rows ();
1095  ra_idx (1) = 0;
1096  }
1097 
1098  retval = ctmp;
1099 
1100  if (frc_str_conv && ! retval.is_string ())
1101  retval = retval.convert_to_str ();
1102  }
1103  }
1104 
1105  return retval;
1106 }
1107 
1111 {
1112  tree_matrix *new_matrix = new tree_matrix (0, line (), column ());
1113 
1114  new_matrix->copy_base (*this, scope, context);
1115 
1116  return new_matrix;
1117 }
1118 
1119 void
1121 {
1122  tw.visit_matrix (*this);
1123 }
1124 
1125 /*
1126 ## test concatenation with all zero matrices
1127 %!assert ([ "" 65*ones(1,10) ], "AAAAAAAAAA")
1128 %!assert ([ 65*ones(1,10) "" ], "AAAAAAAAAA")
1129 
1130 %!test
1131 %! c = {"foo"; "bar"; "bazoloa"};
1132 %! assert ([c; "a"; "bc"; "def"], {"foo"; "bar"; "bazoloa"; "a"; "bc"; "def"});
1133 
1134 %!assert (class ([int64(1), int64(1)]), "int64")
1135 %!assert (class ([int64(1), int32(1)]), "int64")
1136 %!assert (class ([int64(1), int16(1)]), "int64")
1137 %!assert (class ([int64(1), int8(1)]), "int64")
1138 %!assert (class ([int64(1), uint64(1)]), "int64")
1139 %!assert (class ([int64(1), uint32(1)]), "int64")
1140 %!assert (class ([int64(1), uint16(1)]), "int64")
1141 %!assert (class ([int64(1), uint8(1)]), "int64")
1142 %!assert (class ([int64(1), single(1)]), "int64")
1143 %!assert (class ([int64(1), double(1)]), "int64")
1144 %!assert (class ([int64(1), cell(1)]), "cell")
1145 %!assert (class ([int64(1), true]), "int64")
1146 %!assert (class ([int64(1), "a"]), "char")
1147 
1148 %!assert (class ([int32(1), int64(1)]), "int32")
1149 %!assert (class ([int32(1), int32(1)]), "int32")
1150 %!assert (class ([int32(1), int16(1)]), "int32")
1151 %!assert (class ([int32(1), int8(1)]), "int32")
1152 %!assert (class ([int32(1), uint64(1)]), "int32")
1153 %!assert (class ([int32(1), uint32(1)]), "int32")
1154 %!assert (class ([int32(1), uint16(1)]), "int32")
1155 %!assert (class ([int32(1), uint8(1)]), "int32")
1156 %!assert (class ([int32(1), single(1)]), "int32")
1157 %!assert (class ([int32(1), double(1)]), "int32")
1158 %!assert (class ([int32(1), cell(1)]), "cell")
1159 %!assert (class ([int32(1), true]), "int32")
1160 %!assert (class ([int32(1), "a"]), "char")
1161 
1162 %!assert (class ([int16(1), int64(1)]), "int16")
1163 %!assert (class ([int16(1), int32(1)]), "int16")
1164 %!assert (class ([int16(1), int16(1)]), "int16")
1165 %!assert (class ([int16(1), int8(1)]), "int16")
1166 %!assert (class ([int16(1), uint64(1)]), "int16")
1167 %!assert (class ([int16(1), uint32(1)]), "int16")
1168 %!assert (class ([int16(1), uint16(1)]), "int16")
1169 %!assert (class ([int16(1), uint8(1)]), "int16")
1170 %!assert (class ([int16(1), single(1)]), "int16")
1171 %!assert (class ([int16(1), double(1)]), "int16")
1172 %!assert (class ([int16(1), cell(1)]), "cell")
1173 %!assert (class ([int16(1), true]), "int16")
1174 %!assert (class ([int16(1), "a"]), "char")
1175 
1176 %!assert (class ([int8(1), int64(1)]), "int8")
1177 %!assert (class ([int8(1), int32(1)]), "int8")
1178 %!assert (class ([int8(1), int16(1)]), "int8")
1179 %!assert (class ([int8(1), int8(1)]), "int8")
1180 %!assert (class ([int8(1), uint64(1)]), "int8")
1181 %!assert (class ([int8(1), uint32(1)]), "int8")
1182 %!assert (class ([int8(1), uint16(1)]), "int8")
1183 %!assert (class ([int8(1), uint8(1)]), "int8")
1184 %!assert (class ([int8(1), single(1)]), "int8")
1185 %!assert (class ([int8(1), double(1)]), "int8")
1186 %!assert (class ([int8(1), cell(1)]), "cell")
1187 %!assert (class ([int8(1), true]), "int8")
1188 %!assert (class ([int8(1), "a"]), "char")
1189 
1190 %!assert (class ([uint64(1), int64(1)]), "uint64")
1191 %!assert (class ([uint64(1), int32(1)]), "uint64")
1192 %!assert (class ([uint64(1), int16(1)]), "uint64")
1193 %!assert (class ([uint64(1), int8(1)]), "uint64")
1194 %!assert (class ([uint64(1), uint64(1)]), "uint64")
1195 %!assert (class ([uint64(1), uint32(1)]), "uint64")
1196 %!assert (class ([uint64(1), uint16(1)]), "uint64")
1197 %!assert (class ([uint64(1), uint8(1)]), "uint64")
1198 %!assert (class ([uint64(1), single(1)]), "uint64")
1199 %!assert (class ([uint64(1), double(1)]), "uint64")
1200 %!assert (class ([uint64(1), cell(1)]), "cell")
1201 %!assert (class ([uint64(1), true]), "uint64")
1202 %!assert (class ([uint64(1), "a"]), "char")
1203 
1204 %!assert (class ([uint32(1), int64(1)]), "uint32")
1205 %!assert (class ([uint32(1), int32(1)]), "uint32")
1206 %!assert (class ([uint32(1), int16(1)]), "uint32")
1207 %!assert (class ([uint32(1), int8(1)]), "uint32")
1208 %!assert (class ([uint32(1), uint64(1)]), "uint32")
1209 %!assert (class ([uint32(1), uint32(1)]), "uint32")
1210 %!assert (class ([uint32(1), uint16(1)]), "uint32")
1211 %!assert (class ([uint32(1), uint8(1)]), "uint32")
1212 %!assert (class ([uint32(1), single(1)]), "uint32")
1213 %!assert (class ([uint32(1), double(1)]), "uint32")
1214 %!assert (class ([uint32(1), cell(1)]), "cell")
1215 %!assert (class ([uint32(1), true]), "uint32")
1216 %!assert (class ([uint32(1), "a"]), "char")
1217 
1218 %!assert (class ([uint16(1), int64(1)]), "uint16")
1219 %!assert (class ([uint16(1), int32(1)]), "uint16")
1220 %!assert (class ([uint16(1), int16(1)]), "uint16")
1221 %!assert (class ([uint16(1), int8(1)]), "uint16")
1222 %!assert (class ([uint16(1), uint64(1)]), "uint16")
1223 %!assert (class ([uint16(1), uint32(1)]), "uint16")
1224 %!assert (class ([uint16(1), uint16(1)]), "uint16")
1225 %!assert (class ([uint16(1), uint8(1)]), "uint16")
1226 %!assert (class ([uint16(1), single(1)]), "uint16")
1227 %!assert (class ([uint16(1), double(1)]), "uint16")
1228 %!assert (class ([uint16(1), cell(1)]), "cell")
1229 %!assert (class ([uint16(1), true]), "uint16")
1230 %!assert (class ([uint16(1), "a"]), "char")
1231 
1232 %!assert (class ([uint8(1), int64(1)]), "uint8")
1233 %!assert (class ([uint8(1), int32(1)]), "uint8")
1234 %!assert (class ([uint8(1), int16(1)]), "uint8")
1235 %!assert (class ([uint8(1), int8(1)]), "uint8")
1236 %!assert (class ([uint8(1), uint64(1)]), "uint8")
1237 %!assert (class ([uint8(1), uint32(1)]), "uint8")
1238 %!assert (class ([uint8(1), uint16(1)]), "uint8")
1239 %!assert (class ([uint8(1), uint8(1)]), "uint8")
1240 %!assert (class ([uint8(1), single(1)]), "uint8")
1241 %!assert (class ([uint8(1), double(1)]), "uint8")
1242 %!assert (class ([uint8(1), cell(1)]), "cell")
1243 %!assert (class ([uint8(1), true]), "uint8")
1244 %!assert (class ([uint8(1), "a"]), "char")
1245 
1246 %!assert (class ([single(1), int64(1)]), "int64")
1247 %!assert (class ([single(1), int32(1)]), "int32")
1248 %!assert (class ([single(1), int16(1)]), "int16")
1249 %!assert (class ([single(1), int8(1)]), "int8")
1250 %!assert (class ([single(1), uint64(1)]), "uint64")
1251 %!assert (class ([single(1), uint32(1)]), "uint32")
1252 %!assert (class ([single(1), uint16(1)]), "uint16")
1253 %!assert (class ([single(1), uint8(1)]), "uint8")
1254 %!assert (class ([single(1), single(1)]), "single")
1255 %!assert (class ([single(1), double(1)]), "single")
1256 %!assert (class ([single(1), cell(1)]), "cell")
1257 %!assert (class ([single(1), true]), "single")
1258 %!assert (class ([single(1), "a"]), "char")
1259 
1260 %!assert (class ([double(1), int64(1)]), "int64")
1261 %!assert (class ([double(1), int32(1)]), "int32")
1262 %!assert (class ([double(1), int16(1)]), "int16")
1263 %!assert (class ([double(1), int8(1)]), "int8")
1264 %!assert (class ([double(1), uint64(1)]), "uint64")
1265 %!assert (class ([double(1), uint32(1)]), "uint32")
1266 %!assert (class ([double(1), uint16(1)]), "uint16")
1267 %!assert (class ([double(1), uint8(1)]), "uint8")
1268 %!assert (class ([double(1), single(1)]), "single")
1269 %!assert (class ([double(1), double(1)]), "double")
1270 %!assert (class ([double(1), cell(1)]), "cell")
1271 %!assert (class ([double(1), true]), "double")
1272 %!assert (class ([double(1), "a"]), "char")
1273 
1274 %!assert (class ([cell(1), int64(1)]), "cell")
1275 %!assert (class ([cell(1), int32(1)]), "cell")
1276 %!assert (class ([cell(1), int16(1)]), "cell")
1277 %!assert (class ([cell(1), int8(1)]), "cell")
1278 %!assert (class ([cell(1), uint64(1)]), "cell")
1279 %!assert (class ([cell(1), uint32(1)]), "cell")
1280 %!assert (class ([cell(1), uint16(1)]), "cell")
1281 %!assert (class ([cell(1), uint8(1)]), "cell")
1282 %!assert (class ([cell(1), single(1)]), "cell")
1283 %!assert (class ([cell(1), double(1)]), "cell")
1284 %!assert (class ([cell(1), cell(1)]), "cell")
1285 %!assert (class ([cell(1), true]), "cell")
1286 %!assert (class ([cell(1), "a"]), "cell")
1287 
1288 %!assert (class ([true, int64(1)]), "int64")
1289 %!assert (class ([true, int32(1)]), "int32")
1290 %!assert (class ([true, int16(1)]), "int16")
1291 %!assert (class ([true, int8(1)]), "int8")
1292 %!assert (class ([true, uint64(1)]), "uint64")
1293 %!assert (class ([true, uint32(1)]), "uint32")
1294 %!assert (class ([true, uint16(1)]), "uint16")
1295 %!assert (class ([true, uint8(1)]), "uint8")
1296 %!assert (class ([true, single(1)]), "single")
1297 %!assert (class ([true, double(1)]), "double")
1298 %!assert (class ([true, cell(1)]), "cell")
1299 %!assert (class ([true, true]), "logical")
1300 %!assert (class ([true, "a"]), "char")
1301 
1302 %!assert (class (["a", int64(1)]), "char")
1303 %!assert (class (["a", int32(1)]), "char")
1304 %!assert (class (["a", int16(1)]), "char")
1305 %!assert (class (["a", int8(1)]), "char")
1306 %!assert (class (["a", int64(1)]), "char")
1307 %!assert (class (["a", int32(1)]), "char")
1308 %!assert (class (["a", int16(1)]), "char")
1309 %!assert (class (["a", int8(1)]), "char")
1310 %!assert (class (["a", single(1)]), "char")
1311 %!assert (class (["a", double(1)]), "char")
1312 %!assert (class (["a", cell(1)]), "cell")
1313 %!assert (class (["a", true]), "char")
1314 %!assert (class (["a", "a"]), "char")
1315 
1316 %!assert (class ([cell(1), struct("foo", "bar")]), "cell")
1317 %!error [struct("foo", "bar"), cell(1)]
1318 
1319 %!assert ([,1], 1)
1320 %!assert ([1,], 1)
1321 %!assert ([,1,], 1)
1322 %!assert ([,1,;;], 1)
1323 %!assert ([,1,;,;], 1)
1324 
1325 %!assert ([1,1], ones (1, 2))
1326 %!assert ([,1,1], ones (1, 2))
1327 %!assert ([1,1,], ones (1, 2))
1328 %!assert ([,1,1,], ones (1, 2))
1329 %!assert ([,1,1,;;], ones (1, 2))
1330 %!assert ([,1,1,;,;], ones (1, 2))
1331 %!assert ([,;,1,1], ones (1, 2))
1332 
1333 %!assert ([1;1], ones (2, 1))
1334 %!assert ([1,;1], ones (2, 1))
1335 %!assert ([1,;,;1], ones (2, 1))
1336 
1337 %!error eval ("[,,]")
1338 %!error eval ("[,,;,]")
1339 %!error eval ("[,;,,;,]")
1340 
1341 %!assert (isnull ([,]))
1342 %!assert (isnull ([;]))
1343 %!assert (isnull ([;;]))
1344 %!assert (isnull ([;,;]))
1345 %!assert (isnull ([,;,;,]))
1346 */
1347 
1348 DEFUN (string_fill_char, args, nargout,
1349  doc: /* -*- texinfo -*-
1350 @deftypefn {} {@var{val} =} string_fill_char ()
1351 @deftypefnx {} {@var{old_val} =} string_fill_char (@var{new_val})
1352 @deftypefnx {} {} string_fill_char (@var{new_val}, "local")
1353 Query or set the internal variable used to pad all rows of a character
1354 matrix to the same length.
1355 
1356 The value must be a single character and the default is @qcode{" "} (a
1357 single space). For example:
1358 
1359 @example
1360 @group
1361 string_fill_char ("X");
1362 [ "these"; "are"; "strings" ]
1363  @result{} "theseXX"
1364  "areXXXX"
1365  "strings"
1366 @end group
1367 @end example
1368 
1369 When called from inside a function with the @qcode{"local"} option, the
1370 variable is changed locally for the function and any subroutines it calls.
1371 The original variable value is restored when exiting the function.
1372 @end deftypefn */)
1373 {
1374  return SET_INTERNAL_VARIABLE (string_fill_char);
1375 }
1376 
1377 /*
1378 ## string_fill_char() function call must be outside of %!test block
1379 ## due to the way a %!test block is wrapped inside a function
1380 %!shared orig_val, old_val
1381 %! orig_val = string_fill_char ();
1382 %! old_val = string_fill_char ("X");
1383 %!test
1384 %! assert (orig_val, old_val);
1385 %! assert (string_fill_char (), "X");
1386 %! assert (["these"; "are"; "strings"], ["theseXX"; "areXXXX"; "strings"]);
1387 %! string_fill_char (orig_val);
1388 %! assert (string_fill_char (), orig_val);
1389 
1390 %!assert ( [ [], {1} ], {1} )
1391 
1392 %!error (string_fill_char (1, 2))
1393 */
char Vstring_fill_char
Definition: pt-mat.cc:53
tm_row_const & operator=(const tm_row_const &x)
Definition: pt-mat.cc:143
bool any_class_p(void) const
Definition: pt-mat.cc:492
bool some_strings_p(void) const
Definition: pt-mat.cc:177
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:803
bool is_object(void) const
Definition: ov.h:593
octave::base_list< tree_argument_list * >::const_iterator const_iterator
Definition: pt-array-list.h:42
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
Definition: Cell.h:37
static octave_map cat(int dim, octave_idx_type n, const octave_scalar_map *map_list)
Definition: oct-map.cc:661
std::string str(char sep= 'x') const
Definition: dim-vector.cc:73
bool is_real_type(void) const
Definition: ov.h:667
int ndims(void) const
Definition: ov.h:495
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value do_cat_op(const octave_value &v1, const octave_value &v2, const Array< octave_idx_type > &ra_idx)
Definition: ov.cc:2456
std::string get_concat_class(const std::string &c1, const std::string &c2)
Definition: pt-mat.cc:205
dim_vector dims(void)
Definition: pt-mat.cc:172
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
bool all_real_p(void) const
Definition: pt-mat.cc:487
std::string class_name(void) const
Definition: pt-mat.cc:495
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
octave_idx_type length(void) const
Definition: ovl.h:96
iterator begin(void)
Definition: pt-mat.cc:193
static octave_value do_single_type_concat(const dim_vector &dv, tm_const &tmp)
Definition: pt-mat.cc:841
bool any_class
Definition: pt-mat.cc:512
bool all_dq_strings_p(void) const
Definition: pt-mat.cc:485
bool all_str
Definition: pt-mat.cc:503
bool all_complex_p(void) const
Definition: pt-mat.cc:179
bool empty(void) const
Definition: base-list.h:47
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
~tm_const(void)
Definition: pt-mat.cc:476
bool any_cell_p(void) const
Definition: pt-mat.cc:490
bool all_empty_p(void) const
Definition: pt-mat.cc:489
void error(const char *fmt,...)
Definition: error.cc:570
tree_expression * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-mat.cc:1109
tm_row_const_rep * rep
Definition: pt-mat.cc:201
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:126
tm_const(const tree_matrix &tm)
Definition: pt-mat.cc:469
octave_idx_type & elem(int i)
Definition: dim-vector.h:215
bool all_strings_p(void) const
Definition: pt-mat.cc:174
static Sparse< T > cat(int dim, octave_idx_type n, const Sparse< T > *sparse_list)
Definition: Sparse.cc:2577
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov.h:524
std::list< octave_value >::iterator iterator
Definition: base-list.h:40
bool is_cell(void) const
Definition: ov.h:545
const_iterator end(void) const
Definition: pt-mat.cc:197
static std::string static_class_name(void)
Definition: ov-base.h:857
bool any_cell
Definition: pt-mat.cc:510
Array< T > & insert(const Array< T > &a, const Array< octave_idx_type > &idx)
Insert an array into another at a specified position.
Definition: Array.cc:1601
tm_row_const_rep::iterator iterator
Definition: pt-mat.cc:127
bool any_sparse_p(void) const
Definition: pt-mat.cc:182
JNIEnv void * args
Definition: ov-java.cc:67
bool all_mt
Definition: pt-mat.cc:509
octave_idx_type columns(void) const
Definition: ov.h:491
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:1688
bool all_dq_str
Definition: pt-mat.cc:505
bool all_1x1
Definition: pt-mat.cc:513
iterator end(void)
Definition: base-list.h:86
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
tm_row_const_rep::const_iterator const_iterator
Definition: pt-mat.cc:128
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
Definition: ov.h:1202
bool is_sparse_type(void) const
Definition: ov.h:682
octave_idx_type numel(const octave_value_list &idx)
Definition: ov.h:411
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
size_t length(void) const
Definition: pt-mat.cc:170
octave_value do_single_type_concat< octave_map >(const dim_vector &dv, tm_const &tmp)
Definition: pt-mat.cc:853
static Array< T > cat(int dim, octave_idx_type n, const Array< T > *array_list)
Concatenation along a specified (0-based) dimension, equivalent to cat().
Definition: Array.cc:2630
bool is_string(void) const
Definition: ov.h:578
bool all_sq_strings_p(void) const
Definition: pt-mat.cc:484
bool all_sq_str
Definition: pt-mat.cc:504
void accept(tree_walker &tw)
Definition: pt-mat.cc:1120
bool is_complex_type(void) const
Definition: ov.h:670
static OCTAVE_NORETURN void eval_error(const char *msg, const dim_vector &x, const dim_vector &y)
Definition: pt-mat.cc:279
octave_refcount< int > count
Definition: pt-mat.cc:90
double tmp
Definition: data.cc:6300
bool all_strings_p(void) const
Definition: pt-mat.cc:483
is false
Definition: cellfun.cc:398
tm_row_const(void)
Definition: pt-mat.cc:130
octave_value retval
Definition: data.cc:6294
bool append
Definition: load-save.cc:1582
bool some_strings_p(void) const
Definition: pt-mat.cc:486
static octave_value do_class_concat(tm_const &tmc)
Definition: pt-mat.cc:867
tm_row_const_rep(const tree_argument_list &row)
Definition: pt-mat.cc:80
bool all_1x1_p(void) const
Definition: pt-mat.cc:184
bool empty(void) const
Definition: pt-mat.cc:168
bool all_dq_strings_p(void) const
Definition: pt-mat.cc:176
bool all_zero_dims(void) const
Definition: ov.h:497
bool some_str
Definition: pt-mat.cc:506
idx type
Definition: ov.cc:3129
Definition: dMatrix.h:37
bool any_sparse
Definition: pt-mat.cc:511
bool any_zero(void) const
Definition: dim-vector.h:359
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
bool all_real
Definition: pt-mat.cc:507
void copy_base(const tree_array_list &array_list)
std::string class_name(void) const
Definition: pt-mat.cc:187
dim_vector dims(void) const
Definition: ov.h:486
octave_value rvalue1(int nargout=1)
Definition: pt-mat.cc:903
With real return the complex result
Definition: data.cc:3375
bool all_complex_p(void) const
Definition: pt-mat.cc:488
bool any_class_p(void) const
Definition: pt-mat.cc:183
bool is_map(void) const
Definition: ov.h:590
octave_value resize(const dim_vector &dv, bool=false) const
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:126
virtual octave_value rvalue1(int nargout=1)
Definition: pt-exp.cc:54
octave_idx_type cols(void) const
Definition: pt-mat.cc:479
void clear(void)
Definition: Array.cc:95
bool is_empty(void) const
Definition: ov.h:542
std::list< octave_value >::const_iterator const_iterator
Definition: base-list.h:41
octave_idx_type rows(void)
Definition: pt-mat.cc:165
bool is_sq_string(void) const
Definition: ov.h:581
void init(const tree_argument_list &)
Definition: pt-mat.cc:342
bool all_sq_strings_p(void) const
Definition: pt-mat.cc:175
dim_vector dims(void) const
Definition: pt-mat.cc:481
const_iterator begin(void) const
Definition: pt-mat.cc:194
bool is_dq_string(void) const
Definition: ov.h:584
void do_init_element(const octave_value &, bool &)
Definition: pt-mat.cc:285
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
bool zero_by_zero(void) const
Definition: dim-vector.h:354
p
Definition: lu.cc:138
bool is_cs_list(void) const
Definition: ov.h:602
bool any_sparse_p(void) const
Definition: pt-mat.cc:491
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:332
size_t length(void) const
Definition: base-list.h:50
tm_row_const(const tree_argument_list &row)
Definition: pt-mat.cc:133
bool all_real_p(void) const
Definition: pt-mat.cc:178
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:301
bool any_cell_p(void) const
Definition: pt-mat.cc:181
octave_idx_type rows(void) const
Definition: pt-mat.cc:478
elt_type & front(void)
Definition: base-list.h:97
std::string class_name(void) const
Definition: ov.h:1234
the element is set to zero In other the statement xample y
Definition: data.cc:5342
octave_idx_type cols(void)
Definition: pt-mat.cc:166
bool hvcat(const dim_vector &dvb, int dim)
This corresponds to [,] (horzcat, dim = 0) and [;] (vertcat, dim = 1).
Definition: dim-vector.cc:250
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
bool all_1x1_p(void) const
Definition: pt-mat.cc:493
bool is_undefined(void) const
Definition: ov.h:539
bool ok
Definition: pt-mat.cc:517
iterator end(void)
Definition: pt-mat.cc:196
tm_row_const(const tm_row_const &x)
Definition: pt-mat.cc:136
octave_value_list list_value(void) const
Definition: ov.cc:1741
void init(const tree_matrix &tm)
Definition: pt-mat.cc:529
bool all_empty_p(void) const
Definition: pt-mat.cc:180
bool first_elem_struct_p(void) const
Definition: pt-mat.cc:185
std::string class_nm
Definition: pt-mat.cc:515
octave_value_list rvalue(int nargout)
Definition: pt-mat.cc:655
void append(const octave_value &s)
Definition: base-list.h:110
void cellify(void)
Definition: pt-mat.cc:189
static void single_type_concat(Array< T > &result, tm_const &tmp)
Definition: pt-mat.cc:673
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
virtual void visit_matrix(tree_matrix &)=0
dim_vector dv
Definition: pt-mat.cc:501
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:854
dim_vector dv
Definition: sub2ind.cc:263
~tm_row_const(void)
Definition: pt-mat.cc:159
bool all_cmplx
Definition: pt-mat.cc:508
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
Definition: str2double.cc:342
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
iterator begin(void)
Definition: base-list.h:83
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
void maybe_warn_string_concat(bool all_dq_strings_p, bool all_sq_strings_p)
Definition: pt-mat.cc:664