26 #if defined (HAVE_CONFIG_H)
75 double *Rs,
void *Numeric);
81 void *Symbolic,
void **Numeric,
82 const double *Control,
double *Info);
90 const double *Control,
double *Info);
100 template <
typename T>
108 template <
typename T>
112 template <
typename T>
115 const double *Control);
117 template <
typename T>
121 template <
typename T>
125 #if defined (HAVE_UMFPACK)
159 &ignore1, &ignore2, &ignore3, Numeric);
184 const double *Ax,
void *Symbolic,
void **Numeric,
185 const double *Control,
double *Info)
189 Ax, Symbolic, Numeric, Control, Info);
198 const double *Control,
double *Info)
204 Symbolic, Control, Info);
226 const double *Control)
295 &ignore1, &ignore2, &ignore3, Numeric);
308 reinterpret_cast<double *
> (Lz),
311 reinterpret_cast<double *
> (Uz),
314 reinterpret_cast<double *
> (Dz),
323 const Complex *Az,
void *Symbolic,
void **Numeric,
324 const double *Control,
double *Info)
328 reinterpret_cast<const double *
> (Az),
329 nullptr, Symbolic, Numeric, Control, Info);
338 void **Symbolic,
const double *Control,
double *Info)
343 reinterpret_cast<const double *
> (Az),
345 Symbolic, Control, Info);
372 reinterpret_cast<const double *
> (Az),
373 nullptr, col_form, Control);
407 template <
typename lu_type>
410 : m_L (), m_U (), m_R (), m_cond (0), m_P (), m_Q ()
412 #if defined (HAVE_UMFPACK)
417 Matrix Control (UMFPACK_CONTROL, 1);
419 umfpack_defaults<lu_elt_type> (control);
423 Control (UMFPACK_PRL) = tmp;
425 if (piv_thres.
numel () == 2)
427 tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
429 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
431 tmp = (piv_thres (1) > 1. ? 1. : piv_thres (1));
433 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
439 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
443 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
449 Control (UMFPACK_FIXQ) = tmp;
453 Control (UMFPACK_SCALE) = UMFPACK_SCALE_SUM;
455 Control (UMFPACK_SCALE) = UMFPACK_SCALE_NONE;
457 umfpack_report_control<lu_elt_type> (control);
463 umfpack_report_matrix<lu_elt_type> (nr, nc, Ap, Ai, Ax,
468 Matrix Info (1, UMFPACK_INFO);
470 int status = umfpack_qsymbolic<lu_elt_type> (nr, nc, Ap, Ai, Ax,
nullptr,
471 &Symbolic, control, info);
475 umfpack_report_status<lu_elt_type> (control, status);
476 umfpack_report_info<lu_elt_type> (control, info);
478 umfpack_free_symbolic<lu_elt_type> (&Symbolic);
480 (*current_liboctave_error_handler)
481 (
"sparse_lu: symbolic factorization failed");
485 umfpack_report_symbolic<lu_elt_type> (Symbolic, control);
488 status = umfpack_numeric<lu_elt_type> (Ap, Ai, Ax, Symbolic,
489 &Numeric, control, info);
490 umfpack_free_symbolic<lu_elt_type> (&Symbolic);
492 m_cond = Info (UMFPACK_RCOND);
496 umfpack_report_status<lu_elt_type> (control, status);
497 umfpack_report_info<lu_elt_type> (control, info);
499 umfpack_free_numeric<lu_elt_type> (&Numeric);
501 (*current_liboctave_error_handler)
502 (
"sparse_lu: numeric factorization failed");
506 umfpack_report_numeric<lu_elt_type> (Numeric, control);
509 status = umfpack_get_lunz<lu_elt_type> (&lnz, &unz, Numeric);
513 umfpack_report_status<lu_elt_type> (control, status);
514 umfpack_report_info<lu_elt_type> (control, info);
516 umfpack_free_numeric<lu_elt_type> (&Numeric);
518 (*current_liboctave_error_handler)
519 (
"sparse_lu: extracting LU factors failed");
526 m_L = lu_type (n_inner, nr,
529 m_L = lu_type (n_inner, nr, lnz);
536 m_U = lu_type (n_inner, nc,
539 m_U = lu_type (n_inner, nc, unz);
561 status = umfpack_get_numeric<lu_elt_type> (Ltp, Ltj, Ltx,
567 umfpack_free_numeric<lu_elt_type> (&Numeric);
571 umfpack_report_status<lu_elt_type> (control, status);
573 (*current_liboctave_error_handler)
574 (
"sparse_lu: extracting LU factors failed");
584 umfpack_report_matrix<lu_elt_type> (nr, n_inner,
590 umfpack_report_matrix<lu_elt_type> (n_inner, nc,
596 umfpack_report_perm<lu_elt_type> (nr, p, control);
597 umfpack_report_perm<lu_elt_type> (nc, q, control);
600 umfpack_report_info<lu_elt_type> (control, info);
607 octave_unused_parameter (a);
608 octave_unused_parameter (piv_thres);
609 octave_unused_parameter (
scale);
611 (*current_liboctave_error_handler)
612 (
"support for UMFPACK was unavailable or disabled when liboctave was built");
617 template <
typename lu_type>
621 bool FixedQ,
double droptol,
622 bool milu,
bool udiag)
623 : m_L (), m_U (), m_R (), m_cond (0), m_P (), m_Q ()
625 #if defined (HAVE_UMFPACK)
628 (*current_liboctave_error_handler)
629 (
"Modified incomplete LU not implemented");
635 Matrix Control (UMFPACK_CONTROL, 1);
637 umfpack_defaults<lu_elt_type> (control);
641 Control (UMFPACK_PRL) = tmp;
643 if (piv_thres.
numel () == 2)
645 tmp = (piv_thres (0) > 1. ? 1. : piv_thres (0));
647 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
648 tmp = (piv_thres (1) > 1. ? 1. : piv_thres (1));
650 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
656 Control (UMFPACK_PIVOT_TOLERANCE) = tmp;
660 Control (UMFPACK_SYM_PIVOT_TOLERANCE) = tmp;
664 Control (UMFPACK_DROPTOL) = droptol;
668 Control (UMFPACK_FIXQ) = 1.0;
673 Control (UMFPACK_FIXQ) = tmp;
678 Control (UMFPACK_SCALE) = UMFPACK_SCALE_SUM;
680 Control (UMFPACK_SCALE) = UMFPACK_SCALE_NONE;
682 umfpack_report_control<lu_elt_type> (control);
688 umfpack_report_matrix<lu_elt_type> (nr, nc, Ap, Ai, Ax,
693 Matrix Info (1, UMFPACK_INFO);
705 status = umfpack_qsymbolic<lu_elt_type> (nr, nc, Ap, Ai, Ax,
706 qinit, &Symbolic, control,
713 umfpack_report_status<lu_elt_type> (control, status);
714 umfpack_report_info<lu_elt_type> (control, info);
716 umfpack_free_symbolic<lu_elt_type> (&Symbolic);
718 (*current_liboctave_error_handler)
719 (
"sparse_lu: symbolic factorization failed");
723 umfpack_report_symbolic<lu_elt_type> (Symbolic, control);
726 status = umfpack_numeric<lu_elt_type> (Ap, Ai, Ax, Symbolic,
727 &Numeric, control, info);
728 umfpack_free_symbolic<lu_elt_type> (&Symbolic);
730 m_cond = Info (UMFPACK_RCOND);
734 umfpack_report_status<lu_elt_type> (control, status);
735 umfpack_report_info<lu_elt_type> (control, info);
737 umfpack_free_numeric<lu_elt_type> (&Numeric);
739 (*current_liboctave_error_handler)
740 (
"sparse_lu: numeric factorization failed");
744 umfpack_report_numeric<lu_elt_type> (Numeric, control);
747 status = umfpack_get_lunz<lu_elt_type> (&lnz, &unz, Numeric);
751 umfpack_report_status<lu_elt_type> (control, status);
752 umfpack_report_info<lu_elt_type> (control, info);
754 umfpack_free_numeric<lu_elt_type> (&Numeric);
756 (*current_liboctave_error_handler)
757 (
"sparse_lu: extracting LU factors failed");
764 m_L = lu_type (n_inner, nr,
767 m_L = lu_type (n_inner, nr, lnz);
774 m_U = lu_type (n_inner, nc,
777 m_U = lu_type (n_inner, nc, unz);
799 status = umfpack_get_numeric<lu_elt_type> (Ltp, Ltj, Ltx,
805 umfpack_free_numeric<lu_elt_type> (&Numeric);
809 umfpack_report_status<lu_elt_type> (control, status);
811 (*current_liboctave_error_handler)
812 (
"sparse_lu: extracting LU factors failed");
822 umfpack_report_matrix<lu_elt_type> (nr, n_inner,
828 umfpack_report_matrix<lu_elt_type> (n_inner, nc,
834 umfpack_report_perm<lu_elt_type> (nr, p, control);
835 umfpack_report_perm<lu_elt_type> (nc, q, control);
838 umfpack_report_info<lu_elt_type> (control, info);
844 (*current_liboctave_error_handler)
845 (
"Option udiag of incomplete LU not implemented");
849 octave_unused_parameter (a);
850 octave_unused_parameter (Qinit);
851 octave_unused_parameter (piv_thres);
852 octave_unused_parameter (
scale);
853 octave_unused_parameter (FixedQ);
854 octave_unused_parameter (droptol);
855 octave_unused_parameter (milu);
856 octave_unused_parameter (udiag);
858 (*current_liboctave_error_handler)
859 (
"support for UMFPACK was unavailable or disabled when liboctave was built");
864 template <
typename lu_type>
872 lu_type Yout (nr, nc, m_L.nnz () + m_U.nnz () - (nr<nz?nr:nz));
880 Yout.xridx (ii) = m_U.ridx (i);
881 Yout.xdata (ii++) = m_U.data (i);
888 i < m_L.cidx (j +1); i++)
890 Yout.xridx (ii) = m_L.ridx (i);
891 Yout.xdata (ii++) = m_L.data (i);
895 Yout.xcidx (j + 1) = ii;
901 template <
typename lu_type>
912 Pout.
ridx (m_P(i)) = i;
921 template <
typename lu_type>
930 Pout.
xelem (i) =
static_cast<double> (m_P(i) + 1);
935 template <
typename lu_type>
942 template <
typename lu_type>
953 Pout.
ridx (i) = m_Q(i);
962 template <
typename lu_type>
971 Pout.
xelem (i) =
static_cast<double> (m_Q(i) + 1);
976 template <
typename lu_type>
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type * cidx(void)
octave_idx_type * ridx(void)
octave_idx_type * xcidx(void)
octave_idx_type * xridx(void)
Vector representing the dimensions (size) of an Array.
OCTAVE_API ColumnVector Pr_vec(void) const
OCTAVE_API ColumnVector Pc_vec(void) const
MArray< octave_idx_type > m_Q
OCTAVE_API PermMatrix Pr_mat(void) const
OCTAVE_API lu_type Y(void) const
OCTAVE_API SparseMatrix Pc(void) const
OCTAVE_API SparseMatrix Pr(void) const
lu_type::element_type lu_elt_type
OCTAVE_API PermMatrix Pc_mat(void) const
MArray< octave_idx_type > m_P
static double get_key(const std::string &key)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void scale(Matrix &m, double x, double y, double z)
class OCTAVE_API SparseMatrix
class OCTAVE_API PermMatrix
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
#define UMFPACK_ZNAME(name)
#define UMFPACK_DNAME(name)
void umfpack_report_numeric(void *Numeric, const double *Control)
octave_idx_type umfpack_qsymbolic(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const T *Ax, const octave_idx_type *Qinit, void **Symbolic, const double *Control, double *Info)
OCTAVE_API void umfpack_defaults< Complex >(double *Control)
OCTAVE_API void umfpack_free_numeric< Complex >(void **Numeric)
OCTAVE_API void umfpack_free_numeric< double >(void **Numeric)
OCTAVE_API void umfpack_free_symbolic< Complex >(void **Symbolic)
OCTAVE_API octave_idx_type umfpack_qsymbolic< double >(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const double *Ax, const octave_idx_type *Qinit, void **Symbolic, const double *Control, double *Info)
void umfpack_report_perm(octave_idx_type np, const octave_idx_type *Perm, const double *Control)
OCTAVE_API void umfpack_report_control< Complex >(const double *Control)
void umfpack_free_symbolic(void **Symbolic)
OCTAVE_API octave_idx_type umfpack_get_lunz< double >(octave_idx_type *lnz, octave_idx_type *unz, void *Numeric)
void umfpack_free_numeric(void **Numeric)
OCTAVE_API void umfpack_report_status< Complex >(double *Control, octave_idx_type status)
void umfpack_report_symbolic(void *Symbolic, const double *Control)
OCTAVE_API void umfpack_report_symbolic< double >(void *Symbolic, const double *Control)
OCTAVE_API void umfpack_report_info< Complex >(const double *Control, const double *Info)
OCTAVE_API void umfpack_report_perm< Complex >(octave_idx_type np, const octave_idx_type *Perm, const double *Control)
void umfpack_report_control(const double *Control)
OCTAVE_API void umfpack_defaults< double >(double *Control)
OCTAVE_API octave_idx_type umfpack_numeric< double >(const octave_idx_type *Ap, const octave_idx_type *Ai, const double *Ax, void *Symbolic, void **Numeric, const double *Control, double *Info)
octave_idx_type umfpack_numeric(const octave_idx_type *Ap, const octave_idx_type *Ai, const T *Ax, void *Symbolic, void **Numeric, const double *Control, double *Info)
OCTAVE_API octave_idx_type umfpack_get_lunz< Complex >(octave_idx_type *lnz, octave_idx_type *unz, void *Numeric)
octave_idx_type umfpack_get_lunz(octave_idx_type *lnz, octave_idx_type *unz, void *Numeric)
octave_idx_type umfpack_get_numeric(octave_idx_type *Lp, octave_idx_type *Lj, T *Lx, octave_idx_type *Up, octave_idx_type *Ui, T *Ux, octave_idx_type *p, octave_idx_type *q, double *Dz_packed, octave_idx_type *do_recip, double *Rs, void *Numeric)
void umfpack_report_matrix(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const T *Ax, octave_idx_type col_form, const double *Control)
OCTAVE_API void umfpack_report_matrix< double >(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const double *Ax, octave_idx_type col_form, const double *Control)
OCTAVE_API void umfpack_report_matrix< Complex >(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const Complex *Az, octave_idx_type col_form, const double *Control)
void umfpack_report_info(const double *Control, const double *Info)
void umfpack_report_status(double *Control, octave_idx_type status)
OCTAVE_API void umfpack_report_symbolic< Complex >(void *Symbolic, const double *Control)
OCTAVE_API void umfpack_report_perm< double >(octave_idx_type np, const octave_idx_type *Perm, const double *Control)
OCTAVE_API octave_idx_type umfpack_qsymbolic< Complex >(octave_idx_type n_row, octave_idx_type n_col, const octave_idx_type *Ap, const octave_idx_type *Ai, const Complex *Az, const octave_idx_type *Qinit, void **Symbolic, const double *Control, double *Info)
OCTAVE_API octave_idx_type umfpack_numeric< Complex >(const octave_idx_type *Ap, const octave_idx_type *Ai, const Complex *Az, void *Symbolic, void **Numeric, const double *Control, double *Info)
void umfpack_defaults(double *Control)
OCTAVE_API octave_idx_type umfpack_get_numeric< double >(octave_idx_type *Lp, octave_idx_type *Lj, double *Lx, octave_idx_type *Up, octave_idx_type *Ui, double *Ux, octave_idx_type *p, octave_idx_type *q, double *Dx, octave_idx_type *do_recip, double *Rs, void *Numeric)
OCTAVE_API void umfpack_report_numeric< Complex >(void *Numeric, const double *Control)
OCTAVE_API void umfpack_report_status< double >(double *Control, octave_idx_type status)
OCTAVE_API void umfpack_free_symbolic< double >(void **Symbolic)
OCTAVE_API octave_idx_type umfpack_get_numeric< Complex >(octave_idx_type *Lp, octave_idx_type *Lj, Complex *Lz, octave_idx_type *Up, octave_idx_type *Ui, Complex *Uz, octave_idx_type *p, octave_idx_type *q, double *Dz, octave_idx_type *do_recip, double *Rs, void *Numeric)
OCTAVE_API void umfpack_report_control< double >(const double *Control)
OCTAVE_API void umfpack_report_info< double >(const double *Control, const double *Info)
OCTAVE_API void umfpack_report_numeric< double >(void *Numeric, const double *Control)