116#if defined (HAVE_CHOLMOD)
118 int nargin = args.length ();
120 if (nargin < 1 || nargin > 3)
126 cholmod_sparse Astore;
127 cholmod_sparse *
A = &Astore;
131#if defined (OCTAVE_ENABLE_64)
132 A->itype = CHOLMOD_LONG;
134 A->itype = CHOLMOD_INT;
136 A->dtype = CHOLMOD_DOUBLE;
143 if (args(0).isreal ())
145 sm = args(0).sparse_matrix_value ();
146 A->nrow = sm.
rows ();
147 A->ncol = sm.
cols ();
150 A->nzmax = sm.
nnz ();
151 A->xtype = CHOLMOD_REAL;
153 if (
A->nrow > 0 &&
A->ncol > 0)
156 else if (args(0).iscomplex ())
158 scm = args(0).sparse_complex_matrix_value ();
159 A->nrow = scm.
rows ();
160 A->ncol = scm.
cols ();
163 A->nzmax = scm.
nnz ();
164 A->xtype = CHOLMOD_COMPLEX;
166 if (
A->nrow > 0 &&
A->ncol > 0)
172 bool coletree =
false;
177 std::string str = args(1).xstring_value (
"TYP must be a string");
180 ch = tolower (str[0]);
194 error (R
"(symbfact: unrecognized TYP "%s")", str.c_str ());
199 std::string str = args(2).xstring_value (
"MODE must be a string");
202 ch = toupper (str[0]);
204 error (R
"(symbfact: unrecognized MODE "%s")", str.c_str ());
207 if (
A->stype &&
A->nrow !=
A->ncol)
216 cholmod_common Common;
217 cholmod_common *cm = &Common;
224 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
228 cm->print =
static_cast<int> (spu) + 2;
229 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
233 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
234 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
237 cholmod_sparse *Aup, *Alo;
239 if (
A->stype == 1 || coletree)
255 if (cm->status < CHOLMOD_OK)
257 err_msg =
"symbfact: matrix corrupted";
261 if (
CHOLMOD_NAME(postorder) (Parent, n,
nullptr, Post, cm) != n)
263 err_msg =
"symbfact: postorder failed";
267 CHOLMOD_NAME(rowcolcounts) (Alo,
nullptr, 0, Parent, Post,
nullptr, ColCount,
270 if (cm->status < CHOLMOD_OK)
272 err_msg =
"symbfact: matrix corrupted";
278 cholmod_sparse *A1, *A2;
285 else if (
A->stype == -1)
326 0, CHOLMOD_PATTERN, cm);
336 L.
xridx (W[Ri[p]]++) = k;
339 L.
xridx (W[k]++) = k;
346 std::fill_n (L.
xdata (), lnz,
true);
358 tmp(i) = Post[i] + 1;
365 tmp(i) = Parent[i] + 1;
373 for (
int i = 0 ; i < n ; i++)
374 height = std::max (height, Level[i]);
376 retval(1) =
static_cast<double> (height);
380 tmp(i) = ColCount[i];
387 if (! err_msg.empty ())
388 error (
"%s", err_msg.c_str ());
394 octave_unused_parameter (args);
395 octave_unused_parameter (nargout);
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.