43 template <
class DMT,
class MT>
46 const std::list<octave_value_list>& idx)
53 retval = do_index_op (idx.front ());
59 std::string nm = type_name ();
60 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
72 template <
class DMT,
class MT>
77 if (matrix.rows () == 1 || matrix.cols () == 1)
85 retval = matrix.build_diag_matrix ();
92 retval = matrix.extract_diag (k);
97 template <
class DMT,
class MT>
104 if (idx.
length () == 2 && ! resize_ok)
111 retval = matrix.checkelem (idx0(0), idx1(0));
118 && m <= matrix.rows () && n <= matrix.rows ())
134 template <
class DMT,
class MT>
137 const std::list<octave_value_list>& idx,
146 if (type.length () == 1)
153 && jdx(0).is_scalar_type () && jdx(1).is_scalar_type ())
155 typename DMT::element_type val;
159 && i0(0) < matrix.rows () && i1(0) < matrix.cols ()
160 && chk_valid_scalar (rhs, val))
162 matrix.dgelem (i0(0)) = val;
171 retval = numeric_assign (type, idx, rhs);
175 std::string nm = type_name ();
176 error (
"in indexed assignment of %s, last lhs index must be ()",
189 retval = tmp.
subsasgn (type, idx, rhs);
193 std::string nm = type_name ();
194 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
206 template <
class DMT,
class MT>
214 rm.resize (dv(0), dv(1));
218 retval = to_dense ().
resize (dv, fill);
222 template <
class DMT,
class MT>
226 return to_dense ().is_true ();
232 {
return x.real (); }
238 template <
class DMT,
class MT>
243 typedef typename DMT::element_type el_type;
247 "complex matrix",
"real scalar");
252 type_name (),
"real scalar");
262 template <
class DMT,
class MT>
267 typedef typename DMT::element_type el_type;
271 "complex matrix",
"real scalar");
276 type_name (),
"real scalar");
286 template <
class DMT,
class MT>
294 if (rows () > 0 && columns () > 0)
297 type_name (),
"complex scalar");
299 retval = matrix (0, 0);
307 template <
class DMT,
class MT>
315 if (rows () > 0 && columns () > 0)
318 type_name (),
"complex scalar");
320 retval = matrix (0, 0);
328 template <
class DMT,
class MT>
332 return Matrix (diag_matrix_value ());
335 template <
class DMT,
class MT>
342 template <
class DMT,
class MT>
349 template <
class DMT,
class MT>
356 template <
class DMT,
class MT>
360 return NDArray (matrix_value ());
363 template <
class DMT,
class MT>
370 template <
class DMT,
class MT>
377 template <
class DMT,
class MT>
384 template <
class DMT,
class MT>
388 return to_dense ().bool_array_value (warn);
391 template <
class DMT,
class MT>
395 return to_dense ().char_array_value (warn);
398 template <
class DMT,
class MT>
405 template <
class DMT,
class MT>
412 template <
class DMT,
class MT>
416 return to_dense ().index_vector (require_integers);
419 template <
class DMT,
class MT>
427 template <
class DMT,
class MT>
431 os <<
"# rows: " << matrix.rows () <<
"\n"
432 <<
"# columns: " << matrix.columns () <<
"\n";
434 os << matrix.extract_diag ();
439 template <
class DMT,
class MT>
456 error (
"load: failed to load diagonal matrix constant");
464 typedef typename DMT::element_type el_type;
466 matrix.resize (r, c);
474 error (
"load: failed to extract number of rows and columns");
481 template <
class DMT,
class MT>
484 bool pr_as_read_syntax)
const
487 current_print_indent_level ());
490 template <
class DMT,
class MT>
494 return to_dense ().as_mxArray ();
497 template <
class DMT,
class MT>
506 template <
class DMT,
class MT>
510 print_raw (os, pr_as_read_syntax);
513 template <
class DMT,
class MT>
520 return to_dense ().write (os, block_size, output_type, skip, flt_fmt);
523 template <
class DMT,
class MT>
526 const std::string& prefix)
const
528 matrix.print_info (os, prefix);
531 template <
class DMT,
class MT>
535 if (n < matrix.numel ())
548 template <
class DMT,
class MT>
552 if (! dense_cache.is_defined ())
553 dense_cache = MT (matrix);
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
void print(std::ostream &os, bool pr_as_read_syntax=false)
octave_value to_dense(void) const
octave_idx_type length(octave_idx_type n=0) const
float float_value(bool=false) const
NDArray array_value(bool=false) const
double double_value(bool=false) const
mxArray * as_mxArray(void) const
idx_vector index_vector(bool=false) const
bool load_ascii(std::istream &is)
octave_value resize(const dim_vector &dv, bool fill=false) const
octave_idx_type length(void) const
bool is_defined(void) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
void error(const char *fmt,...)
charNDArray char_array_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
int write(octave_stream &os, int block_size, oct_data_conv::data_type output_type, int skip, oct_mach_info::float_format flt_fmt) const
octave_value resize(const dim_vector &dv, bool fill=false) const
double lo_ieee_nan_value(void)
octave_value convert_to_str_internal(bool pad, bool force, char type) const
bool all_ones(void) const
FloatComplex float_complex_value(bool=false) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
bool print_as_scalar(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
#define panic_impossible()
ComplexMatrix complex_matrix_value(bool=false) const
bool any_zero(void) const
Complex complex_value(bool=false) const
float lo_ieee_float_nan_value(void)
void print_info(std::ostream &os, const std::string &prefix) const
bool is_colon_equiv(octave_idx_type n) const
FloatComplexNDArray float_complex_array_value(bool=false) const
NDArray array_value(bool frc_str_conv=false) const
FloatMatrix float_matrix_value(bool=false) const
NDArray diag(octave_idx_type k=0) const
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
void gripe_invalid_conversion(const std::string &from, const std::string &to)
Matrix matrix_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
FloatNDArray float_array_value(bool=false) const
void octave_print_internal(std::ostream &, char, bool)
bool is_scalar(void) const
octave_value fast_elem_extract(octave_idx_type n) const
boolNDArray bool_array_value(bool warn=false) const
bool save_ascii(std::ostream &os)
std::complex< float > FloatComplex
FloatComplexMatrix float_complex_matrix_value(bool=false) const
std::complex< double > Complex
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
octave_value diag(octave_idx_type k=0) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
static octave_value empty_conv(const std::string &type, const octave_value &rhs=octave_value())
F77_RET_T const double * x
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)