26 #if defined (HAVE_CONFIG_H)
53 DEFUN (symbfact, args, nargout,
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)
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;
255 if (cm->status < CHOLMOD_OK)
257 err_msg =
"symbfact: matrix corrupted";
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);
charNDArray max(char d, const charNDArray &m)
SparseBoolMatrix transpose(void) const
octave_idx_type rows(void) const
octave_idx_type * cidx(void)
octave_idx_type * ridx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type cols(void) const
octave_idx_type * xcidx(void)
octave_idx_type * xridx(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)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
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
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
#define CHOLMOD_NAME(name)
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)