26 #if defined (HAVE_CONFIG_H)
42 DEFUN (matrix_type, args, ,
125 int nargin = args.length ();
127 if (nargin == 0 || nargin > 4)
130 bool autocomp =
true;
131 if (nargin == 2 && args(1).is_string ()
132 && args(1).string_value () ==
"nocompute")
140 if (args(0).is_scalar_type ())
147 else if (args(0).issparse ())
153 if (args(0).iscomplex ())
160 = args(0).sparse_complex_matrix_value ();
163 args(0).matrix_type (mattyp);
175 args(0).matrix_type (mattyp);
179 int typ = mattyp.
type ();
205 if (args(0).rows () == args(0).columns ())
218 std::string str_typ = args(1).xstring_value (
"matrix_type: TYPE must be a string");
228 str_typ.begin (), tolower);
230 if (str_typ ==
"diagonal")
232 if (str_typ ==
"permuted diagonal")
234 else if (str_typ ==
"upper")
236 else if (str_typ ==
"lower")
238 else if (str_typ ==
"banded"
239 || str_typ ==
"banded positive definite")
242 error (
"matrix_type: banded matrix type requires 4 arguments");
244 nl = args(2).xnint_value (
"matrix_type: band size NL, NU must be integers");
245 nu = args(3).xnint_value (
"matrix_type: band size NL, NU must be integers");
247 if (nl == 1 && nu == 1)
252 if (str_typ ==
"banded positive definite")
255 else if (str_typ ==
"positive definite")
260 else if (str_typ ==
"singular")
262 else if (str_typ ==
"full")
264 else if (str_typ ==
"unknown")
267 error (
"matrix_type: Unknown matrix type %s", str_typ.c_str ());
270 && (str_typ ==
"upper" || str_typ ==
"lower"))
272 const ColumnVector perm = args(2).xvector_value (
"matrix_type: Invalid permutation vector PERM");
278 error (
"matrix_type: Invalid permutation vector PERM");
288 && str_typ !=
"banded positive definite"
289 && str_typ !=
"banded")
290 error (
"matrix_type: Invalid number of arguments");
293 if (args(0).iscomplex ())
307 if (args(0).iscomplex ())
313 if (args(0).is_single_type ())
316 m = args(0).float_complex_matrix_value ();
319 args(0).matrix_type (mattyp);
326 args(0).matrix_type (mattyp);
336 if (args(0).is_single_type ())
341 args(0).matrix_type (mattyp);
345 Matrix m = args(0).matrix_value ();
348 args(0).matrix_type (mattyp);
353 int typ = mattyp.
type ();
367 if (args(0).rows () == args(0).columns ())
380 std::string str_typ = args(1).xstring_value (
"matrix_type: TYPE must be a string");
387 str_typ.begin (), tolower);
389 if (str_typ ==
"upper")
391 else if (str_typ ==
"lower")
393 else if (str_typ ==
"positive definite")
398 else if (str_typ ==
"singular")
400 else if (str_typ ==
"full")
402 else if (str_typ ==
"unknown")
405 error (
"matrix_type: Unknown matrix type %s", str_typ.c_str ());
407 if (nargin == 3 && (str_typ ==
"upper" || str_typ ==
"lower"))
409 const ColumnVector perm = args(2).xvector_value (
"matrix_type: Invalid permutation vector PERM");
415 error (
"matrix_type: Invalid permutation vector PERM");
424 else if (nargin != 2)
425 error (
"matrix_type: Invalid number of arguments");
428 if (args(0).is_single_type ())
430 if (args(0).iscomplex ())
439 if (args(0).iscomplex ())
octave_idx_type numel(void) const
Number of elements in the array.
void invalidate_type(void)
void mark_as_permuted_diagonal(void)
void mark_as_rectangular(void)
void mark_as_permuted(const octave_idx_type np, const octave_idx_type *p)
bool is_unknown(void) const
void mark_as_upper_triangular(void)
void mark_as_banded(const octave_idx_type ku, const octave_idx_type kl)
void mark_as_lower_triangular(void)
void mark_as_tridiagonal(void)
int type(bool quiet=true)
void mark_as_diagonal(void)
void mark_as_symmetric(void)
Vector representing the dimensions (size) of an Array.
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
ColumnVector transform(const Matrix &m, double x, double y, double z)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
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