26 #if defined (HAVE_CONFIG_H)
42 template <
typename MT>
44 get_lu_l (
const math::lu<MT>& fact)
53 template <
typename MT>
55 get_lu_u (
const math::lu<MT>& fact)
58 if (U.issquare () && fact.regular ())
145 int nargin = args.length ();
146 bool issparse = (nargin > 0 && args(0).issparse ());
148 if (nargin < 1 || (issparse && nargin > 3) || (! issparse && nargin > 2))
157 if (args(
n).is_string ())
159 std::string tmp = args(
n++).string_value ();
164 error (
"lu: unrecognized string argument");
169 error (
"lu: can not define pivoting threshold THRESH for full matrices");
171 Matrix tmp = args(
n++).matrix_value ();
172 if (tmp.
numel () == 1)
178 else if (tmp.
numel () == 2)
181 error (
"lu: THRESH must be a 1- or 2-element vector");
186 bool scale = (nargout == 5);
205 "lu: function may fail when called with less than 4 output arguments and a sparse input");
210 math::sparse_lu<SparseMatrix> fact (
m, Qinit, thresh,
false,
214 retval(0) = fact.Y ();
217 retval.
resize (nargout == 3 ? 3 : 2);
219 =
octave_value (fact.U () * fact.Pc_mat ().transpose (),
221 nc, fact.col_perm ()));
230 nr, fact.row_perm ()));
235 retval(2) = fact.Pr_vec();
244 math::sparse_lu<SparseMatrix> fact (
m, thresh,
scale);
253 retval(2) = fact.Pr_vec ();
254 retval(3) = fact.Pc_vec ();
258 retval(2) = fact.Pr_mat ();
259 retval(3) = fact.Pc_mat ();
263 retval(4) = fact.R ();
273 "lu: function may fail when called with less than 4 output arguments and a sparse input");
278 math::sparse_lu<SparseComplexMatrix> fact (
m, Qinit, thresh,
282 retval(0) = fact.Y ();
285 retval.
resize (nargout == 3 ? 3 : 2);
287 =
octave_value (fact.U () * fact.Pc_mat ().transpose (),
289 nc, fact.col_perm ()));
297 nr, fact.row_perm ()));
302 retval(2) = fact.Pr_vec();
311 math::sparse_lu<SparseComplexMatrix> fact (
m, thresh,
scale);
320 retval(2) = fact.Pr_vec ();
321 retval(3) = fact.Pc_vec ();
325 retval(2) = fact.Pr_mat ();
326 retval(3) = fact.Pc_mat ();
330 retval(4) = fact.R ();
348 math::lu<FloatMatrix> fact (
m);
354 retval =
ovl (fact.Y ());
361 retval =
ovl (L, get_lu_u (fact));
369 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
372 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
382 math::lu<Matrix> fact (
m);
388 retval =
ovl (fact.Y ());
395 retval =
ovl (L, get_lu_u (fact));
403 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
406 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
419 math::lu<FloatComplexMatrix> fact (
m);
425 retval =
ovl (fact.Y ());
432 retval =
ovl (L, get_lu_u (fact));
440 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
443 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
453 math::lu<ComplexMatrix> fact (
m);
459 retval =
ovl (fact.Y ());
466 retval =
ovl (L, get_lu_u (fact));
474 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
477 retval =
ovl (get_lu_l (fact), get_lu_u (fact),
585 DEFUN (luupdate, args, ,
630 int nargin = args.length ();
632 if (nargin != 4 && nargin != 5)
635 bool pivoted = (nargin == 5);
646 error (
"luupdate: L, U, X, and Y must be numeric");
648 if (! check_lu_dims (argl, argu, argp))
649 error (
"luupdate: dimension mismatch");
667 math::lu<FloatMatrix> fact (L, U, P);
669 fact.update_piv (
x, y);
674 return ovl (get_lu_l (fact), get_lu_u (fact), fact.P ());
676 return ovl (get_lu_l (fact), get_lu_u (fact));
685 math::lu<Matrix> fact (L, U, P);
687 fact.update_piv (
x, y);
692 return ovl (get_lu_l (fact), get_lu_u (fact), fact.P ());
694 return ovl (get_lu_l (fact), get_lu_u (fact));
708 math::lu<FloatComplexMatrix> fact (L, U, P);
710 fact.update_piv (
x, y);
715 return ovl (get_lu_l (fact), get_lu_u (fact), fact.P ());
717 return ovl (get_lu_l (fact), get_lu_u (fact));
726 math::lu<ComplexMatrix> fact (L, U, P);
728 fact.update_piv (
x, y);
733 return ovl (get_lu_l (fact), get_lu_u (fact), fact.P ());
735 return ovl (get_lu_l (fact), get_lu_u (fact));
850 OCTAVE_END_NAMESPACE(
octave)
charNDArray min(char d, const charNDArray &m)
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
static PermMatrix eye(octave_idx_type n)
PermMatrix transpose() const
void resize(octave_idx_type n, const octave_value &rfv=octave_value())
bool is_undefined() const
SparseMatrix sparse_matrix_value(bool frc_str_conv=false) const
octave_idx_type rows() const
ComplexMatrix complex_matrix_value(bool frc_str_conv=false) const
bool is_perm_matrix() const
bool is_single_type() const
FloatMatrix float_matrix_value(bool frc_str_conv=false) const
octave_idx_type columns() const
Matrix matrix_value(bool frc_str_conv=false) const
FloatComplexMatrix float_complex_matrix_value(bool frc_str_conv=false) const
PermMatrix perm_matrix_value() const
SparseComplexMatrix sparse_complex_matrix_value(bool frc_str_conv=false) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void warning_with_id(const char *id, const char *fmt,...)
void() error(const char *fmt,...)
void err_wrong_type_arg(const char *name, const char *s)
void scale(Matrix &m, double x, double y, double z)
F77_RET_T const F77_DBLE * x
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.