26 #if defined (HAVE_CONFIG_H)
86 retval = (
x > y) ?
x : y;
93 "double",
"single",
"double",
"single",
94 "int8",
"int16",
"int32",
"int64",
95 "uint8",
"uint16",
"uint32",
"uint64",
97 "struct",
"cell",
"function_handle",
"unknown"
101 "<unknown type>",
"unknown");
106 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
110 # pragma GCC diagnostic push
111 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
116 #if defined (HAVE_PRAGMA_GCC_DIAGNOSTIC)
117 # pragma GCC diagnostic pop
146 error (
"squeeze: invalid operation for %s type", nm.c_str ());
242 std::list<octave_value_list> idx_list;
243 idx_list.push_back (idx);
244 return subsref (std::string {type}, idx_list, nargout);
249 const std::list<octave_value_list>&)
252 error (
"can't perform indexing operations for %s type", nm.c_str ());
257 const std::list<octave_value_list>&,
int)
260 error (
"can't perform indexing operations for %s type", nm.c_str ());
265 const std::list<octave_value_list>& idx,
276 error (
"can't perform indexing operations for %s type", nm.c_str ());
282 std::string nm =
'<' +
type_name () +
'>';
290 std::list<octave_value_list> idx_list;
291 idx_list.push_back (idx);
293 return subsasgn (std::string {type}, idx_list, rhs);
298 const std::list<octave_value_list>& idx,
308 error (
"can't perform indexed assignment for %s type", nm.c_str ());
315 if (type.length () == 1)
326 retval = tmp.
subsasgn (type, idx, rhs);
331 error (
"in indexed assignment of %s, last rhs index must be ()",
341 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
364 const std::list<octave_value_list>& idx,
456 (
"octave_base_value::convert_to_row_or_column_vector ()",
type_name ());
473 const std::string& name)
const
494 const std::string& name,
513 const std::string& )
const
515 os <<
"no info for type: " <<
type_name () <<
"\n";
518 #define INT_CONV_METHOD(T, F) \
520 octave_base_value::F ## _value (bool require_int, bool frc_str_conv) const \
528 d = double_value (frc_str_conv); \
530 catch (octave::execution_exception& ee) \
532 err_wrong_type_arg (ee, "octave_base_value::" #F "_value ()", type_name ()); \
535 static const double out_of_range_top \
536 = static_cast<double> (std::numeric_limits<T>::max ()) + 1.; \
537 if (require_int && octave::math::x_nint (d) != d) \
538 error_with_cfn ("conversion of %g to " #T " value failed", d); \
539 else if (d < std::numeric_limits<T>::min ()) \
540 retval = std::numeric_limits<T>::min (); \
541 else if (d >= out_of_range_top) \
542 retval = std::numeric_limits<T>::max (); \
544 retval = static_cast<T> (octave::math::fix (d)); \
568 d = double_value (frc_str_conv);
570 catch (octave::execution_exception& ee)
576 error (
"conversion of NaN to integer value failed");
862 wrong_type_arg_error ();
864 return std::string ();
873 octave::range<double>
892 if (tmp.
numel () != 1)
893 error (
"invalid conversion of multi-dimensional struct to scalar struct");
916 std::list<std::string>
1160 (
"Octave:load-save-unavailable",
1161 "%s: loading %s files not available in this version of Octave",
1162 s_t_name.c_str (), type);
1169 (
"Octave:load-save-unavailable",
1170 "%s: saving %s files not available in this version of Octave",
1171 s_t_name.c_str (), type);
1175 octave_base_value::wrong_type_arg_error ()
const
1201 std::map<std::string, octave_value>
m
1210 OCTAVE_NORETURN
static
1212 err_indexed_assignment (
const std::string& tn1,
const std::string& tn2)
1214 error (
"assignment of '%s' to indexed '%s' not implemented",
1215 tn2.c_str (), tn1.c_str ());
1218 OCTAVE_NORETURN
static
1220 err_assign_conversion_failed (
const std::string& tn1,
const std::string& tn2)
1222 error (
"type conversion for assignment of '%s' to indexed '%s' failed",
1223 tn2.c_str (), tn1.c_str ());
1226 OCTAVE_NORETURN
static
1228 err_no_conversion (
const std::string& on,
const std::string& tn1,
1229 const std::string& tn2)
1231 error (
"operator %s: no conversion for assignment of '%s' to indexed '%s'",
1232 on.c_str (), tn2.c_str (), tn1.c_str ());
1237 const std::list<octave_value_list>& idx,
1242 if (idx.front ().empty ())
1243 error (
"missing index in indexed assignment");
1257 f (*
this, idx.front (), rhs.
get_rep ());
1269 int t_result = ti.lookup_pref_assign_conv (t_lhs, t_rhs);
1274 = ti.lookup_widening_op (t_lhs, t_result);
1286 retval = val.
subsasgn (type, idx, rhs);
1305 || ti.lookup_pref_assign_conv (t_lhs,
1308 else if (cf_this.
type_id () >= 0
1311 || ti.lookup_pref_assign_conv (cf_this.
type_id (),
1340 if (! cf_this && ! cf_rhs)
1345 retval = tmp_lhs.
subsasgn (type, idx, tmp_rhs);
1359 int octave_base_value::s_curr_print_indent_level = 0;
1362 bool octave_base_value::s_beginning_of_line =
true;
1373 if (s_beginning_of_line)
1378 for (
int i = 0; i < s_curr_print_indent_level; i++)
1381 s_beginning_of_line =
false;
1392 s_beginning_of_line =
true;
1400 s_beginning_of_line =
true;
1401 s_curr_print_indent_level = 0;
1453 if (retval(i).is_magic_colon ())
1462 const std::list<octave_value_list>& idx,
1463 const std::string& who)
1465 std::size_t
len = type.length ();
1467 if (
len != idx.size ())
1468 error (
"invalid index for %s", who.c_str ());
1473 auto p = idx.begin ();
1475 for (std::size_t i = 0; i <
len; i++)
1482 type_field(i) =
"()";
1483 subs_field(i) =
Cell (sanitize (*p++));
1487 type_field(i) =
"{}";
1488 subs_field(i) =
Cell (sanitize (*p++));
1493 type_field(i) =
".";
1497 if (vlist.
length () != 1)
1498 error (
"only single argument permitted for '.' index");
1503 error (
"string argument required for '.' index");
1505 subs_field(i) = val;
1517 m.assign (
"type", type_field);
1518 m.assign (
"subs", subs_field);
1536 return (fcn && fcn->
name () ==
"builtin");
1557 complex_matrix_conv);
1562 OCTAVE_END_NAMESPACE(
octave)
Vector representing the dimensions (size) of an Array.
Array< octave_idx_type > as_array() const
octave_idx_type ndims() const
Number of dimensions.
virtual bool load_hdf5(octave_hdf5_id loc_id, const char *name)
virtual SparseMatrix sparse_matrix_value(bool=false) const
virtual octave_value full_value() const
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
virtual float float_value(bool=false) const
virtual octave_base_value * make_storable_value()
virtual bool save_ascii(std::ostream &os)
virtual octave_int16 int16_scalar_value() const
virtual octave::range< double > range_value() const
virtual octave_value as_double() const
virtual FloatComplexDiagMatrix float_complex_diag_matrix_value(bool=false) const
virtual octave_idx_type numel() const
virtual uint16NDArray uint16_array_value() const
virtual ComplexNDArray complex_array_value(bool=false) const
virtual void print_with_name(std::ostream &output_buf, const std::string &name, bool print_padding=true)
virtual octave_value fast_elem_extract(octave_idx_type n) const
virtual boolNDArray bool_array_value(bool=false) const
virtual bool print_name_tag(std::ostream &os, const std::string &name) const
virtual uint32NDArray uint32_array_value() const
virtual MatrixType matrix_type() const
virtual FloatComplexNDArray float_complex_array_value(bool=false) const
virtual octave_user_script * user_script_value(bool silent=false)
virtual octave_value as_uint8() const
virtual charNDArray char_array_value(bool=false) const
virtual string_vector parent_class_names() const
virtual octave_value_list simple_subsref(char type, octave_value_list &idx, int nargout)
octave_base_value *(* type_conv_fcn)(const octave_base_value &)
virtual octave_value diag(octave_idx_type k=0) const
virtual octave_int8 int8_scalar_value() const
virtual Array< std::string > cellstr_value() const
virtual uint8NDArray uint8_array_value() const
void indent(std::ostream &os) const
virtual octave_uint32 uint32_scalar_value() const
virtual octave_value permute(const Array< int > &vec, bool=false) const
virtual octave_fcn_handle * fcn_handle_value(bool silent=false)
virtual charMatrix char_matrix_value(bool force=false) const
virtual octave_value storable_value()
void newline(std::ostream &os) const
virtual octave_classdef * classdef_object_value(bool silent=false)
virtual octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
virtual float_display_format get_edit_display_format() const
virtual octave_value all(int=0) const
virtual bool isfield(const std::string &) const
virtual sortmode is_sorted_rows(sortmode mode=UNSORTED) const
virtual octave_value as_uint16() const
virtual boolMatrix bool_matrix_value(bool=false) const
virtual FloatComplex float_complex_value(bool=false) const
virtual octave_value map(unary_mapper_t) const
virtual octave_idx_type nzmax() const
virtual octave_value convert_to_str_internal(bool pad, bool force, char type) const
virtual FloatComplexMatrix float_complex_matrix_value(bool=false) const
virtual ComplexMatrix complex_matrix_value(bool=false) const
virtual void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
virtual octave_int32 int32_scalar_value() const
virtual octave_idx_type nnz() const
virtual int32NDArray int32_array_value() const
virtual octave_value dump() const
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
virtual octave_value as_int32() const
virtual octave::idx_vector index_vector(bool require_integers=false) const
octave::refcount< octave_idx_type > m_count
virtual octave_uint64 uint64_scalar_value() const
virtual FloatDiagMatrix float_diag_matrix_value(bool=false) const
virtual bool save_binary(std::ostream &os, bool save_as_floats)
virtual type_conv_info numeric_conversion_function() const
octave_value numeric_assign(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
void warn_load(const char *type) const
virtual octave_value as_double_or_copy()
virtual int type_id() const
virtual octave_value reshape(const dim_vector &) const
virtual mxArray * as_mxArray(bool interleaved) const
virtual SparseBoolMatrix sparse_bool_matrix_value(bool=false) const
virtual string_vector map_keys() const
virtual octave_value_list list_value() const
virtual uint64NDArray uint64_array_value() const
static const char * get_umap_name(unary_mapper_t)
virtual int16NDArray int16_array_value() const
virtual bool load_ascii(std::istream &is)
virtual bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
virtual dim_vector dims() const
virtual FloatNDArray float_array_value(bool=false) const
virtual Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
virtual FloatMatrix float_matrix_value(bool=false) const
virtual octave_value as_int64() const
virtual octave_idx_type xnumel(const octave_value_list &)
virtual DiagMatrix diag_matrix_value(bool=false) const
virtual SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
virtual octave_idx_type nfields() const
virtual bool isnumeric() const
virtual octave_uint8 uint8_scalar_value() const
virtual int64NDArray int64_array_value() const
virtual bool print_as_scalar() const
virtual octave_value squeeze() const
virtual bool fast_elem_insert(octave_idx_type n, const octave_value &x)
virtual octave_user_function * user_function_value(bool silent=false)
virtual bool bool_value(bool=false) const
virtual octave_value as_uint32() const
virtual octave_value as_int16() const
virtual int8NDArray int8_array_value() const
virtual void print_info(std::ostream &os, const std::string &prefix) const
virtual std::string xstring_value() const
virtual bool fast_elem_insert_self(void *where, builtin_type_t btyp) const
virtual ComplexDiagMatrix complex_diag_matrix_value(bool=false) const
virtual bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
virtual octave_value as_int8() const
virtual void print(std::ostream &os, bool pr_as_read_syntax=false)
virtual octave_value resize(const dim_vector &, bool fill=false) const
virtual octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
virtual 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
virtual bool is_defined() const
virtual octave_int64 int64_scalar_value() const
virtual octave_map map_value() const
virtual NDArray array_value(bool=false) const
virtual std::string string_value(bool force=false) const
virtual std::size_t nparents() const
virtual octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
virtual octave_user_code * user_code_value(bool silent=false)
virtual octave_scalar_map scalar_map_value() const
virtual double double_value(bool=false) const
virtual octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
virtual Matrix matrix_value(bool=false) const
virtual std::string type_name() const
virtual std::string class_name() const
virtual octave_value simple_subsasgn(char type, octave_value_list &idx, const octave_value &rhs)
virtual sortmode issorted(sortmode mode=UNSORTED) const
virtual octave_base_value * empty_clone() const
virtual octave_function * function_value(bool silent=false)
virtual octave_value as_single() const
virtual string_vector string_vector_value(bool pad=false) const
friend class octave_value
virtual PermMatrix perm_matrix_value() const
virtual std::list< std::string > parent_class_name_list() const
virtual octave_value any(int=0) const
virtual Cell cell_value() const
virtual void convert_to_row_or_column_vector()
virtual octave_value as_uint64() const
virtual octave_uint16 uint16_scalar_value() const
virtual Complex complex_value(bool=false) const
void warn_save(const char *type) const
octave_scalar_map checkelem(octave_idx_type n) const
octave_idx_type numel() const
static octave_value make_copy(octave_base_value *rep)
octave_idx_type length() const
octave_base_value * clone() const
charMatrix char_matrix_value(bool frc_str_conv=false) const
static std::string assign_op_as_string(assign_op)
octave_value undef_subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
const octave_base_value & get_rep() const
octave_base_value::type_conv_info numeric_conversion_function() const
std::string string_value(bool force=false) const
string_vector string_vector_value(bool pad=false) const
std::string type_name() const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void warning_with_id(const char *id, const char *fmt,...)
void() error(const char *fmt,...)
#define panic_impossible()
#define panic_unless(cond)
void err_wrong_type_arg(const char *name, const char *s)
void err_invalid_conversion(const std::string &from, const std::string &to)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
octave::idx_vector idx_vector
type_info & __get_type_info__()
tree_evaluator & __get_evaluator__()
void err_invalid_index(const std::string &idx, octave_idx_type nd, octave_idx_type dim, const std::string &)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
F77_RET_T const F77_DBLE const F77_DBLE * f
octave_idx_type dims_to_numel(const dim_vector &dims, const octave_value_list &idx_arg)
std::complex< double > Complex
std::complex< float > FloatComplex
#define INSTALL_ASSIGNCONV_TI(ti, t1, t2, tr)
#define INSTALL_WIDENOP_TI(ti, t1, t2, f)
std::string btyp_class_name[btyp_num_types+1]
void install_base_type_conversions(octave::type_info &ti)
octave_value make_idx_args(const std::string &type, const std::list< octave_value_list > &idx, const std::string &who)
builtin_type_t btyp_mixed_numeric(builtin_type_t x, builtin_type_t y)
Determine the resulting type for a possible mixed-type operation.
#define INT_CONV_METHOD(T, F)
bool called_from_builtin()
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
octave::type_info::assign_op_fcn assign_op_fcn
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.