49template <
typename DMT,
typename MT>
52 const std::list<octave_value_list>& idx)
59 retval = do_index_op (idx.front ());
65 std::string nm = type_name ();
66 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
77template <
typename DMT,
typename MT>
82 if (m_matrix.rows () == 1 || m_matrix.cols () == 1)
90 retval = m_matrix.build_diag_matrix ();
97 retval = m_matrix.extract_diag (k);
101template <
typename DMT,
typename MT>
119 retval = m_matrix.checkelem (idx0(0), idx1(0));
126 && m <= m_matrix.rows () && n <= m_matrix.rows ())
133 retval = to_dense ().
index_op (idx, resize_ok);
144 retval = to_dense ().
index_op (idx, resize_ok);
149template <
typename DMT,
typename MT>
152 const std::list<octave_value_list>& idx,
161 if (type.length () != 1)
163 std::string nm = type_name ();
164 error (
"in indexed assignment of %s, last lhs index must be ()",
177 if (jdx.
length () == 1 && jdx(0).is_scalar_type ())
179 typename DMT::element_type val;
191 && chk_valid_scalar (rhs, val))
193 m_matrix.dgelem (i0(0)) = val;
207 else if (jdx.
length () == 2
208 && jdx(0).is_scalar_type () && jdx(1).is_scalar_type ())
210 typename DMT::element_type val;
218 && i0(0) < m_matrix.rows () && i1(0) < m_matrix.cols ()
219 && chk_valid_scalar (rhs, val))
221 m_matrix.dgelem (i0(0)) = val;
237 retval = numeric_assign (type, idx, rhs);
246 std::string nm = type_name ();
247 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
252 retval = tmp.
subsasgn (type, idx, rhs);
263template <
typename DMT,
typename MT>
268 if (dv.
ndims () == 2)
271 rm.resize (dv(0), dv(1));
275 retval = to_dense ().
resize (dv, fill);
280template <
typename DMT,
typename MT>
284 if (dims ().
numel () > 1)
292 return to_dense ().is_true ();
304template <
typename DMT,
typename MT>
308 typedef typename DMT::element_type el_type;
312 "complex matrix",
"real scalar");
318 type_name (),
"real scalar");
323template <
typename DMT,
typename MT>
327 typedef typename DMT::element_type el_type;
331 "complex matrix",
"real scalar");
333 if (! (
numel () > 0))
337 type_name (),
"real scalar");
342template <
typename DMT,
typename MT>
346 if (rows () == 0 || columns () == 0)
350 type_name (),
"complex scalar");
352 return m_matrix(0, 0);
355template <
typename DMT,
typename MT>
363 if (rows () == 0 || columns () == 0)
367 type_name (),
"complex scalar");
369 retval = m_matrix (0, 0);
374template <
typename DMT,
typename MT>
378 return Matrix (diag_matrix_value ());
381template <
typename DMT,
typename MT>
388template <
typename DMT,
typename MT>
395template <
typename DMT,
typename MT>
402template <
typename DMT,
typename MT>
406 return NDArray (matrix_value ());
409template <
typename DMT,
typename MT>
416template <
typename DMT,
typename MT>
423template <
typename DMT,
typename MT>
430template <
typename DMT,
typename MT>
434 return to_dense ().bool_array_value (warn);
437template <
typename DMT,
typename MT>
441 return to_dense ().char_array_value (warn);
444template <
typename DMT,
typename MT>
451template <
typename DMT,
typename MT>
458template <
typename DMT,
typename MT>
462 return to_dense ().index_vector (require_integers);
465template <
typename DMT,
typename MT>
473template <
typename DMT,
typename MT>
481template <
typename DMT,
typename MT>
487 std::ostringstream buf;
492template <
typename DMT,
typename MT>
496 os <<
"# rows: " << m_matrix.rows () <<
"\n"
497 <<
"# columns: " << m_matrix.columns () <<
"\n";
499 os << m_matrix.extract_diag ();
504template <
typename DMT,
typename MT>
513 error (
"load: failed to extract number of rows and columns");
520 error (
"load: failed to load diagonal matrix constant");
525 typedef typename DMT::element_type el_type;
527 m_matrix.resize (r, c);
535template <
typename DMT,
typename MT>
538 bool pr_as_read_syntax)
const
541 current_print_indent_level ());
544template <
typename DMT,
typename MT>
548 return to_dense ().as_mxArray (interleaved);
551template <
typename DMT,
typename MT>
560template <
typename DMT,
typename MT>
564 print_raw (os, pr_as_read_syntax);
567template <
typename DMT,
typename MT>
574 return to_dense ().write (os, block_size, output_type, skip, flt_fmt);
577template <
typename DMT,
typename MT>
580 const std::string& prefix)
const
582 m_matrix.print_info (os, prefix);
588template <
typename DMT,
typename MT>
592 if (m_matrix.isempty ())
594 else if (m_matrix.ndims () == 2)
611 std::ostringstream buf;
613 std::string tmp = buf.str ();
614 std::size_t pos = tmp.find_first_not_of (
' ');
615 if (pos != std::string::npos)
616 os << tmp.substr (pos);
617 else if (! tmp.empty ())
620 if (++elts >= max_elts)
627 if (i < nr - 1 && elts < max_elts)
640template <
typename DMT,
typename MT>
644 if (n < m_matrix.numel ())
657template <
typename DMT,
typename MT>
661 if (! m_dense_cache.is_defined ())
662 m_dense_cache = MT (m_matrix);
664 return m_dense_cache;
Array< octave::idx_vector > ind2sub(const dim_vector &dv, const octave::idx_vector &idx)
N Dimensional Array with copy-on-write semantics.
Template for N-dimensional array classes with like-type math operators.
Template for two dimensional diagonal array with math operators.
OCTAVE_API NDArray diag(octave_idx_type k=0) const
Vector representing the dimensions (size) of an Array.
bool all_ones(void) const
octave_idx_type ndims(void) const
Number of dimensions.
bool any_zero(void) const
bool is_scalar(void) const
octave_idx_type length(octave_idx_type n=0) const
bool is_colon_equiv(octave_idx_type n) const
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
OCTINTERP_API bool is_true(void) const
OCTINTERP_API bool load_ascii(std::istream &is)
OCTINTERP_API void print_info(std::ostream &os, const std::string &prefix) const
OCTINTERP_API boolNDArray bool_array_value(bool warn=false) const
OCTINTERP_API Matrix matrix_value(bool=false) const
OCTINTERP_API bool save_ascii(std::ostream &os)
OCTINTERP_API Complex complex_value(bool=false) const
OCTINTERP_API NDArray array_value(bool=false) const
OCTINTERP_API FloatComplexNDArray float_complex_array_value(bool=false) const
OCTINTERP_API ComplexMatrix complex_matrix_value(bool=false) const
OCTINTERP_API FloatComplex float_complex_value(bool=false) const
OCTINTERP_API octave_value diag(octave_idx_type k=0) const
OCTINTERP_API FloatComplexMatrix float_complex_matrix_value(bool=false) const
OCTINTERP_API FloatNDArray float_array_value(bool=false) const
OCTINTERP_API octave_value resize(const dim_vector &dv, bool fill=false) const
OCTINTERP_API octave::idx_vector index_vector(bool=false) const
OCTINTERP_API octave_value fast_elem_extract(octave_idx_type n) const
OCTINTERP_API float_display_format get_edit_display_format(void) const
OCTINTERP_API octave_value to_dense(void) const
OCTINTERP_API float float_value(bool=false) const
OCTINTERP_API octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
OCTINTERP_API octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
OCTINTERP_API octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
OCTINTERP_API charNDArray char_array_value(bool=false) const
OCTINTERP_API SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
OCTINTERP_API void print(std::ostream &os, bool pr_as_read_syntax=false)
OCTINTERP_API int write(octave::stream &os, int block_size, oct_data_conv::data_type output_type, int skip, octave::mach_info::float_format flt_fmt) const
OCTINTERP_API ComplexNDArray complex_array_value(bool=false) const
OCTINTERP_API std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
OCTINTERP_API bool print_as_scalar(void) const
OCTINTERP_API void short_disp(std::ostream &os) const
OCTINTERP_API octave_value convert_to_str_internal(bool pad, bool force, char type) const
OCTINTERP_API mxArray * as_mxArray(bool interleaved) const
OCTINTERP_API double double_value(bool=false) const
OCTINTERP_API FloatMatrix float_matrix_value(bool=false) const
OCTINTERP_API void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
OCTINTERP_API SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type length(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value index_op(const octave_value_list &idx, bool resize_ok=false)
static OCTINTERP_API octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
bool is_defined(void) const
OCTINTERP_API octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, std::size_t skip=1)
NDArray array_value(bool frc_str_conv=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
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_array_as_logical(const dim_vector &dv)
void err_invalid_conversion(const std::string &from, const std::string &to)
void warn_implicit_conversion(const char *id, const char *from, const char *to)
float lo_ieee_float_nan_value(void)
F77_RET_T const F77_DBLE * x
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
class OCTAVE_API ComplexMatrix
class OCTAVE_API SparseMatrix
class OCTAVE_API FloatComplexMatrix
class OCTAVE_API FloatMatrix
class OCTAVE_API ComplexNDArray
class OCTAVE_API SparseComplexMatrix
class OCTAVE_API FloatComplexNDArray
class OCTAVE_API FloatNDArray
std::complex< double > Complex
std::complex< float > FloatComplex
T::size_type numel(const T &str)
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)