GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-base.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_ov_base_h)
27 #define octave_ov_base_h 1
28 
29 #include "octave-config.h"
30 
31 #include <cstdlib>
32 
33 #include <iosfwd>
34 #include <list>
35 #include <string>
36 
37 #include "Range.h"
38 #include "data-conv.h"
39 #include "mx-base.h"
40 #include "str-vec.h"
41 
42 #include "oct-hdf5-types.h"
43 #include "oct-stream.h"
44 
45 namespace octave
46 {
47  class type_info;
48 
49  // FIXME: This is not ideal, but it avoids including
50  // interpreter-private.h here and bringing in a lot of unnecessary
51  // symbols that require even more header files.
52 
53  extern type_info& __get_type_info__ (const std::string&);
54 }
55 
56 class Cell;
58 class mxArray;
59 class octave_map;
60 class octave_scalar_map;
61 class octave_value;
62 class octave_value_list;
63 class octave_classdef;
64 class octave_function;
66 class octave_user_script;
67 class octave_user_code;
68 class octave_fcn_handle;
69 class octave_value_list;
70 
72 {
92 };
93 
94 extern OCTINTERP_API std::string
96 
97 inline bool btyp_isnumeric (builtin_type_t btyp)
98 { return btyp <= btyp_uint64; }
99 
100 inline bool btyp_isinteger (builtin_type_t btyp)
101 { return btyp >= btyp_int8 && btyp <= btyp_uint64; }
102 
103 inline bool btyp_isfloat (builtin_type_t btyp)
104 { return btyp <= btyp_float_complex; }
105 
106 inline bool btyp_isarray (builtin_type_t btyp)
107 { return btyp <= btyp_char; }
108 
109 //! Determine the resulting type for a possible mixed-type operation.
110 //!
111 //! Rules for the resulting type:
112 //! - bool -> double
113 //! - single + double -> single
114 //! - real + complex -> complex
115 //! - integer + real -> integer
116 //! - uint + uint -> uint (the bigger one)
117 //! - sint + sint -> sint (the bigger one)
118 //!
119 //! @return The resulting type or "unknown type", if the resulting type cannot
120 //! be determined.
121 
122 extern OCTINTERP_API
124 
125 template <typename T>
127 {
129 };
130 
131 #define DEF_CLASS_TO_BTYP(CLASS,BTYP) \
132  template <> \
133  struct class_to_btyp<CLASS> \
134  { \
135  static const builtin_type_t btyp = BTYP; \
136  }
137 
152 
153 // T_ID is the type id of struct objects, set by register_type().
154 // T_NAME is the type name of struct objects.
155 
156 #define OCTAVE_EMPTY_CPP_ARG /* empty */
157 
158 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA \
159  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2 (OCTAVE_EMPTY_CPP_ARG)
160 
161 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA \
162  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual)
163 
164 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(VIRTUAL) \
165  public: \
166  VIRTUAL int type_id (void) const { return t_id; } \
167  VIRTUAL std::string type_name (void) const { return t_name; } \
168  VIRTUAL std::string class_name (void) const { return c_name; } \
169  static int static_type_id (void) { return t_id; } \
170  static std::string static_type_name (void) { return t_name; } \
171  static std::string static_class_name (void) { return c_name; } \
172  static void register_type (void); \
173  static void register_type (octave::type_info&); \
174  \
175  private: \
176  static int t_id; \
177  static const std::string t_name; \
178  static const std::string c_name;
179 
180 #define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c) \
181  int t::t_id (-1); \
182  const std::string t::t_name (n); \
183  const std::string t::c_name (c); \
184  void t::register_type (void) \
185  { \
186  octave::type_info& type_info \
187  = octave::__get_type_info__ (#t "::register_type"); \
188  \
189  register_type (type_info); \
190  } \
191  void t::register_type (octave::type_info& ti) \
192  { \
193  octave_value v (new t ()); \
194  t_id = ti.register_type (t::t_name, t::c_name, v); \
195  }
196 
197 // A base value type, so that derived types only have to redefine what
198 // they need (if they are derived from octave_base_value instead of
199 // octave_value).
200 
201 class
202 OCTINTERP_API
204 {
205 public:
206 
207  typedef octave_base_value * (*type_conv_fcn) (const octave_base_value&);
208 
209  // type conversion, including result type information
211  {
212  public:
213  type_conv_info (type_conv_fcn f = nullptr, int t = -1)
214  : _fcn (f), _type_id (t) { }
215 
216  operator type_conv_fcn (void) const { return _fcn; }
217 
218  octave_base_value * operator () (const octave_base_value& v) const
219  { return (*_fcn) (v); }
220 
221  int type_id (void) const { return _type_id; }
222 
223  private:
224  type_conv_fcn _fcn;
225  int _type_id;
226  };
227 
228  friend class octave_value;
229 
230  octave_base_value (void) : count (1) { }
231 
232  octave_base_value (const octave_base_value&) : count (1) { }
233 
234  virtual ~octave_base_value (void) = default;
235 
236  // Unconditional clone. Always clones.
237  virtual octave_base_value *
238  clone (void) const { return new octave_base_value (*this); }
239 
240  // Empty clone.
241  virtual octave_base_value *
242  empty_clone (void) const;
243 
244  // Unique clone. Usually clones, but may be overridden to fake the
245  // cloning when sharing copies is to be controlled from within an
246  // instance (see octave_class).
247  virtual octave_base_value *
248  unique_clone (void) { return clone (); }
249 
250  virtual type_conv_info
252  { return type_conv_info (); }
253 
254  virtual type_conv_info
256  { return type_conv_info (); }
257 
258  virtual octave_value squeeze (void) const;
259 
260  virtual octave_value full_value (void) const;
261 
262  virtual octave_value as_double (void) const;
263  virtual octave_value as_single (void) const;
264 
265  virtual octave_value as_int8 (void) const;
266  virtual octave_value as_int16 (void) const;
267  virtual octave_value as_int32 (void) const;
268  virtual octave_value as_int64 (void) const;
269 
270  virtual octave_value as_uint8 (void) const;
271  virtual octave_value as_uint16 (void) const;
272  virtual octave_value as_uint32 (void) const;
273  virtual octave_value as_uint64 (void) const;
274 
275  virtual octave_base_value * try_narrowing_conversion (void) { return nullptr; }
276 
277  virtual void maybe_economize (void) { }
278 
279  virtual Matrix size (void);
280 
281  virtual octave_idx_type xnumel (const octave_value_list&);
282 
283  // FIXME: Do we really need all three of these versions of subsref?
284 
285  virtual octave_value
286  subsref (const std::string& type,
287  const std::list<octave_value_list>& idx);
288 
289  virtual octave_value_list
290  subsref (const std::string& type,
291  const std::list<octave_value_list>& idx,
292  int nargout);
293 
294  virtual octave_value
295  subsref (const std::string& type,
296  const std::list<octave_value_list>& idx,
297  bool auto_add);
298 
299  virtual octave_value
300  do_index_op (const octave_value_list& idx, bool resize_ok = false);
301 
302  virtual void assign (const std::string&, const octave_value&) { }
303 
304  virtual octave_value
305  subsasgn (const std::string& type,
306  const std::list<octave_value_list>& idx,
307  const octave_value& rhs);
308 
309  virtual octave_value
310  undef_subsasgn (const std::string& type,
311  const std::list<octave_value_list>& idx,
312  const octave_value& rhs);
313 
314  virtual idx_vector index_vector (bool require_integers = false) const;
315 
316  virtual dim_vector dims (void) const { return dim_vector (); }
317 
318  octave_idx_type rows (void) const
319  {
320  const dim_vector dv = dims ();
321 
322  return dv(0);
323  }
324 
326  {
327  const dim_vector dv = dims ();
328 
329  return dv(1);
330  }
331 
332  virtual int ndims (void) const
333  { return dims ().ndims (); }
334 
335  virtual octave_idx_type numel (void) const { return dims ().numel (); }
336 
337  virtual size_t byte_size (void) const { return 0; }
338 
339  virtual octave_idx_type nnz (void) const;
340 
341  virtual octave_idx_type nzmax (void) const;
342 
343  virtual octave_idx_type nfields (void) const;
344 
345  virtual octave_value reshape (const dim_vector&) const;
346 
347  virtual octave_value permute (const Array<int>& vec, bool = false) const;
348 
349  virtual octave_value resize (const dim_vector&, bool fill = false) const;
350 
351  virtual MatrixType matrix_type (void) const;
352 
353  virtual MatrixType matrix_type (const MatrixType& typ) const;
354 
355  virtual bool is_defined (void) const { return false; }
356 
357  bool isempty (void) const { return (dims ().any_zero ()); }
358 
359  bool is_zero_by_zero (void) const { return dims().zero_by_zero (); }
360 
361  virtual bool iscell (void) const { return false; }
362 
363  virtual bool iscellstr (void) const { return false; }
364 
365  virtual bool is_real_scalar (void) const { return false; }
366 
367  virtual bool is_real_matrix (void) const { return false; }
368 
369  virtual bool is_complex_scalar (void) const { return false; }
370 
371  virtual bool is_complex_matrix (void) const { return false; }
372 
373  virtual bool is_bool_scalar (void) const { return false; }
374 
375  virtual bool is_bool_matrix (void) const { return false; }
376 
377  virtual bool is_char_matrix (void) const { return false; }
378 
379  virtual bool is_diag_matrix (void) const { return false; }
380 
381  virtual bool is_perm_matrix (void) const { return false; }
382 
383  virtual bool is_string (void) const { return false; }
384 
385  virtual bool is_sq_string (void) const { return false; }
386 
387  virtual bool is_range (void) const { return false; }
388 
389  virtual bool isstruct (void) const { return false; }
390 
391  virtual bool isobject (void) const { return false; }
392 
393  virtual bool is_classdef_meta (void) const { return false; }
394 
395  virtual bool is_classdef_superclass_ref (void) const { return false; }
396 
397  virtual bool is_classdef_object (void) const { return false; }
398 
399  virtual bool is_package (void) const { return false; }
400 
401  virtual bool isjava (void) const { return false; }
402 
403  virtual bool is_cs_list (void) const { return false; }
404 
405  virtual bool is_magic_colon (void) const { return false; }
406 
407  virtual bool is_all_va_args (void) const { return false; }
408 
409  virtual octave_value all (int = 0) const;
410 
411  virtual octave_value any (int = 0) const;
412 
413  virtual builtin_type_t builtin_type (void) const { return btyp_unknown; }
414 
415  virtual bool is_double_type (void) const { return false; }
416 
417  virtual bool is_single_type (void) const { return false; }
418 
419  virtual bool isfloat (void) const { return false; }
420 
421  virtual bool is_int8_type (void) const { return false; }
422 
423  virtual bool is_int16_type (void) const { return false; }
424 
425  virtual bool is_int32_type (void) const { return false; }
426 
427  virtual bool is_int64_type (void) const { return false; }
428 
429  virtual bool is_uint8_type (void) const { return false; }
430 
431  virtual bool is_uint16_type (void) const { return false; }
432 
433  virtual bool is_uint32_type (void) const { return false; }
434 
435  virtual bool is_uint64_type (void) const { return false; }
436 
437  virtual bool islogical (void) const { return false; }
438 
439  virtual bool isinteger (void) const { return false; }
440 
441  virtual bool isreal (void) const { return false; }
442 
443  virtual bool iscomplex (void) const { return false; }
444 
445  // Would be nice to get rid of the next four functions:
446 
447  virtual bool is_scalar_type (void) const { return false; }
448 
449  virtual bool is_matrix_type (void) const { return false; }
450 
451  virtual bool isnumeric (void) const { return false; }
452 
453  virtual bool issparse (void) const { return false; }
454 
455  virtual bool is_true (void) const { return false; }
456 
457  virtual bool isnull (void) const { return false; }
458 
459  virtual bool is_constant (void) const { return false; }
460 
461  virtual bool is_function_handle (void) const { return false; }
462 
463  virtual bool is_anonymous_function (void) const { return false; }
464 
465  virtual bool is_inline_function (void) const { return false; }
466 
467  virtual bool is_function (void) const { return false; }
468 
469  virtual bool is_user_script (void) const { return false; }
470 
471  virtual bool is_user_function (void) const { return false; }
472 
473  virtual bool is_user_code (void) const { return false; }
474 
475  virtual bool is_builtin_function (void) const { return false; }
476 
477  virtual bool is_dld_function (void) const { return false; }
478 
479  virtual bool is_mex_function (void) const { return false; }
480 
481  virtual void erase_subfunctions (void) { }
482 
483  virtual short int short_value (bool = false, bool = false) const;
484 
485  virtual unsigned short int ushort_value (bool = false, bool = false) const;
486 
487  virtual int int_value (bool = false, bool = false) const;
488 
489  virtual unsigned int uint_value (bool = false, bool = false) const;
490 
491  virtual int nint_value (bool = false) const;
492 
493  virtual long int long_value (bool = false, bool = false) const;
494 
495  virtual unsigned long int ulong_value (bool = false, bool = false) const;
496 
497  virtual int64_t int64_value (bool = false, bool = false) const;
498 
499  virtual uint64_t uint64_value (bool = false, bool = false) const;
500 
501  virtual double double_value (bool = false) const;
502 
503  virtual float float_value (bool = false) const;
504 
505  virtual double scalar_value (bool frc_str_conv = false) const
506  { return double_value (frc_str_conv); }
507 
508  virtual float float_scalar_value (bool frc_str_conv = false) const
509  { return float_value (frc_str_conv); }
510 
511  virtual Cell cell_value (void) const;
512 
513  virtual Matrix matrix_value (bool = false) const;
514 
515  virtual FloatMatrix float_matrix_value (bool = false) const;
516 
517  virtual NDArray array_value (bool = false) const;
518 
519  virtual FloatNDArray float_array_value (bool = false) const;
520 
521  virtual Complex complex_value (bool = false) const;
522 
523  virtual FloatComplex float_complex_value (bool = false) const;
524 
525  virtual ComplexMatrix complex_matrix_value (bool = false) const;
526 
527  virtual FloatComplexMatrix float_complex_matrix_value (bool = false) const;
528 
529  virtual ComplexNDArray complex_array_value (bool = false) const;
530 
531  virtual FloatComplexNDArray float_complex_array_value (bool = false) const;
532 
533  virtual bool bool_value (bool = false) const;
534 
535  virtual boolMatrix bool_matrix_value (bool = false) const;
536 
537  virtual boolNDArray bool_array_value (bool = false) const;
538 
539  virtual charMatrix char_matrix_value (bool force = false) const;
540 
541  virtual charNDArray char_array_value (bool = false) const;
542 
543  virtual SparseMatrix sparse_matrix_value (bool = false) const;
544 
545  virtual SparseComplexMatrix sparse_complex_matrix_value (bool = false) const;
546 
547  virtual SparseBoolMatrix sparse_bool_matrix_value (bool = false) const;
548 
549  virtual DiagMatrix diag_matrix_value (bool = false) const;
550 
551  virtual FloatDiagMatrix float_diag_matrix_value (bool = false) const;
552 
553  virtual ComplexDiagMatrix complex_diag_matrix_value (bool = false) const;
554 
555  virtual FloatComplexDiagMatrix
556  float_complex_diag_matrix_value (bool = false) const;
557 
558  virtual PermMatrix perm_matrix_value (void) const;
559 
560  virtual octave_int8 int8_scalar_value (void) const;
561 
562  virtual octave_int16 int16_scalar_value (void) const;
563 
564  virtual octave_int32 int32_scalar_value (void) const;
565 
566  virtual octave_int64 int64_scalar_value (void) const;
567 
568  virtual octave_uint8 uint8_scalar_value (void) const;
569 
570  virtual octave_uint16 uint16_scalar_value (void) const;
571 
572  virtual octave_uint32 uint32_scalar_value (void) const;
573 
574  virtual octave_uint64 uint64_scalar_value (void) const;
575 
576  virtual int8NDArray int8_array_value (void) const;
577 
578  virtual int16NDArray int16_array_value (void) const;
579 
580  virtual int32NDArray int32_array_value (void) const;
581 
582  virtual int64NDArray int64_array_value (void) const;
583 
584  virtual uint8NDArray uint8_array_value (void) const;
585 
586  virtual uint16NDArray uint16_array_value (void) const;
587 
588  virtual uint32NDArray uint32_array_value (void) const;
589 
590  virtual uint64NDArray uint64_array_value (void) const;
591 
592  virtual string_vector string_vector_value (bool pad = false) const;
593 
594  virtual std::string string_value (bool force = false) const;
595 
596  virtual Array<std::string> cellstr_value (void) const;
597 
598  virtual Range range_value (void) const;
599 
600  virtual octave_map map_value (void) const;
601 
602  virtual octave_scalar_map scalar_map_value (void) const;
603 
604  virtual string_vector map_keys (void) const;
605 
606  virtual size_t nparents (void) const;
607 
608  virtual std::list<std::string> parent_class_name_list (void) const;
609 
610  virtual string_vector parent_class_names (void) const;
611 
612  virtual octave_base_value * find_parent_class (const std::string&)
613  { return nullptr; }
614 
615  virtual octave_base_value * unique_parent_class (const std::string&)
616  { return nullptr; }
617 
618  virtual bool is_instance_of (const std::string&) const
619  { return false; }
620 
621  virtual octave_classdef * classdef_object_value (bool silent = false);
622 
623  virtual octave_function * function_value (bool silent = false);
624 
625  virtual octave_user_function * user_function_value (bool silent = false);
626 
627  virtual octave_user_script * user_script_value (bool silent = false);
628 
629  virtual octave_user_code * user_code_value (bool silent = false);
630 
631  virtual octave_fcn_handle * fcn_handle_value (bool silent = false);
632 
633  virtual octave_value_list list_value (void) const;
634 
635  virtual octave_value convert_to_str (bool pad = false, bool force = false,
636  char type = '\'') const;
637  virtual octave_value
638  convert_to_str_internal (bool pad, bool force, char type) const;
639 
640  virtual void convert_to_row_or_column_vector (void);
641 
642  // The following extractor functions don't perform any implicit type
643  // conversions.
644 
645  virtual std::string xstring_value () const;
646 
647  virtual bool print_as_scalar (void) const { return false; }
648 
649  virtual void print (std::ostream& os, bool pr_as_read_syntax = false);
650 
651  virtual void
652  print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
653 
654  virtual bool
655  print_name_tag (std::ostream& os, const std::string& name) const;
656 
657  virtual void
658  print_with_name (std::ostream& output_buf, const std::string& name,
659  bool print_padding = true);
660 
661  virtual void short_disp (std::ostream& os) const { os << "..."; }
662 
663  virtual float_display_format get_edit_display_format (void) const;
664 
665  virtual std::string edit_display (const float_display_format&,
667  { return "#VAL"; }
668 
669  virtual void print_info (std::ostream& os, const std::string& prefix) const;
670 
671  virtual bool save_ascii (std::ostream& os);
672 
673  virtual bool load_ascii (std::istream& is);
674 
675  virtual bool save_binary (std::ostream& os, bool save_as_floats);
676 
677  virtual bool load_binary (std::istream& is, bool swap,
679 
680  virtual bool
681  save_hdf5 (octave_hdf5_id loc_id, const char *name, bool save_as_floats);
682 
683  virtual bool
684  load_hdf5 (octave_hdf5_id loc_id, const char *name);
685 
686  virtual int
687  write (octave::stream& os, int block_size,
688  oct_data_conv::data_type output_type, int skip,
689  octave::mach_info::float_format flt_fmt) const;
690 
691  virtual void * mex_get_data (void) const { return nullptr; }
692 
693  virtual octave_idx_type * mex_get_ir (void) const { return nullptr; }
694 
695  virtual octave_idx_type * mex_get_jc (void) const { return nullptr; }
696 
697  virtual mxArray * as_mxArray (void) const;
698 
699  virtual octave_value diag (octave_idx_type k = 0) const;
700 
702 
703  virtual octave_value sort (octave_idx_type dim = 0,
704  sortmode mode = ASCENDING) const;
706  octave_idx_type dim = 0,
707  sortmode mode = ASCENDING) const;
708 
709  virtual sortmode issorted (sortmode mode = UNSORTED) const;
710 
711  virtual Array<octave_idx_type>
712  sort_rows_idx (sortmode mode = ASCENDING) const;
713 
714  virtual sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
715 
716  virtual void lock (void);
717 
718  virtual void unlock (void);
719 
720  virtual bool islocked (void) const { return false; }
721 
722  virtual void call_object_destructor (void) { }
723 
724  virtual octave_value dump (void) const;
725 
726  // Standard mappers. Register new ones here.
728  {
790  num_unary_mappers = umap_unknown
791  };
792 
793  virtual octave_value map (unary_mapper_t) const;
794 
795  // These are fast indexing & assignment shortcuts for extracting
796  // or inserting a single scalar from/to an array.
797 
798  // Extract the n-th element, aka val(n). Result is undefined if val is not
799  // an array type or n is out of range. Never error.
800  virtual octave_value
802 
803  // Assign the n-th element, aka val(n) = x. Returns false if val is not an
804  // array type, x is not a matching scalar type, or n is out of range.
805  // Never error.
806  virtual bool
808 
809  // This is a helper for the above, to be overridden in scalar types. The
810  // whole point is to handle the insertion efficiently with just *two* VM
811  // calls, which is basically the theoretical minimum.
812  virtual bool
813  fast_elem_insert_self (void *where, builtin_type_t btyp) const;
814 
815  // Grab the reference count. For use by jit.
816  void
817  grab (void)
818  {
819  ++count;
820  }
821 
822  // Release the reference count. For use by jit.
823  void
824  release (void)
825  {
826  if (--count == 0)
827  delete this;
828  }
829 
830 protected:
831 
832  // This should only be called for derived types.
833 
834  octave_value numeric_assign (const std::string& type,
835  const std::list<octave_value_list>& idx,
836  const octave_value& rhs);
837 
838  void reset_indent_level (void) const
839  { curr_print_indent_level = 0; }
840 
841  void increment_indent_level (void) const
842  { curr_print_indent_level += 2; }
843 
844  void decrement_indent_level (void) const
845  { curr_print_indent_level -= 2; }
846 
847  int current_print_indent_level (void) const
848  { return curr_print_indent_level; }
849 
850  void indent (std::ostream& os) const;
851 
852  void newline (std::ostream& os) const;
853 
854  void reset (void) const;
855 
856  // A reference count.
857  // NOTE: the declaration is octave_idx_type because with 64-bit indexing,
858  // it is well possible to have more than MAX_INT copies of a single value
859  // (think of an empty cell array with >2G elements).
861 
862  static const char * get_umap_name (unary_mapper_t);
863 
864  void warn_load (const char *type) const;
865  void warn_save (const char *type) const;
866 
867 private:
868 
869  void wrong_type_arg_error (void) const;
870 
872  static bool beginning_of_line;
873 
875 };
876 
877 // TRUE means to perform automatic sparse to real mutation if there
878 // is memory to be saved
879 extern OCTINTERP_API bool Vsparse_auto_mutate;
880 
881 // Utility function to convert C++ arguments used in subsref/subsasgn into an
882 // octave_value_list object that can be used to call a function/method in the
883 // interpreter.
884 extern OCTINTERP_API octave_value
885 make_idx_args (const std::string& type,
886  const std::list<octave_value_list>& idx,
887  const std::string& who);
888 
889 // Tells whether some regular octave_value_base methods are being called from
890 // within the "builtin" function.
891 extern OCTINTERP_API bool called_from_builtin (void);
892 
893 #endif
Definition: Cell.h:43
Definition: dMatrix.h:42
Definition: Range.h:40
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:401
bool zero_by_zero(void) const
Definition: dim-vector.h:377
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:334
type_conv_info(type_conv_fcn f=nullptr, int t=-1)
Definition: ov-base.h:213
virtual bool is_mex_function(void) const
Definition: ov-base.h:479
virtual bool isinteger(void) const
Definition: ov-base.h:439
virtual bool is_uint64_type(void) const
Definition: ov-base.h:435
virtual void * mex_get_data(void) const
Definition: ov-base.h:691
virtual ~octave_base_value(void)=default
virtual type_conv_info numeric_conversion_function(void) const
Definition: ov-base.h:251
virtual bool isfloat(void) const
Definition: ov-base.h:419
virtual type_conv_info numeric_demotion_function(void) const
Definition: ov-base.h:255
static bool beginning_of_line
Definition: ov-base.h:872
virtual bool is_real_matrix(void) const
Definition: ov-base.h:367
octave_idx_type columns(void) const
Definition: ov-base.h:325
octave::refcount< octave_idx_type > count
Definition: ov-base.h:860
virtual bool is_classdef_superclass_ref(void) const
Definition: ov-base.h:395
void decrement_indent_level(void) const
Definition: ov-base.h:844
virtual bool is_classdef_object(void) const
Definition: ov-base.h:397
virtual bool is_diag_matrix(void) const
Definition: ov-base.h:379
virtual bool is_function(void) const
Definition: ov-base.h:467
virtual void short_disp(std::ostream &os) const
Definition: ov-base.h:661
virtual bool is_user_code(void) const
Definition: ov-base.h:473
void increment_indent_level(void) const
Definition: ov-base.h:841
virtual bool is_package(void) const
Definition: ov-base.h:399
virtual bool issparse(void) const
Definition: ov-base.h:453
virtual bool is_uint16_type(void) const
Definition: ov-base.h:431
virtual bool is_constant(void) const
Definition: ov-base.h:459
virtual bool is_uint32_type(void) const
Definition: ov-base.h:433
virtual bool is_user_function(void) const
Definition: ov-base.h:471
virtual void erase_subfunctions(void)
Definition: ov-base.h:481
int current_print_indent_level(void) const
Definition: ov-base.h:847
virtual bool is_string(void) const
Definition: ov-base.h:383
virtual octave_base_value * unique_parent_class(const std::string &)
Definition: ov-base.h:615
virtual bool is_complex_matrix(void) const
Definition: ov-base.h:371
virtual bool is_int32_type(void) const
Definition: ov-base.h:425
virtual void call_object_destructor(void)
Definition: ov-base.h:722
virtual bool isjava(void) const
Definition: ov-base.h:401
virtual float float_scalar_value(bool frc_str_conv=false) const
Definition: ov-base.h:508
virtual bool is_function_handle(void) const
Definition: ov-base.h:461
virtual bool print_as_scalar(void) const
Definition: ov-base.h:647
virtual bool is_true(void) const
Definition: ov-base.h:455
void release(void)
Definition: ov-base.h:824
virtual octave_base_value * unique_clone(void)
Definition: ov-base.h:248
virtual void assign(const std::string &, const octave_value &)
Definition: ov-base.h:302
virtual bool iscellstr(void) const
Definition: ov-base.h:363
virtual bool is_uint8_type(void) const
Definition: ov-base.h:429
virtual bool is_bool_scalar(void) const
Definition: ov-base.h:373
virtual bool is_inline_function(void) const
Definition: ov-base.h:465
virtual bool islogical(void) const
Definition: ov-base.h:437
virtual bool is_user_script(void) const
Definition: ov-base.h:469
bool is_zero_by_zero(void) const
Definition: ov-base.h:359
virtual std::string edit_display(const float_display_format &, octave_idx_type, octave_idx_type) const
Definition: ov-base.h:665
virtual bool isobject(void) const
Definition: ov-base.h:391
static int curr_print_indent_level
Definition: ov-base.h:871
octave_base_value(void)
Definition: ov-base.h:230
virtual bool is_matrix_type(void) const
Definition: ov-base.h:449
virtual bool is_complex_scalar(void) const
Definition: ov-base.h:369
virtual bool is_bool_matrix(void) const
Definition: ov-base.h:375
virtual void maybe_economize(void)
Definition: ov-base.h:277
virtual bool is_scalar_type(void) const
Definition: ov-base.h:447
void reset_indent_level(void) const
Definition: ov-base.h:838
virtual bool is_all_va_args(void) const
Definition: ov-base.h:407
virtual octave_idx_type * mex_get_ir(void) const
Definition: ov-base.h:693
virtual bool is_cs_list(void) const
Definition: ov-base.h:403
virtual bool is_int16_type(void) const
Definition: ov-base.h:423
virtual dim_vector dims(void) const
Definition: ov-base.h:316
virtual octave_idx_type numel(void) const
Definition: ov-base.h:335
virtual builtin_type_t builtin_type(void) const
Definition: ov-base.h:413
virtual bool is_dld_function(void) const
Definition: ov-base.h:477
octave_base_value(const octave_base_value &)
Definition: ov-base.h:232
virtual bool is_int8_type(void) const
Definition: ov-base.h:421
virtual bool isstruct(void) const
Definition: ov-base.h:389
virtual octave_base_value * try_narrowing_conversion(void)
Definition: ov-base.h:275
octave_idx_type rows(void) const
Definition: ov-base.h:318
void grab(void)
Definition: ov-base.h:817
virtual bool is_double_type(void) const
Definition: ov-base.h:415
virtual double scalar_value(bool frc_str_conv=false) const
Definition: ov-base.h:505
virtual octave_base_value * find_parent_class(const std::string &)
Definition: ov-base.h:612
virtual bool is_char_matrix(void) const
Definition: ov-base.h:377
virtual octave_idx_type * mex_get_jc(void) const
Definition: ov-base.h:695
virtual bool is_anonymous_function(void) const
Definition: ov-base.h:463
virtual bool is_int64_type(void) const
Definition: ov-base.h:427
virtual bool islocked(void) const
Definition: ov-base.h:720
virtual bool is_instance_of(const std::string &) const
Definition: ov-base.h:618
virtual int ndims(void) const
Definition: ov-base.h:332
virtual bool isnull(void) const
Definition: ov-base.h:457
virtual bool is_real_scalar(void) const
Definition: ov-base.h:365
virtual bool iscomplex(void) const
Definition: ov-base.h:443
virtual bool is_perm_matrix(void) const
Definition: ov-base.h:381
virtual bool is_classdef_meta(void) const
Definition: ov-base.h:393
virtual bool is_single_type(void) const
Definition: ov-base.h:417
virtual bool is_magic_colon(void) const
Definition: ov-base.h:405
virtual size_t byte_size(void) const
Definition: ov-base.h:337
virtual bool isreal(void) const
Definition: ov-base.h:441
virtual bool isnumeric(void) const
Definition: ov-base.h:451
virtual bool is_defined(void) const
Definition: ov-base.h:355
virtual bool is_sq_string(void) const
Definition: ov-base.h:385
virtual octave_base_value * clone(void) const
Definition: ov-base.h:238
virtual bool iscell(void) const
Definition: ov-base.h:361
bool isempty(void) const
Definition: ov-base.h:357
virtual bool is_builtin_function(void) const
Definition: ov-base.h:475
virtual bool is_range(void) const
Definition: ov-base.h:387
MatrixType matrix_type(void) const
Definition: ov.h:542
uint64_t uint64_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:788
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov.h:1233
int32NDArray int32_array_value(void) const
Definition: ov.h:909
boolNDArray bool_array_value(bool warn=false) const
Definition: ov.h:844
uint16NDArray uint16_array_value(void) const
Definition: ov.h:918
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:853
bool bool_value(bool warn=false) const
Definition: ov.h:838
octave_int64 int64_scalar_value(void) const
Definition: ov.h:888
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov.h:1221
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov.h:449
charMatrix char_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:847
octave_uint8 uint8_scalar_value(void) const
Definition: ov.h:891
DiagMatrix diag_matrix_value(bool force=false) const
Definition: ov.h:863
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
Assign the n-th element, aka 'val(n) = x'.
Definition: ov.h:1459
octave_uint32 uint32_scalar_value(void) const
Definition: ov.h:897
octave_user_function * user_function_value(bool silent=false) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:765
void print_with_name(std::ostream &os, const std::string &name) const
Definition: ov.h:1239
octave_idx_type nnz(void) const
Definition: ov.h:524
mxArray * as_mxArray(void) const
Definition: ov.h:1331
int64_t int64_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:784
short int short_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:758
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
Definition: ov.h:475
octave_value permute(const Array< int > &vec, bool inv=false) const
Definition: ov.h:533
FloatDiagMatrix float_diag_matrix_value(bool force=false) const
Definition: ov.h:866
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:824
std::list< std::string > parent_class_name_list(void) const
Definition: ov.h:951
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov.h:1306
octave_value dump(void) const
Definition: ov.h:1362
Complex complex_value(bool frc_str_conv=false) const
Definition: ov.h:818
octave_value as_uint64(void) const
Definition: ov.h:429
octave_value as_uint16(void) const
Definition: ov.h:427
FloatComplexDiagMatrix float_complex_diag_matrix_value(bool force=false) const
Definition: ov.h:873
octave_value as_single(void) const
Definition: ov.h:419
octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
unsigned short int ushort_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:762
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov.h:1310
octave_value full_value(void) const
Definition: ov.h:413
Range range_value(void) const
Definition: ov.h:938
octave_value squeeze(void) const
Definition: ov.h:409
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov.h:1339
size_t nparents(void) const
Definition: ov.h:948
void convert_to_row_or_column_vector(void)
Definition: ov.h:1224
octave_user_code * user_code_value(bool silent=false) const
ComplexNDArray complex_array_value(bool frc_str_conv=false) const
Definition: ov.h:831
octave_base_value * empty_clone(void) const
Definition: ov.h:321
octave_value as_uint32(void) const
Definition: ov.h:428
octave_int8 int8_scalar_value(void) const
Definition: ov.h:879
bool save_binary(std::ostream &os, bool save_as_floats)
Definition: ov.h:1303
charNDArray char_array_value(bool frc_str_conv=false) const
Definition: ov.h:850
octave_int32 int32_scalar_value(void) const
Definition: ov.h:885
octave_uint16 uint16_scalar_value(void) const
Definition: ov.h:894
bool save_ascii(std::ostream &os)
Definition: ov.h:1299
Cell cell_value(void) const
Matrix size(void)
Definition: ov.h:435
FloatComplex float_complex_value(bool frc_str_conv=false) const
Definition: ov.h:821
octave_idx_type xnumel(const octave_value_list &idx)
Definition: ov.h:440
int8NDArray int8_array_value(void) const
Definition: ov.h:903
octave_value as_int64(void) const
Definition: ov.h:424
float float_value(bool frc_str_conv=false) const
Definition: ov.h:797
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov.h:1314
int64NDArray int64_array_value(void) const
Definition: ov.h:912
octave_function * function_value(bool silent=false) const
unsigned long int ulong_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:780
uint8NDArray uint8_array_value(void) const
Definition: ov.h:915
octave_value any(int dim=0) const
Definition: ov.h:640
octave_value reshape(const dim_vector &dv) const
Definition: ov.h:530
octave_value as_int16(void) const
Definition: ov.h:422
octave_value as_uint8(void) const
Definition: ov.h:426
bool load_ascii(std::istream &is)
Definition: ov.h:1301
octave_value as_int32(void) const
Definition: ov.h:423
octave_fcn_handle * fcn_handle_value(bool silent=false) const
boolMatrix bool_matrix_value(bool warn=false) const
Definition: ov.h:841
octave_idx_type nfields(void) const
Definition: ov.h:528
octave_value fast_elem_extract(octave_idx_type n) const
Extract the n-th element, aka 'val(n)'.
Definition: ov.h:1447
void unlock(void)
Definition: ov.h:1356
std::string string_value(bool force=false) const
Definition: ov.h:927
ComplexDiagMatrix complex_diag_matrix_value(bool force=false) const
Definition: ov.h:869
void lock(void)
Definition: ov.h:1354
int nint_value(bool frc_str_conv=false) const
Definition: ov.h:772
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:809
string_vector parent_class_names(void) const
Definition: ov.h:954
void print_info(std::ostream &os, const std::string &prefix="") const
Definition: ov.cc:2612
octave_scalar_map scalar_map_value(void) const
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1436
octave_idx_type nzmax(void) const
Definition: ov.h:526
long int long_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:776
uint64NDArray uint64_array_value(void) const
Definition: ov.h:924
string_vector string_vector_value(bool pad=false) const
Definition: ov.h:930
PermMatrix perm_matrix_value(void) const
Definition: ov.h:876
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov.h:1351
octave_classdef * classdef_object_value(bool silent=false) const
octave_uint64 uint64_scalar_value(void) const
Definition: ov.h:900
SparseBoolMatrix sparse_bool_matrix_value(bool warn=false) const
Definition: ov.h:860
NDArray array_value(bool frc_str_conv=false) const
Definition: ov.h:812
int write(octave::stream &os, int block_size, oct_data_conv::data_type output_type, int skip, octave::mach_info::float_format flt_fmt) const
uint32NDArray uint32_array_value(void) const
Definition: ov.h:921
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov.h:1216
bool print_name_tag(std::ostream &os, const std::string &name) const
Definition: ov.h:1236
octave_value_list list_value(void) const
sortmode issorted(sortmode mode=UNSORTED) const
Definition: ov.h:1345
octave_value all(int dim=0) const
Definition: ov.h:637
std::string xstring_value(const char *fmt,...) const
octave_map map_value(void) const
idx_vector index_vector(bool require_integers=false) const
Definition: ov.h:493
FloatComplexNDArray float_complex_array_value(bool frc_str_conv=false) const
Definition: ov.h:835
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov.h:539
FloatNDArray float_array_value(bool frc_str_conv=false) const
Definition: ov.h:815
octave_int16 int16_scalar_value(void) const
Definition: ov.h:882
Array< std::string > cellstr_value(void) const
Definition: ov.h:935
int16NDArray int16_array_value(void) const
Definition: ov.h:906
string_vector map_keys(void) const
Definition: ov.h:945
octave_base_value * clone(void) const
Matrix matrix_value(bool frc_str_conv=false) const
Definition: ov.h:806
FloatComplexMatrix float_complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:828
void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov.h:1230
octave_value diag(octave_idx_type k=0) const
Definition: ov.h:1333
double double_value(bool frc_str_conv=false) const
Definition: ov.h:794
unsigned int uint_value(bool req_int=false, bool frc_str_conv=false) const
Definition: ov.h:769
octave_value as_int8(void) const
Definition: ov.h:421
dim_vector dims(void) const
Definition: ov.h:500
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
Definition: ov.h:857
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
octave_user_script * user_script_value(bool silent=false) const
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov.h:1348
QString name
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
static float_display_format get_edit_display_format(const octave_value &val)
type_info & __get_type_info__(const std::string &who)
std::complex< double > Complex
Definition: oct-cmplx.h:33
std::complex< float > FloatComplex
Definition: oct-cmplx.h:34
int64_t octave_hdf5_id
sortmode
Definition: oct-sort.h:95
@ UNSORTED
Definition: oct-sort.h:95
@ ASCENDING
Definition: oct-sort.h:95
static double as_double(time_t sec, long usec)
Definition: oct-time.h:37
bool btyp_isnumeric(builtin_type_t btyp)
Definition: ov-base.h:97
bool btyp_isinteger(builtin_type_t btyp)
Definition: ov-base.h:100
OCTINTERP_API builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
Determine the resulting type for a possible mixed-type operation.
Definition: ov-base.cc:65
OCTINTERP_API bool called_from_builtin(void)
Definition: ov-base.cc:1457
#define DEF_CLASS_TO_BTYP(CLASS, BTYP)
Definition: ov-base.h:131
OCTINTERP_API std::string btyp_class_name[btyp_num_types]
Definition: ov-base.cc:89
#define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:161
bool btyp_isarray(builtin_type_t btyp)
Definition: ov-base.h:106
bool btyp_isfloat(builtin_type_t btyp)
Definition: ov-base.h:103
OCTINTERP_API octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
Definition: ov-base.cc:1394
OCTINTERP_API bool Vsparse_auto_mutate
Definition: ov-base.cc:103
builtin_type_t
Definition: ov-base.h:72
@ btyp_float_complex
Definition: ov-base.h:76
@ btyp_cell
Definition: ov-base.h:88
@ btyp_func_handle
Definition: ov-base.h:89
@ btyp_double
Definition: ov-base.h:73
@ btyp_int32
Definition: ov-base.h:79
@ btyp_float
Definition: ov-base.h:74
@ btyp_struct
Definition: ov-base.h:87
@ btyp_uint16
Definition: ov-base.h:82
@ btyp_int64
Definition: ov-base.h:80
@ btyp_bool
Definition: ov-base.h:85
@ btyp_unknown
Definition: ov-base.h:90
@ btyp_uint64
Definition: ov-base.h:84
@ btyp_int16
Definition: ov-base.h:78
@ btyp_uint32
Definition: ov-base.h:83
@ btyp_num_types
Definition: ov-base.h:91
@ btyp_char
Definition: ov-base.h:86
@ btyp_uint8
Definition: ov-base.h:81
@ btyp_int8
Definition: ov-base.h:77
@ btyp_complex
Definition: ov-base.h:75
static const builtin_type_t btyp
Definition: ov-base.h:128