47 const std::list<octave_value_list>& idx)
54 retval = do_index_op (idx.front ());
60 std::string nm = type_name ();
61 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
75 const std::list<octave_value_list>& idx,
84 if (type.length () == 1)
85 retval = numeric_assign (type, idx, rhs);
94 error (
"invalid assignment expression");
98 retval = tmp.
subsasgn (type, idx, rhs);
102 std::string nm = type_name ();
103 error (
"in indexed assignment of %s, last lhs index must be ()",
114 std::string nm = type_name ();
115 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
120 retval = tmp.
subsasgn (type, idx, rhs);
131template <
typename MT>
140 int nd = matrix.ndims ();
141 const MT& cmatrix = matrix;
164 retval = cmatrix.checkelem (i(0));
166 retval = MT (matrix.index (i, resize_ok));
179 retval = cmatrix.checkelem (i(0), j(0));
181 retval = MT (matrix.index (i, j, resize_ok));
188 bool scalar_opt = n_idx == nd && ! resize_ok;
191 for (k = 0; k < n_idx; k++)
193 idx_vec(k) = idx(k).index_vector ();
195 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ());
201 retval = MT (matrix.index (idx_vec, resize_ok));
223template <
typename MT>
247 matrix.assign (i, rhs);
258 matrix.assign (i, j, rhs);
266 for (k = 0; k < n_idx; k++)
267 idx_vec(k) = idx(k).index_vector ();
269 matrix.assign (idx_vec, rhs);
282 clear_cached_info ();
285template <
typename MT>
294template <
typename MT>
297 typename MT::element_type rhs)
301 int nd = matrix.ndims ();
324 if (i.
is_scalar () && i(0) < matrix.numel ())
327 matrix.assign (i, mrhs);
340 && i(0) < matrix.rows () && j(0) < matrix.columns ())
341 matrix(i(0), j(0)) = rhs;
343 matrix.assign (i, j, mrhs);
350 bool scalar_opt = n_idx == nd;
353 for (k = 0; k < n_idx; k++)
355 idx_vec(k) = idx(k).index_vector ();
357 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ()
358 && idx_vec(k)(0) < dv(k));
369 j += idx_vec(i)(0) * n;
375 matrix.assign (idx_vec, mrhs);
388 clear_cached_info ();
391template <
typename MT>
400 ra_idx(i) = idx(i).index_vector ();
402 matrix.delete_elements (
ra_idx);
405 clear_cached_info ();
408template <
typename MT>
414 retval.resize (dv, 0);
421template <
typename MT>
427 int nel = dv.
numel ();
433 if (t1.any_element_is_nan ())
447template <
typename MT>
456template <
typename MT>
460 print_raw (os, pr_as_read_syntax);
464template <
typename MT>
467 const std::string& prefix)
const
469 matrix.print_info (os, prefix);
472template <
typename MT>
476 if (matrix.isempty ())
478 else if (matrix.ndims () == 2)
495 std::ostringstream buf;
497 std::string tmp = buf.str ();
498 std::size_t pos = tmp.find_first_not_of (
' ');
499 if (pos != std::string::npos)
500 os << tmp.substr (pos);
501 else if (! tmp.empty ())
504 if (++elts >= max_elts)
511 if (i < nr - 1 && elts < max_elts)
524template <
typename MT>
531template <
typename MT>
537 std::ostringstream buf;
542template <
typename MT>
546 if (n < matrix.numel ())
552template <
typename MT>
557 if (n < matrix.numel ())
560 typedef typename MT::element_type ET;
566 void *here =
reinterpret_cast<void *
> (&matrix(n));
568 return x.get_rep ().fast_elem_insert_self (here, btyp);
Array< octave_idx_type > conv_to_int_array(const Array< octave::idx_vector > &a)
N Dimensional Array with copy-on-write semantics.
OCTAVE_API boolNDArray all(int dim=-1) const
Vector representing the dimensions (size) of an Array.
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
bool all_ones(void) const
OCTAVE_API dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
bool any_zero(void) const
bool is_scalar(void) const
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
MatrixType matrix_type(void) const
OCTINTERP_API bool fast_elem_insert(octave_idx_type n, const octave_value &x)
octave_value resize(const dim_vector &dv, bool fill=false) const
OCTINTERP_API octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
OCTINTERP_API octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
OCTINTERP_API void delete_elements(const octave_value_list &idx)
OCTINTERP_API octave_value fast_elem_extract(octave_idx_type n) const
OCTINTERP_API void print_info(std::ostream &os, const std::string &prefix) const
OCTINTERP_API bool print_as_scalar(void) const
OCTINTERP_API void print(std::ostream &os, bool pr_as_read_syntax=false)
OCTINTERP_API float_display_format get_edit_display_format(void) const
OCTINTERP_API void short_disp(std::ostream &os) const
OCTINTERP_API void assign(const octave_value_list &idx, const MT &rhs)
OCTINTERP_API bool is_true(void) const
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
OCTINTERP_API std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
octave_idx_type length(void) const
static OCTINTERP_API octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
OCTINTERP_API octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, std::size_t skip=1)
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
void error(const char *fmt,...)
#define panic_impossible()
void warn_empty_index(const std::string &type_name)
void warn_array_as_logical(const dim_vector &dv)
F77_RET_T const F77_DBLE * x
void err_nan_to_logical_conversion(void)
const octave_base_value const Array< octave_idx_type > & ra_idx
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
float_display_format make_format(const double &d)