41 DEFUN (__luinc__, args, nargout,
43 @deftypefn {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, '0')\n\
44 @deftypefnx {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{droptol})\n\
45 @deftypefnx {Built-in Function} {[@var{L}, @var{U}, @var{P}, @var{Q}] =} luinc (@var{A}, @var{opts})\n\
46 @cindex LU decomposition\n\
47 Produce the incomplete LU@tie{}factorization of the sparse matrix @var{A}.\n\
49 Two types of incomplete factorization are possible, and the type\n\
50 is determined by the second argument to @code{luinc}.\n\
52 Called with a second argument of @qcode{'0'}, the zero-level incomplete\n\
53 LU@tie{}factorization is produced. This creates a factorization of @var{A}\n\
54 where the position of the nonzero arguments correspond to the same\n\
55 positions as in the matrix @var{A}.\n\
57 Alternatively, the fill-in of the incomplete LU@tie{}factorization can\n\
58 be controlled through the variable @var{droptol} or the structure\n\
59 @var{opts}. The @sc{umfpack} multifrontal factorization code by Tim A.\n\
60 Davis is used for the incomplete LU@tie{}factorization, (availability\n\
61 @url{http://www.cise.ufl.edu/research/sparse/umfpack/})\n\
63 @var{droptol} determines the values below which the values in the\n\
64 LU@tie{} factorization are dropped and replaced by zero. It must be a\n\
65 positive scalar, and any values in the factorization whose absolute value\n\
66 are less than this value are dropped, expect if leaving them increase the\n\
67 sparsity of the matrix. Setting @var{droptol} to zero results in a complete\n\
68 LU@tie{}factorization which is the default.\n\
70 @var{opts} is a structure containing one or more of the fields\n\
74 The drop tolerance as above. If @var{opts} only contains @code{droptol}\n\
75 then this is equivalent to using the variable @var{droptol}.\n\
78 A logical variable flagging whether to use the modified incomplete\n\
79 LU@tie{} factorization. In the case that @code{milu} is true, the dropped\n\
80 values are subtracted from the diagonal of the matrix @var{U} of the\n\
81 factorization. The default is @code{false}.\n\
84 A logical variable that flags whether zero elements on the diagonal of\n\
85 @var{U} should be replaced with @var{droptol} to attempt to avoid singular\n\
86 factors. The default is @code{false}.\n\
89 Defines the pivot threshold in the interval [0,1]. Values outside that\n\
93 All other fields in @var{opts} are ignored. The outputs from @code{luinc}\n\
94 are the same as for @code{lu}.\n\
96 Given the string argument @qcode{\"vector\"}, @code{luinc} returns the\n\
97 values of @var{p} @var{q} as vector values.\n\
98 @seealso{sparse, lu, ilu, ichol}\n\
101 int nargin = args.length ();
106 else if (nargin < 2 || nargin > 3)
107 error (
"luinc: incorrect number of arguments");
110 bool zero_level =
false;
114 double droptol = -1.;
117 if (args(1).is_string ())
119 if (args(1).string_value () ==
"0")
122 error (
"luinc: unrecognized string argument");
124 else if (args(1).is_map ())
141 milu = (val == 0. ?
false :
true);
149 udiag = (val == 0. ?
false :
true);
157 if (thresh.
nelem () == 1)
160 thresh(1) = thresh(0);
162 else if (thresh.
nelem () != 2)
164 error (
"luinc: expecting 2-element vector for thresh");
171 error (
"luinc: OPTS must be a scalar structure");
176 droptol = args(1).double_value ();
180 std::string tmp = args(2).string_value ();
184 if (tmp.compare (
"vector") == 0)
187 error (
"luinc: unrecognized string argument");
193 error (
"luinc: zero-level factorization not implemented");
197 if (args(0).type_name () ==
"sparse matrix")
215 SparseLU fact (sm, Qinit, thresh,
false,
true, droptol,
235 SparseLU fact (sm, Qinit, thresh,
false,
true, droptol,
241 retval(2) = fact.
Pr_vec ();
243 retval(2) = fact.
Pr_mat ();
257 SparseLU fact (sm, Qinit, thresh,
false,
false, droptol,
264 retval(3) = fact.
Pc_vec ();
265 retval(2) = fact.
Pr_vec ();
269 retval(3) = fact.
Pc_mat ();
270 retval(2) = fact.
Pr_mat ();
284 else if (args(0).type_name () ==
"sparse complex matrix")
287 args(0).sparse_complex_matrix_value ();
304 droptol, milu, udiag);
325 droptol, milu, udiag);
330 retval(2) = fact.
Pr_vec ();
332 retval(2) = fact.
Pr_mat ();
347 droptol, milu, udiag);
353 retval(3) = fact.
Pc_vec ();
354 retval(2) = fact.
Pr_vec ();
358 retval(3) = fact.
Pc_mat ();
359 retval(2) = fact.
Pr_mat ();
374 error (
"luinc: matrix A must be sparse");
octave_idx_type cols(void) const
octave_idx_type rows(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
SparseMatrix transpose(void) const
const octave_idx_type * row_perm(void) const
OCTINTERP_API void print_usage(void)
bool is_defined(void) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
PermMatrix Pr_mat(void) const
octave_idx_type nelem(void) const
Number of elements in the array.
ColumnVector Pr_vec(void) const
Matrix matrix_value(bool frc_str_conv=false) const
PermMatrix Pc_mat(void) const
ColumnVector Pc_vec(void) const
octave_value getfield(const std::string &key) const
double double_value(bool frc_str_conv=false) const
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))