26 #if defined (HAVE_CONFIG_H)
51 DEFUN (symbfact, args, nargout,
114 #if defined (HAVE_CHOLMOD)
116 int nargin = args.length ();
118 if (nargin < 1 || nargin > 3)
124 cholmod_sparse Astore;
125 cholmod_sparse *
A = &Astore;
129 #if defined (OCTAVE_ENABLE_64)
130 A->itype = CHOLMOD_LONG;
132 A->itype = CHOLMOD_INT;
134 A->dtype = CHOLMOD_DOUBLE;
138 if (args(0).isreal ())
146 A->xtype = CHOLMOD_REAL;
151 else if (args(0).iscomplex ())
159 A->xtype = CHOLMOD_COMPLEX;
172 std::string str = args(1).xstring_value (
"TYP must be a string");
175 ch = tolower (str[0]);
189 error (R
"(symbfact: unrecognized TYP "%s")", str.c_str ());
194 std::string str = args(2).xstring_value (
"MODE must be a string");
197 ch = toupper (str[0]);
199 error (R
"(symbfact: unrecognized MODE "%s")", str.c_str ());
202 if (
A->stype &&
A->nrow !=
A->ncol)
211 cholmod_common Common;
212 cholmod_common *cm = &Common;
219 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function,
nullptr);
223 cm->print =
static_cast<int> (spu) + 2;
224 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
228 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
229 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
232 cholmod_sparse *Aup, *Alo;
250 if (cm->status < CHOLMOD_OK)
252 err_msg =
"symbfact: matrix corrupted";
258 err_msg =
"symbfact: postorder failed";
262 CHOLMOD_NAME(rowcolcounts) (Alo,
nullptr, 0, Parent, Post,
nullptr, ColCount,
265 if (cm->status < CHOLMOD_OK)
267 err_msg =
"symbfact: matrix corrupted";
273 cholmod_sparse *A1, *A2;
280 else if (
A->stype == -1)
321 0, CHOLMOD_PATTERN, cm);
331 L.
xridx (W[Ri[p]]++) = k;
334 L.
xridx (W[k]++) = k;
341 std::fill_n (L.
xdata (), lnz,
true);
353 tmp(i) = Post[i] + 1;
360 tmp(i) = Parent[i] + 1;
368 for (
int i = 0 ; i <
n ; i++)
369 height =
std::max (height, Level[i]);
371 retval(1) =
static_cast<double> (height);
375 tmp(i) = ColCount[i];
382 if (! err_msg.empty ())
383 error (
"%s", err_msg.c_str ());
389 octave_unused_parameter (args);
390 octave_unused_parameter (nargout);
charNDArray max(char d, const charNDArray &m)
SparseBoolMatrix transpose(void) const
octave_idx_type cols(void) const
octave_idx_type * xridx(void)
octave_idx_type * cidx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type rows(void) const
octave_idx_type * xcidx(void)
octave_idx_type * ridx(void)
Vector representing the dimensions (size) of an Array.
static double get_key(const std::string &key)
static void coletree(const octave_idx_type *ridx, const octave_idx_type *colbeg, octave_idx_type *colend, octave_idx_type *parent, octave_idx_type nr, octave_idx_type nc)
OCTINTERP_API void print_usage(void)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
void err_square_matrix_required(const char *fcn, const char *name)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
void err_wrong_type_arg(const char *name, const char *s)
F77_RET_T const F77_INT F77_CMPLX * A
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define CHOLMOD_NAME(name)
octave_value::octave_value(const Array< char > &chm, char type) return retval
void SparseCholError(int status, char *file, int line, char *message)
int SparseCholPrint(const char *fmt,...)
static void transpose(octave_idx_type N, const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *ridx2, octave_idx_type *cidx2)