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)
163 "non-integer range used as index");
180 "range",
"real scalar");
200 "range",
"real scalar");
219 retval.
elem (i) =
static_cast<char>(matrix.
elem (i));
258 return mat.
diag (m, n);
272 retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0);
290 "range",
"complex scalar");
312 "range",
"complex scalar");
376 if (n == 0 || n == 1)
420 if (c ==
' ' || c ==
'\t' || c ==
'\n')
433 double base = r.
base ();
434 double limit = r.
limit ();
435 double inc = r.
inc ();
439 os <<
"# base, limit, increment\n";
441 os <<
"# base, length, increment\n";
462 double base, limit, inc;
463 is >> base >> limit >> inc;
467 error (
"load: failed to load range constant");
474 range =
Range (base, inc, static_cast<octave_idx_type> (limit));
483 os.write (reinterpret_cast<char *> (&tmp), 1);
485 double bas = r.
base ();
486 double lim = r.
limit ();
487 double inc = r.
inc ();
491 os.write (reinterpret_cast<char *> (&bas), 8);
492 os.write (reinterpret_cast<char *> (&lim), 8);
493 os.write (reinterpret_cast<char *> (&inc), 8);
503 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
505 double bas, lim, inc;
506 if (! is.read (reinterpret_cast<char *> (&bas), 8))
510 if (! is.read (reinterpret_cast<char *> (&lim), 8))
514 if (! is.read (reinterpret_cast<char *> (&inc), 8))
521 range =
Range (bas, inc, static_cast<octave_idx_type> (lim));
526 #if defined (HAVE_HDF5)
537 hid_t type_id = H5Tcreate (H5T_COMPOUND,
sizeof (
double) * 3);
539 H5Tinsert (type_id,
"base", 0 *
sizeof (
double), num_type);
540 H5Tinsert (type_id,
"limit", 1 *
sizeof (
double), num_type);
541 H5Tinsert (type_id,
"increment", 2 *
sizeof (
double), num_type);
551 hid_t space_hid = -1, type_hid = -1, data_hid = -1;
554 space_hid = H5Screate_simple (0, dimens, 0);
555 if (space_hid < 0)
return false;
560 H5Sclose (space_hid);
564 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
565 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
567 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, H5P_DEFAULT);
571 H5Sclose (space_hid);
577 double range_vals[3];
578 range_vals[0] = r.
base ();
580 range_vals[2] = r.
inc ();
582 if (H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, H5P_DEFAULT,
587 "OCTAVE_RANGE_NELEM", &nel) >= 0;
594 H5Sclose (space_hid);
605 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
607 hid_t data_hid = H5Dopen (loc_id, name);
609 hid_t type_hid = H5Dget_type (data_hid);
615 H5Tclose (range_type);
620 hid_t space_hid = H5Dget_space (data_hid);
621 hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
625 H5Tclose (range_type);
626 H5Sclose (space_hid);
632 if (H5Dread (data_hid, range_type, H5S_ALL, H5S_ALL, H5P_DEFAULT,
638 "OCTAVE_RANGE_NELEM", &nel))
639 range =
Range (rangevals[0], rangevals[2], nel);
642 if (rangevals[2] != 0)
643 range =
Range (rangevals[0], rangevals[1], rangevals[2]);
646 static_cast<octave_idx_type> (rangevals[1]));
650 H5Tclose (range_type);
651 H5Sclose (space_hid);
664 double *pr =
static_cast<double *
> (retval->
get_data ());
670 const double *p = m.
data ();
672 for (
mwSize i = 0; i < nel; i++)
678 DEFUN (allow_noninteger_range_as_index, args, nargout,
680 @deftypefn {Built-in Function} {@var{val} =} allow_noninteger_range_as_index ()\n\
681 @deftypefnx {Built-in Function} {@var{old_val} =} allow_noninteger_range_as_index (@var{new_val})\n\
682 @deftypefnx {Built-in Function} {} allow_noninteger_range_as_index (@var{new_val}, \"local\")\n\
683 Query or set the internal variable that controls whether non-integer\n\
684 ranges are allowed as indices. This might be useful for @sc{matlab}\n\
685 compatibility; however, it is still not entirely compatible because\n\
686 @sc{matlab} treats the range expression differently in different contexts.\n\
688 When called from inside a function with the @qcode{\"local\"} option, the\n\
689 variable is changed locally for the function and any subroutines it calls. \n\
690 The original variable value is restored when exiting the function.\n\