45 error (
"%s: dimension vector DIMS must not be empty", name);
53 if (ii == dimsv(i) && ii >= 0)
57 error (
"%s: dimension vector DIMS must contain integers", name);
68 @deftypefn {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{i}, @var{j})\n\
69 @deftypefnx {Function File} {@var{ind} =} sub2ind (@var{dims}, @var{s1}, @var{s2}, @dots{}, @var{sN})\n\
70 Convert subscripts to a linear index.\n\
72 The following example shows how to convert the two-dimensional index\n\
73 @code{(2,3)} of a 3-by-3 matrix to a linear index. The matrix is linearly\n\
74 indexed moving from one column to next, filling up all rows in each column.\n\
78 linear_index = sub2ind ([3, 3], 2, 3)\n\
85 int nargin = args.length ();
97 dv = dv.
redim (nargin - 1);
98 for (
int j = 0; j < nargin - 1; j++)
100 if (args(j+1).is_numeric_type ())
102 idxa(j) = args(j+1).index_vector ();
105 else if (j > 0 && args(j+1).dims () != args(1).dims ())
106 error (
"sub2ind: all subscripts must be of the same size");
109 error (
"sub2ind: subscripts must be numeric");
173 @deftypefn {Function File} {[@var{s1}, @var{s2}, @dots{}, @var{sN}] =} ind2sub (@var{dims}, @var{ind})\n\
174 Convert a linear index to subscripts.\n\
176 The following example shows how to convert the linear index @code{8}\n\
177 in a 3-by-3 matrix into a subscript. The matrix is linearly indexed\n\
178 moving from one column to next, filling up all rows in each column.\n\
182 [r, c] = ind2sub ([3, 3], 8)\n\
190 int nargin = args.length ();
201 if (nargout > dv.
length ())
202 dv = dv.
redim (nargout);
OCTINTERP_API void print_usage(void)
void resize(int n, int fill_value=0)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
static dim_vector get_dim_vector(const octave_value &val, const char *name)
idx_vector sub2ind(const dim_vector &dv, const Array< idx_vector > &idxa)
dim_vector redim(int n) const
Handles the reference counting for all the derived classes.
Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
charNDArray max(char d, const charNDArray &m)
octave_idx_type length(void) const
Number of elements in the array.
RowVector row_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const