26 #if defined (HAVE_CONFIG_H)
49 template <
typename chol_type>
55 : count (1), is_pd (false), minor_p (0), perms (), cond (0)
56 #if defined (HAVE_CHOLMOD)
57 , Lsparse (nullptr), Common ()
62 : count (1), is_pd (false), minor_p (0), perms (), cond (0)
63 #if defined (HAVE_CHOLMOD)
64 , Lsparse (nullptr), Common ()
67 init (a, natural, force);
71 bool natural,
bool force)
72 : count (1), is_pd (false), minor_p (0), perms (), cond (0)
73 #if defined (HAVE_CHOLMOD)
74 , Lsparse (nullptr), Common ()
77 info = init (a, natural, force);
88 #if defined (HAVE_CHOLMOD)
96 #if defined (HAVE_CHOLMOD)
97 cholmod_sparse *
L (
void)
const
105 #if defined (HAVE_CHOLMOD)
119 double rcond (
void)
const {
return cond; }
133 #if defined (HAVE_CHOLMOD)
138 void drop_zeros (
const cholmod_sparse *S);
144 #if defined (HAVE_CHOLMOD)
149 template <
typename chol_type>
169 for (; p < pend; p++)
173 if (CHOLMOD_IS_NONZERO (sik))
190 template <
typename T>
205 return CHOLMOD_COMPLEX;
210 template <
typename chol_type>
213 bool natural,
bool force)
217 #if defined (HAVE_CHOLMOD)
223 (*current_liboctave_error_handler)
224 (
"sparse_chol requires square matrix");
226 cholmod_common *cm = &Common;
231 cm->prefer_zomplex =
false;
238 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
242 cm->print =
static_cast<int> (spu) + 2;
243 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
249 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide,
252 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
254 cm->final_asis =
false;
255 cm->final_super =
false;
257 cm->final_pack =
true;
258 cm->final_monotonic =
true;
259 cm->final_resymbol =
false;
262 cholmod_sparse *
ac = &
A;
270 ac->nzmax = a.nnz ();
274 #if defined (OCTAVE_ENABLE_64)
275 ac->itype = CHOLMOD_LONG;
277 ac->itype = CHOLMOD_INT;
279 ac->dtype = CHOLMOD_DOUBLE;
281 ac->xtype = get_xtype<chol_elt> ();
292 cm->method[0].ordering = CHOLMOD_NATURAL;
293 cm->postorder =
false;
296 cholmod_factor *Lfactor;
302 is_pd = cm->status == CHOLMOD_OK;
303 info = (is_pd ? 0 : cm->status);
311 minor_p = Lfactor->minor;
317 if (minor_p > 0 && minor_p < a_nr)
319 size_t n1 = a_nr + 1;
322 Lsparse->p, &n1, cm);
329 Lsparse->ncol = minor_p;
332 drop_zeros (Lsparse);
343 static char blank_name[] =
" ";
354 octave_unused_parameter (a);
355 octave_unused_parameter (natural);
356 octave_unused_parameter (force);
358 (*current_liboctave_error_handler)
359 (
"support for CHOLMOD was unavailable or disabled when liboctave was built");
366 template <
typename chol_type>
370 #if defined (HAVE_CHOLMOD)
393 template <
typename chol_type>
398 template <
typename chol_type>
405 template <
typename chol_type>
408 bool natural,
bool force)
413 template <
typename chol_type>
421 template <
typename chol_type>
428 template <
typename chol_type>
435 template <
typename chol_type>
438 if (--rep->count == 0)
442 template <
typename chol_type>
448 if (--rep->count == 0)
458 template <
typename chol_type>
462 #if defined (HAVE_CHOLMOD)
464 cholmod_sparse *
m = rep->L ();
469 chol_type ret (
m->nrow, nc, nnz);
477 ret.xdata (i) =
static_cast<chol_elt *
>(
m->x)[i];
489 template <
typename chol_type>
496 template <
typename chol_type>
503 template <
typename chol_type>
510 template <
typename chol_type>
514 return rep->is_positive_definite ();
517 template <
typename chol_type>
521 return rep->rcond ();
524 template <
typename chol_type>
530 #if defined (HAVE_CHOLMOD)
532 cholmod_sparse *
m = rep->L ();
538 chol_type linv = L ().hermitian ().inverse (mattype, info, rcond2, 1, 0);
554 template <
typename chol_type>
563 (*current_liboctave_error_handler) (
"U must be a square matrix");
566 int typ = mattype.type (
false);
569 chol_type rtra, multip;
573 rtra =
r.transpose ();
578 rtra =
r.transpose ();
585 retval = multip.inverse (mattypenew, info, rcond,
true,
false);
octave_idx_type numel(void) const
Number of elements in the array.
Array< T > hermitian(T(*fcn)(const T &)=nullptr) const
Size of the specified dimension.
SparseMatrix transpose(void) const
SparseMatrix hermitian(void) const
octave_idx_type * xridx(void)
octave_idx_type * xcidx(void)
RowVector perm(void) const
octave_idx_type P(void) const
void drop_zeros(const cholmod_sparse *S)
cholmod_sparse * L(void) const
octave_idx_type init(const chol_type &a, bool natural, bool force)
sparse_chol_rep(const chol_type &a, bool natural, bool force)
sparse_chol_rep(const sparse_chol_rep &)=delete
sparse_chol_rep(const chol_type &a, octave_idx_type &info, bool natural, bool force)
SparseMatrix Q(void) const
bool is_positive_definite(void) const
refcount< octave_idx_type > count
SparseMatrix Q(void) const
chol_type inverse(void) const
chol_type::element_type chol_elt
RowVector perm(void) const
sparse_chol & operator=(const sparse_chol &a)
octave_idx_type P(void) const
bool is_positive_definite(void) const
virtual ~sparse_chol(void)
static double get_key(const std::string &key)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
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
F77_RET_T const F77_INT F77_CMPLX * A
template SparseMatrix chol2inv< SparseMatrix >(const SparseMatrix &r)
template SparseComplexMatrix chol2inv< SparseComplexMatrix >(const SparseComplexMatrix &r)
int get_xtype< Complex >(void)
int get_xtype< double >(void)
#define CHOLMOD_NAME(name)
octave_value::octave_value(const Array< char > &chm, char type) return retval
#define BEGIN_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
#define END_INTERRUPT_IMMEDIATELY_IN_FOREIGN_CODE
void SparseCholError(int status, char *file, int line, char *message)
int SparseCholPrint(const char *fmt,...)