44 template <
typename MT>
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]);
72 template <
typename MT>
75 const std::list<octave_value_list>& idx,
84 if (
type.length () == 1)
94 error (
"invalid assignment expression");
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]);
131 template <
typename MT>
140 int nd = matrix.ndims ();
141 const MT& cmatrix = matrix;
166 retval = MT (matrix.index (i, resize_ok));
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));
223 template <
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 ();
285 template <
typename MT>
294 template <
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 ();
391 template <
typename MT>
400 ra_idx(i) = idx(i).index_vector ();
402 matrix.delete_elements (
ra_idx);
405 clear_cached_info ();
408 template <
typename MT>
421 template <
typename MT>
427 int nel = dv.
numel ();
433 if (t1.any_element_is_nan ())
447 template <
typename MT>
456 template <
typename MT>
460 print_raw (os, pr_as_read_syntax);
464 template <
typename MT>
467 const std::string& prefix)
const
469 matrix.print_info (os, prefix);
472 template <
typename MT>
476 if (matrix.isempty ())
478 else if (matrix.ndims () == 2)
495 std::ostringstream buf;
497 std::string tmp = buf.str ();
498 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)
524 template <
typename MT>
531 template <
typename MT>
537 std::ostringstream buf;
542 template <
typename MT>
546 if (
n < matrix.numel ())
552 template <
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< idx_vector > &a)
N Dimensional Array with copy-on-write semantics.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
T & checkelem(octave_idx_type n)
Size of the specified dimension.
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
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)
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
MatrixType matrix_type(void) const
bool fast_elem_insert(octave_idx_type n, const octave_value &x)
octave_value resize(const dim_vector &dv, bool fill=false) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
virtual void assign(const std::string &, const octave_value &)
void delete_elements(const octave_value_list &idx)
octave_value fast_elem_extract(octave_idx_type n) const
void print_info(std::ostream &os, const std::string &prefix) const
bool print_as_scalar(void) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
float_display_format get_edit_display_format(void) const
void short_disp(std::ostream &os) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
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 octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
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()) ? '\'' :'"'))
octave_value::octave_value(const Array< char > &chm, char type) return retval
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)