98 const std::list<octave_value_list>& idx)
112 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
126 if (idx.
length () == 1 && ! resize_ok)
164 "non-integer range used as index");
181 "range",
"real scalar");
201 "range",
"real scalar");
220 retval.
elem (i) =
static_cast<char>(matrix.
elem (i));
259 return mat.
diag (m, n);
273 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0);
291 "range",
"complex scalar");
313 "range",
"complex scalar");
377 if (n == 0 || n == 1)
421 if (c ==
' ' || c ==
'\t' || c ==
'\n')
434 double base = r.
base ();
435 double limit = r.
limit ();
436 double inc = r.
inc ();
440 os <<
"# base, limit, increment\n";
442 os <<
"# base, length, increment\n";
463 double base, limit, inc;
464 is >> base >> limit >> inc;
468 error (
"load: failed to load range constant");
475 range =
Range (base, inc, static_cast<octave_idx_type> (limit));
484 os.write (reinterpret_cast<char *> (&tmp), 1);
486 double bas = r.
base ();
487 double lim = r.
limit ();
488 double inc = r.
inc ();
492 os.write (reinterpret_cast<char *> (&bas), 8);
493 os.write (reinterpret_cast<char *> (&lim), 8);
494 os.write (reinterpret_cast<char *> (&inc), 8);
504 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
506 double bas, lim, inc;
507 if (! is.read (reinterpret_cast<char *> (&bas), 8))
511 if (! is.read (reinterpret_cast<char *> (&lim), 8))
515 if (! is.read (reinterpret_cast<char *> (&inc), 8))
522 range =
Range (bas, inc, static_cast<octave_idx_type> (lim));
527 #if defined (HAVE_HDF5)
538 hid_t type_id = H5Tcreate (H5T_COMPOUND,
sizeof (
double) * 3);
540 H5Tinsert (type_id,
"base", 0 *
sizeof (
double), num_type);
541 H5Tinsert (type_id,
"limit", 1 *
sizeof (
double), num_type);
542 H5Tinsert (type_id,
"increment", 2 *
sizeof (
double), num_type);
555 #if defined (HAVE_HDF5)
558 hid_t space_hid, type_hid, data_hid;
559 space_hid = type_hid = data_hid = -1;
561 space_hid = H5Screate_simple (0, dimens, 0);
562 if (space_hid < 0)
return false;
567 H5Sclose (space_hid);
571 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
572 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
574 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, H5P_DEFAULT);
578 H5Sclose (space_hid);
584 double range_vals[3];
585 range_vals[0] = r.
base ();
587 range_vals[2] = r.
inc ();
589 if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
594 "OCTAVE_RANGE_NELEM", &nel) >= 0;
601 H5Sclose (space_hid);
615 #if defined (HAVE_HDF5)
618 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
620 hid_t data_hid = H5Dopen (loc_id, name);
622 hid_t type_hid = H5Dget_type (data_hid);
628 H5Tclose (range_type);
633 hid_t space_hid = H5Dget_space (data_hid);
634 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
638 H5Tclose (range_type);
639 H5Sclose (space_hid);
645 if (H5Dread (data_hid, range_type, H5S_ALL, H5S_ALL, H5P_DEFAULT,
651 "OCTAVE_RANGE_NELEM", &nel))
652 range =
Range (rangevals[0], rangevals[2], nel);
655 if (rangevals[2] != 0)
656 range =
Range (rangevals[0], rangevals[1], rangevals[2]);
659 static_cast<octave_idx_type> (rangevals[1]));
663 H5Tclose (range_type);
664 H5Sclose (space_hid);
679 double *pr =
static_cast<double *
> (retval->
get_data ());
685 const double *p = m.
data ();
687 for (
mwSize i = 0; i < nel; i++)
700 DEFUN (allow_noninteger_range_as_index, args, nargout,
702 @deftypefn {Built-in Function} {@var{val} =} allow_noninteger_range_as_index ()\n\
703 @deftypefnx {Built-in Function} {@var{old_val} =} allow_noninteger_range_as_index (@var{new_val})\n\
704 @deftypefnx {Built-in Function} {} allow_noninteger_range_as_index (@var{new_val}, \"local\")\n\
705 Query or set the internal variable that controls whether non-integer\n\
706 ranges are allowed as indices.\n\
708 This might be useful for @sc{matlab} compatibility; however, it is still not\n\
709 entirely compatible because @sc{matlab} treats the range expression\n\
710 differently in different contexts.\n\
712 When called from inside a function with the @qcode{\"local\"} option, the\n\
713 variable is changed locally for the function and any subroutines it calls.\n\
714 The original variable value is restored when exiting the function.\n\
717 static bool warned =
false;
722 "allow_noninteger_range_as_index is obsolete and will be removed from a future version of Octave");
Matrix diag(octave_idx_type k=0) const
void octave_write_double(std::ostream &os, double d)
type_conv_info numeric_conversion_function(void) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
void warning_with_id(const char *id, const char *fmt,...)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
static hid_t hdf5_make_range_type(hid_t num_type)
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
bool hdf5_types_compatible(hid_t t1, hid_t t2)
mxArray * as_mxArray(void) const
boolMatrix any(int dim=-1) const
dim_vector dims(void) const
Range range_value(void) const
static void skip_comments(std::istream &is)
void gripe_load(const char *type) const
NDArray array_value(bool=false) const
octave_idx_type length(void) const
octave_idx_type nelem(void) const
void skip_until_newline(std::istream &is, bool keep_newline)
charNDArray char_array_value(bool=false) const
void swap_bytes< 8 >(void *ptr)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
octave_base_value * try_narrowing_conversion(void)
#define SET_INTERNAL_VARIABLE(NM)
float float_value(bool=false) const
void indent(std::ostream &os) const
bool load_ascii(std::istream &is)
void * get_data(void) const
bool save_binary(std::ostream &os, bool &save_as_floats)
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
void gripe_save(const char *type) const
T & elem(octave_idx_type n)
double lo_ieee_nan_value(void)
herr_t hdf5_add_scalar_attr(hid_t loc_id, hid_t type_id, const char *attr_name, void *buf)
bool any_element_is_nan(void) const
void newline(std::ostream &os) const
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
double double_value(bool=false) const
bool save_ascii(std::ostream &os)
virtual octave_idx_type numel(void) const
octave_value any(int dim=0) const
bool any_element_not_one_or_zero(void) const
OCTAVE_EMPTY_CPP_ARG std::string type_name(void) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
void short_disp(std::ostream &os) const
octave_value fast_elem_extract(octave_idx_type n) const
void gripe_nan_to_logical_conversion(void)
static int static_type_id(void)
const T * data(void) const
Matrix diag(octave_idx_type k=0) const
Matrix matrix_value(bool=false) const
void resize(const dim_vector &dv, const T &rfv)
double elem(octave_idx_type i) const
bool hdf5_get_scalar_attr(hid_t loc_id, hid_t type_id, const char *attr_name, void *buf)
#define panic_impossible()
Matrix matrix_value(void) const
bool print_name_tag(std::ostream &os, const std::string &name) const
boolNDArray bool_array_value(bool warn=false) const
float lo_ieee_float_nan_value(void)
friend class octave_value
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Array< double > index(const idx_vector &i) const
void gripe_logical_conversion(void)
void gripe_invalid_conversion(const std::string &from, const std::string &to)
boolMatrix all(int dim=-1) const
int current_print_indent_level(void) const
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
void octave_print_internal(std::ostream &, char, bool)
bool is_scalar(void) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
bool all_elements_are_ints(void) const
idx_vector index_vector(bool require_integers=false) const
static bool Vallow_noninteger_range_as_index
octave_value resize(const dim_vector &dv, bool fill=false) const
std::complex< float > FloatComplex
std::complex< double > Complex
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
FloatComplex float_complex_value(bool=false) const
octave_value diag(octave_idx_type k=0) const
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
Complex complex_value(bool=false) const
octave_value all(int dim=0) const
idx_vector set_idx_cache(const idx_vector &idx) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)