51 return do_index_op (idx);
57 std::string nm = type_name ();
58 error (
"%s cannot be indexed with %c", nm.c_str (), type);
63 error (
"unexpected: index not '(', '{', or '.' in octave_base_matrix<T>::simple_subsref - please report this bug");
70 const std::list<octave_value_list>& idx)
77 retval = do_index_op (idx.front ());
83 std::string nm = type_name ();
84 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
89 error (
"unpexpected: index not '(', '{', or '.' in - octave_base_matrix<MT>::subsref please report this bug");
98 const std::list<octave_value_list>& idx,
107 if (type.length () == 1)
108 retval = numeric_assign (type, idx, rhs);
117 error (
"invalid assignment expression");
121 retval = tmp.
subsasgn (type, idx, rhs);
125 std::string nm = type_name ();
126 error (
"in indexed assignment of %s, last lhs index must be ()",
137 std::string nm = type_name ();
138 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
143 retval = tmp.
subsasgn (type, idx, rhs);
148 error (
"unpexpected: index not '(', '{', or '.' in - octave_base_matrix<MT>::subsasgn please report this bug");
154template <
typename MT>
163 int nd = m_matrix.ndims ();
164 const MT& cmatrix = m_matrix;
183 octave::idx_vector i = idx (0).index_vector ();
186 if (! resize_ok && i.is_scalar ())
187 retval = cmatrix.checkelem (i(0));
189 retval = MT (m_matrix.index (i, resize_ok));
195 octave::idx_vector i = idx (0).index_vector ();
198 octave::idx_vector j = idx (1).index_vector ();
201 if (! resize_ok && i.is_scalar () && j.is_scalar ())
202 retval = cmatrix.checkelem (i(0), j(0));
204 retval = MT (m_matrix.index (i, j, resize_ok));
211 bool scalar_opt = n_idx == nd && ! resize_ok;
214 for (k = 0; k < n_idx; k++)
216 idx_vec(k) = idx(k).index_vector ();
218 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ());
224 retval = MT (m_matrix.index (idx_vec, resize_ok));
229 catch (octave::index_exception& ie)
232 ie.set_pos_if_unset (n_idx, k+1);
246template <
typename MT>
263 error (
"unexpected: zero indices in octave_base_matrix<MT>::assign - please report this bug");
268 octave::idx_vector i = idx (0).index_vector ();
270 m_matrix.assign (i, rhs);
276 octave::idx_vector i = idx (0).index_vector ();
279 octave::idx_vector j = idx (1).index_vector ();
281 m_matrix.assign (i, j, rhs);
289 for (k = 0; k < n_idx; k++)
290 idx_vec(k) = idx(k).index_vector ();
292 m_matrix.assign (idx_vec, rhs);
297 catch (octave::index_exception& ie)
300 ie.set_pos_if_unset (n_idx, k+1);
305 clear_cached_info ();
308template <
typename MT>
317template <
typename MT>
320 typename MT::element_type rhs)
324 int nd = m_matrix.ndims ();
337 error (
"unexpected: zero indices in octave_base_matrix<MT>::assign - please report this bug");
342 octave::idx_vector i = idx (0).index_vector ();
345 if (i.is_scalar () && i(0) < m_matrix.numel ())
346 m_matrix(i(0)) = rhs;
350 m_matrix.assign (i, mrhs);
357 octave::idx_vector i = idx (0).index_vector ();
360 octave::idx_vector j = idx (1).index_vector ();
363 if (i.is_scalar () && j.is_scalar () && nd == 2
364 && i(0) < m_matrix.rows () && j(0) < m_matrix.columns ())
365 m_matrix(i(0), j(0)) = rhs;
369 m_matrix.assign (i, j, mrhs);
377 bool scalar_opt = n_idx == nd;
380 for (k = 0; k < n_idx; k++)
382 idx_vec(k) = idx(k).index_vector ();
384 scalar_opt = (scalar_opt && idx_vec(k).is_scalar ()
385 && idx_vec(k)(0) < dv(k));
396 j += idx_vec(i)(0) * n;
404 m_matrix.assign (idx_vec, mrhs);
410 catch (octave::index_exception& ie)
413 ie.set_pos_if_unset (n_idx, k+1);
418 clear_cached_info ();
421template <
typename MT>
430 ra_idx(i) = idx(i).index_vector ();
432 m_matrix.delete_elements (
ra_idx);
435 clear_cached_info ();
438template <
typename MT>
442 MT retval (m_matrix);
444 retval.resize (dv, 0);
451template <
typename MT>
457 int nel = dv.
numel ();
461 MT t1 (m_matrix.reshape (
dim_vector (nel, 1)));
463 if (t1.any_element_is_nan ())
464 octave::err_nan_to_logical_conversion ();
477template <
typename MT>
486template <
typename MT>
490 print_raw (os, pr_as_read_syntax);
494template <
typename MT>
497 const std::string& prefix)
const
499 m_matrix.print_info (os, prefix);
502template <
typename MT>
506 if (m_matrix.isempty ())
508 else if (m_matrix.ndims () == 2)
523 std::ostringstream buf;
525 std::string tmp = buf.str ();
526 std::size_t pos = tmp.find_first_not_of (
' ');
527 if (pos != std::string::npos)
528 os << tmp.substr (pos);
529 else if (! tmp.empty ())
537 if (elts >= max_elts)
549 if (elts >= max_elts)
564template <
typename MT>
571template <
typename MT>
577 std::ostringstream buf;
582template <
typename MT>
586 if (n < m_matrix.numel ())
592template <
typename MT>
597 if (n < m_matrix.numel ())
600 typedef typename MT::element_type ET;
606 void *here =
reinterpret_cast<void *
> (&m_matrix(n));
608 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.
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.
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
bool print_as_scalar() 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 subsref(const std::string &type, const std::list< octave_value_list > &idx)
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
float_display_format get_edit_display_format() const
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
octave_value_list simple_subsref(char type, octave_value_list &idx, int nargout)
void print(std::ostream &os, bool pr_as_read_syntax=false)
void short_disp(std::ostream &os) const
MatrixType matrix_type() const
void assign(const octave_value_list &idx, const MT &rhs)
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
virtual void short_disp(std::ostream &os) const
octave_idx_type length() const
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, std::size_t skip=1)
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
void error(const char *fmt,...)
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
const octave_base_value const Array< octave_idx_type > & ra_idx
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)