49 template <
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]);
77 template <
typename DMT,
typename MT>
82 if (matrix.rows () == 1 || matrix.cols () == 1)
90 retval = matrix.build_diag_matrix ();
97 retval = matrix.extract_diag (k);
101 template <
typename DMT,
typename MT>
108 if (idx.
length () == 2 && ! resize_ok)
126 &&
m <= matrix.rows () &&
n <= matrix.rows ())
133 retval = to_dense ().do_index_op (idx, resize_ok);
144 retval = to_dense ().do_index_op (idx, resize_ok);
149 template <
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;
185 dim_vector dv (matrix.rows (), matrix.cols ());
191 && chk_valid_scalar (rhs, val))
193 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) < matrix.rows () && i1(0) < matrix.cols ()
219 && chk_valid_scalar (rhs, val))
221 matrix.dgelem (i0(0)) = val;
236 if (!
retval.is_defined ())
246 std::string nm = type_name ();
247 error (
"%s cannot be indexed with %c", nm.c_str (),
type[0]);
263 template <
typename DMT,
typename MT>
268 if (dv.
ndims () == 2)
271 rm.resize (dv(0), dv(1));
280 template <
typename DMT,
typename MT>
284 if (dims ().
numel () > 1)
292 return to_dense ().is_true ();
298 {
return x.real (); }
304 template <
typename DMT,
typename MT>
308 typedef typename DMT::element_type el_type;
312 "complex matrix",
"real scalar");
318 type_name (),
"real scalar");
323 template <
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");
342 template <
typename DMT,
typename MT>
346 if (rows () == 0 || columns () == 0)
350 type_name (),
"complex scalar");
355 template <
typename DMT,
typename MT>
363 if (rows () == 0 || columns () == 0)
367 type_name (),
"complex scalar");
374 template <
typename DMT,
typename MT>
378 return Matrix (diag_matrix_value ());
381 template <
typename DMT,
typename MT>
388 template <
typename DMT,
typename MT>
395 template <
typename DMT,
typename MT>
402 template <
typename DMT,
typename MT>
406 return NDArray (matrix_value ());
409 template <
typename DMT,
typename MT>
416 template <
typename DMT,
typename MT>
423 template <
typename DMT,
typename MT>
430 template <
typename DMT,
typename MT>
434 return to_dense ().bool_array_value (warn);
437 template <
typename DMT,
typename MT>
441 return to_dense ().char_array_value (warn);
444 template <
typename DMT,
typename MT>
451 template <
typename DMT,
typename MT>
458 template <
typename DMT,
typename MT>
462 return to_dense ().index_vector (require_integers);
465 template <
typename DMT,
typename MT>
473 template <
typename DMT,
typename MT>
481 template <
typename DMT,
typename MT>
487 std::ostringstream buf;
492 template <
typename DMT,
typename MT>
496 os <<
"# rows: " << matrix.rows () <<
"\n"
497 <<
"# columns: " << matrix.columns () <<
"\n";
499 os << matrix.extract_diag ();
504 template <
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 matrix.resize (
r, c);
535 template <
typename DMT,
typename MT>
538 bool pr_as_read_syntax)
const
541 current_print_indent_level ());
544 template <
typename DMT,
typename MT>
548 return to_dense ().as_mxArray ();
551 template <
typename DMT,
typename MT>
560 template <
typename DMT,
typename MT>
564 print_raw (os, pr_as_read_syntax);
567 template <
typename DMT,
typename MT>
574 return to_dense ().write (os, block_size, output_type, skip, flt_fmt);
577 template <
typename DMT,
typename MT>
580 const std::string& prefix)
const
582 matrix.print_info (os, prefix);
588 template <
typename DMT,
typename MT>
592 if (matrix.isempty ())
594 else if (matrix.ndims () == 2)
611 std::ostringstream buf;
613 std::string tmp = buf.str ();
614 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)
640 template <
typename DMT,
typename MT>
644 if (
n < matrix.numel ())
657 template <
typename DMT,
typename MT>
661 if (! dense_cache.is_defined ())
662 dense_cache = MT (matrix);
Array< idx_vector > ind2sub(const dim_vector &dv, const idx_vector &idx)
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.
Array< T > diag(octave_idx_type k=0) const
Get the kth super or subdiagonal.
Template for N-dimensional array classes with like-type math operators.
Template for two dimensional diagonal array with math operators.
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
octave_idx_type length(octave_idx_type n=0) const
bool is_scalar(void) 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)
bool load_ascii(std::istream &is)
virtual octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
void print_info(std::ostream &os, const std::string &prefix) const
mxArray * as_mxArray(void) const
boolNDArray bool_array_value(bool warn=false) const
Matrix matrix_value(bool=false) const
bool save_ascii(std::ostream &os)
idx_vector index_vector(bool=false) const
Complex complex_value(bool=false) const
NDArray array_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
ComplexMatrix complex_matrix_value(bool=false) const
virtual octave_value diag(octave_idx_type k=0) const
FloatComplex float_complex_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
FloatNDArray float_array_value(bool=false) const
octave_value resize(const dim_vector &dv, bool fill=false) const
octave_value fast_elem_extract(octave_idx_type n) const
float_display_format get_edit_display_format(void) const
octave_value to_dense(void) const
float float_value(bool=false) const
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
charNDArray char_array_value(bool=false) const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
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
ComplexNDArray complex_array_value(bool=false) const
std::string edit_display(const float_display_format &fmt, octave_idx_type i, octave_idx_type j) const
bool print_as_scalar(void) const
void short_disp(std::ostream &os) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
double double_value(bool=false) const
FloatMatrix float_matrix_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
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
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_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)
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()) ? '\'' :'"'))
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)