26 #if defined (HAVE_CONFIG_H)
44 DEFUN (matrix_type, args, ,
127 int nargin = args.length ();
129 if (nargin == 0 || nargin > 4)
132 bool autocomp =
true;
133 if (nargin == 2 && args(1).is_string ()
134 && args(1).string_value () ==
"nocompute")
142 if (args(0).is_scalar_type ())
149 else if (args(0).issparse ())
155 if (args(0).iscomplex ())
162 = args(0).sparse_complex_matrix_value ();
165 args(0).matrix_type (mattyp);
177 args(0).matrix_type (mattyp);
181 int typ = mattyp.
type ();
202 retval =
octave_value (
"Tridiagonal Positive Definite");
207 if (args(0).rows () == args(0).columns ())
220 std::string str_typ = args(1).xstring_value (
"matrix_type: TYPE must be a string");
230 str_typ.begin (), tolower);
232 if (str_typ ==
"diagonal")
234 if (str_typ ==
"permuted diagonal")
236 else if (str_typ ==
"upper")
238 else if (str_typ ==
"lower")
240 else if (str_typ ==
"banded"
241 || str_typ ==
"banded positive definite")
244 error (
"matrix_type: banded matrix type requires 4 arguments");
246 nl = args(2).xnint_value (
"matrix_type: band size NL, NU must be integers");
247 nu = args(3).xnint_value (
"matrix_type: band size NL, NU must be integers");
249 if (nl == 1 && nu == 1)
254 if (str_typ ==
"banded positive definite")
257 else if (str_typ ==
"positive definite")
262 else if (str_typ ==
"singular")
264 else if (str_typ ==
"full")
266 else if (str_typ ==
"unknown")
269 error (
"matrix_type: Unknown matrix type %s", str_typ.c_str ());
272 && (str_typ ==
"upper" || str_typ ==
"lower"))
274 const ColumnVector perm = args(2).xvector_value (
"matrix_type: Invalid permutation vector PERM");
280 error (
"matrix_type: Invalid permutation vector PERM");
290 && str_typ !=
"banded positive definite"
291 && str_typ !=
"banded")
292 error (
"matrix_type: Invalid number of arguments");
295 if (args(0).iscomplex ())
296 retval =
octave_value (args(0).sparse_complex_matrix_value (),
309 if (args(0).iscomplex ())
315 if (args(0).is_single_type ())
318 m = args(0).float_complex_matrix_value ();
321 args(0).matrix_type (mattyp);
328 args(0).matrix_type (mattyp);
338 if (args(0).is_single_type ())
343 args(0).matrix_type (mattyp);
347 Matrix m = args(0).matrix_value ();
350 args(0).matrix_type (mattyp);
355 int typ = mattyp.
type ();
369 if (args(0).rows () == args(0).columns ())
382 std::string str_typ = args(1).xstring_value (
"matrix_type: TYPE must be a string");
389 str_typ.begin (), tolower);
391 if (str_typ ==
"upper")
393 else if (str_typ ==
"lower")
395 else if (str_typ ==
"positive definite")
400 else if (str_typ ==
"singular")
402 else if (str_typ ==
"full")
404 else if (str_typ ==
"unknown")
407 error (
"matrix_type: Unknown matrix type %s", str_typ.c_str ());
409 if (nargin == 3 && (str_typ ==
"upper" || str_typ ==
"lower"))
411 const ColumnVector perm = args(2).xvector_value (
"matrix_type: Invalid permutation vector PERM");
417 error (
"matrix_type: Invalid permutation vector PERM");
426 else if (nargin != 2)
427 error (
"matrix_type: Invalid number of arguments");
430 if (args(0).is_single_type ())
432 if (args(0).iscomplex ())
433 retval =
octave_value (args(0).float_complex_matrix_value (),
441 if (args(0).iscomplex ())
445 retval =
octave_value (args(0).matrix_value (), mattyp);
OCTARRAY_OVERRIDABLE_FUNC_API 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)
OCTAVE_API 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)
OCTAVE_API int type(bool quiet=true)
void mark_as_diagonal(void)
OCTAVE_API void mark_as_symmetric(void)
Vector representing the dimensions (size) of an Array.
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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()) ? '\'' :'"'))