25 #if defined (HAVE_CONFIG_H) 48 template <
typename chol_type>
54 : count (1), is_pd (
false), minor_p (0), perms (), cond (0)
56 , Lsparse (nullptr), Common ()
61 : count (1), is_pd (
false), minor_p (0), perms (), cond (0)
63 , Lsparse (nullptr), Common ()
66 init (
a, natural, force);
70 bool natural,
bool force)
71 : count (1), is_pd (
false), minor_p (0), perms (), cond (0)
73 , Lsparse (nullptr), Common ()
76 info = init (
a, natural, force);
87 #if defined (HAVE_CHOLMOD) 95 #if defined (HAVE_CHOLMOD) 96 cholmod_sparse *
L (
void)
const 104 #if defined (HAVE_CHOLMOD) 105 return (minor_p == static_cast<octave_idx_type>(Lsparse->ncol) ?
118 double rcond (
void)
const {
return cond; }
132 #if defined (HAVE_CHOLMOD) 137 void drop_zeros (
const cholmod_sparse *S);
143 #if defined (HAVE_CHOLMOD) 148 template <
typename chol_type>
168 for (;
p < pend;
p++)
172 if (CHOLMOD_IS_NONZERO (sik))
189 template <
typename T>
204 return CHOLMOD_COMPLEX;
209 template <
typename chol_type>
212 bool natural,
bool force)
216 #if defined (HAVE_CHOLMOD) 222 (*current_liboctave_error_handler)
223 (
"sparse_chol requires square matrix");
225 cholmod_common *cm = &Common;
230 cm->prefer_zomplex =
false;
237 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
241 cm->print =
static_cast<int> (spu) + 2;
242 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
248 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide,
251 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
253 cm->final_asis =
false;
254 cm->final_super =
false;
256 cm->final_pack =
true;
257 cm->final_monotonic =
true;
258 cm->final_resymbol =
false;
261 cholmod_sparse *ac = &
A;
269 ac->nzmax =
a.nnz ();
273 #if defined (OCTAVE_ENABLE_64) 274 ac->itype = CHOLMOD_LONG;
276 ac->itype = CHOLMOD_INT;
278 ac->dtype = CHOLMOD_DOUBLE;
280 ac->xtype = get_xtype<chol_elt> ();
291 cm->method[0].ordering = CHOLMOD_NATURAL;
292 cm->postorder =
false;
295 cholmod_factor *Lfactor;
301 is_pd = cm->status == CHOLMOD_OK;
302 info = (is_pd ? 0 : cm->status);
310 minor_p = Lfactor->minor;
316 if (minor_p > 0 && minor_p <
a_nr)
318 size_t n1 =
a_nr + 1;
321 Lsparse->p, &n1, cm);
328 Lsparse->ncol = minor_p;
331 drop_zeros (Lsparse);
342 static char blank_name[] =
" ";
353 octave_unused_parameter (
a);
354 octave_unused_parameter (natural);
355 octave_unused_parameter (force);
357 (*current_liboctave_error_handler)
358 (
"support for CHOLMOD was unavailable or disabled when liboctave was built");
365 template <
typename chol_type>
369 #if defined (HAVE_CHOLMOD) 392 template <
typename chol_type>
397 template <
typename chol_type>
404 template <
typename chol_type>
407 bool natural,
bool force)
412 template <
typename chol_type>
420 template <
typename chol_type>
427 template <
typename chol_type>
434 template <
typename chol_type>
437 if (--rep->count == 0)
441 template <
typename chol_type>
447 if (--rep->count == 0)
457 template <
typename chol_type>
461 #if defined (HAVE_CHOLMOD) 463 cholmod_sparse *m = rep->L ();
468 chol_type ret (m->nrow, nc, nnz);
476 ret.xdata (
i) =
static_cast<chol_elt *
>(m->x)[
i];
488 template <
typename chol_type>
495 template <
typename chol_type>
502 template <
typename chol_type>
509 template <
typename chol_type>
513 return rep->is_positive_definite ();
516 template <
typename chol_type>
520 return rep->rcond ();
523 template <
typename chol_type>
529 #if defined (HAVE_CHOLMOD) 531 cholmod_sparse *m = rep->L ();
537 chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0);
539 if (perms.
numel () == n)
546 retval = linv * linv.hermitian ();
553 template <
typename chol_type>
562 (*current_liboctave_error_handler) (
"U must be a square matrix");
565 int typ = mattype.type (
false);
568 chol_type rtra, multip;
572 rtra = r.transpose ();
577 rtra = r.transpose ();
584 retval = multip.inverse (mattypenew, info, rcond,
true,
false);
cholmod_sparse * L(void) const
sparse_chol_rep(const chol_type &a, bool natural, bool force)
RowVector perm(void) const
RowVector perm(void) const
chol_type::element_type chol_elt
void SparseCholError(int status, char *file, int line, char *message)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
SparseMatrix transpose(void) const
bool is_positive_definite(void) const
sparse_chol_rep(const chol_type &a, octave_idx_type &info, bool natural, bool force)
static double get_key(const std::string &key)
int get_xtype< Complex >(void)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
octave_idx_type init(const chol_type &a, bool natural, bool force)
F77_RET_T const F77_INT F77_CMPLX * A
#define CHOLMOD_NAME(name)
if(nargin< 2) print_usage()
sparse_chol & operator=(const sparse_chol &a)
template SparseMatrix chol2inv< SparseMatrix >(const SparseMatrix &r)
void drop_zeros(const cholmod_sparse *S)
int get_xtype< double >(void)
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
defaults to zero A value of zero computes the digamma a value the trigamma and so on The digamma function is defined
int SparseCholPrint(const char *fmt,...)
virtual ~sparse_chol(void)
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
chol_type inverse(void) const
template SparseComplexMatrix chol2inv< SparseComplexMatrix >(const SparseComplexMatrix &r)
SparseMatrix Q(void) const
octave_idx_type P(void) const
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
SparseMatrix Q(void) const
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type P(void) const
bool is_positive_definite(void) const
SparseMatrix hermitian(void) const