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>
103 typedef typename DMT::element_type el_type;
105 if (idx.
length () == 2 && ! resize_ok)
112 retval = matrix.checkelem (idx0(0), idx1(0));
119 && m <= matrix.rows () && n <= matrix.rows ())
135 template <
class DMT,
class MT>
138 const std::list<octave_value_list>& idx,
147 if (type.length () == 1)
154 && jdx(0).is_scalar_type () && jdx(1).is_scalar_type ())
156 typename DMT::element_type val;
160 && i0(0) < matrix.rows () && i1(0) < matrix.cols ()
161 && chk_valid_scalar (rhs, val))
163 matrix.dgelem (i0(0)) = val;
172 retval = numeric_assign (type, idx, rhs);
176 std::string nm = type_name ();
177 error (
"in indexed assignment of %s, last lhs index must be ()",
190 retval = tmp.
subsasgn (type, idx, rhs);
194 std::string nm = type_name ();
195 error (
"%s cannot be indexed with %c", nm.c_str (), type[0]);
207 template <
class DMT,
class MT>
215 rm.resize (dv(0), dv(1));
219 retval = to_dense ().
resize (dv, fill);
223 template <
class DMT,
class MT>
227 return to_dense ().is_true ();
233 {
return x.real (); }
239 template <
class DMT,
class MT>
244 typedef typename DMT::element_type el_type;
248 "complex matrix",
"real scalar");
253 type_name (),
"real scalar");
263 template <
class DMT,
class MT>
268 typedef typename DMT::element_type el_type;
272 "complex matrix",
"real scalar");
277 type_name (),
"real scalar");
287 template <
class DMT,
class MT>
295 if (rows () > 0 && columns () > 0)
298 type_name (),
"complex scalar");
300 retval = matrix (0, 0);
308 template <
class DMT,
class MT>
316 if (rows () > 0 && columns () > 0)
319 type_name (),
"complex scalar");
321 retval = matrix (0, 0);
329 template <
class DMT,
class MT>
333 return Matrix (diag_matrix_value ());
336 template <
class DMT,
class MT>
343 template <
class DMT,
class MT>
350 template <
class DMT,
class MT>
357 template <
class DMT,
class MT>
361 return NDArray (matrix_value ());
364 template <
class DMT,
class MT>
371 template <
class DMT,
class MT>
378 template <
class DMT,
class MT>
385 template <
class DMT,
class MT>
389 return to_dense ().bool_array_value (warn);
392 template <
class DMT,
class MT>
396 return to_dense ().char_array_value (warn);
399 template <
class DMT,
class MT>
406 template <
class DMT,
class MT>
413 template <
class DMT,
class MT>
417 return to_dense ().index_vector ();
420 template <
class DMT,
class MT>
428 template <
class DMT,
class MT>
432 os <<
"# rows: " << matrix.rows () <<
"\n"
433 <<
"# columns: " << matrix.columns () <<
"\n";
435 os << matrix.extract_diag ();
440 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>
509 bool pr_as_read_syntax)
const
511 print_raw (os, pr_as_read_syntax);
514 template <
class DMT,
class MT>
521 return to_dense ().write (os, block_size, output_type, skip, flt_fmt);
524 template <
class DMT,
class MT>
527 const std::string& prefix)
const
529 matrix.print_info (os, prefix);
532 template <
class DMT,
class MT>
536 if (! dense_cache.is_defined ())
537 dense_cache = MT (matrix);