29 #if defined (HAVE_CONFIG_H)
76 for ( ; Flag[i] != k ; i = Parent[i])
126 postnum =
etdfs (
w, first_kid, next_kid, post, postnum);
148 next_kid[v] = first_kid[dad];
153 etdfs (
n, first_kid, next_kid, post, 0);
173 if (firstcol[row] > col)
196 cset =
link (cset, rset, pp);
203 DEFUN (colamd, args, nargout,
273 #if defined (HAVE_COLAMD)
275 int nargin = args.length ();
277 if (nargin < 1 || nargin > 2)
284 static_assert (COLAMD_KNOBS <= 40,
285 "colamd: # of COLAMD_KNOBS exceeded. Please report this to bugs.octave.org");
286 double knob_storage[COLAMD_KNOBS];
287 double *knobs = &knob_storage[0];
288 COLAMD_NAME (_set_defaults) (knobs);
293 NDArray User_knobs = args(1).array_value ();
294 int nel_User_knobs = User_knobs.
numel ();
296 if (nel_User_knobs > 0)
297 knobs[COLAMD_DENSE_ROW] = User_knobs(0);
298 if (nel_User_knobs > 1)
299 knobs[COLAMD_DENSE_COL] = User_knobs(1);
300 if (nel_User_knobs > 2)
301 spumoni =
static_cast<int> (User_knobs(2));
308 <<
'.' << COLAMD_SUB_VERSION
309 <<
", " << COLAMD_DATE <<
":\n";
311 if (knobs[COLAMD_DENSE_ROW] >= 0)
313 <<
", rows with > max (16,"
314 << knobs[COLAMD_DENSE_ROW] <<
"*sqrt (size(A,2)))"
315 <<
" entries removed\n";
318 <<
", only completely dense rows removed\n";
320 if (knobs[COLAMD_DENSE_COL] >= 0)
322 <<
", cols with > max (16,"
323 << knobs[COLAMD_DENSE_COL] <<
"*sqrt (size(A)))"
324 <<
" entries removed\n";
327 <<
", only completely dense columns removed\n";
330 <<
", statistics and knobs printed\n";
340 if (args(0).issparse ())
342 if (args(0).iscomplex ())
344 scm = args(0).sparse_complex_matrix_value ();
353 sm = args(0).sparse_matrix_value ();
364 if (args(0).iscomplex ())
387 static_assert (COLAMD_STATS <= 40,
388 "colamd: # of COLAMD_STATS exceeded. Please report this to bugs.octave.org");
391 if (! COLAMD_NAME () (n_row, n_col, Alen,
A, p, knobs, stats))
393 COLAMD_NAME (_report)(stats);
395 error (
"colamd: internal error!");
405 colbeg[i] = cidx[p[i]];
406 colend[i] = cidx[p[i]+1];
409 coletree (ridx, colbeg, colend, etree, n_row, n_col);
417 out_perm(i) = p[colbeg[i]] + 1;
423 COLAMD_NAME (_report)(stats);
430 out_stats(i) = stats[i];
436 out_stats(COLAMD_INFO1)++;
437 out_stats(COLAMD_INFO2)++;
444 octave_unused_parameter (args);
445 octave_unused_parameter (nargout);
452 DEFUN (symamd, args, nargout,
517 #if defined (HAVE_COLAMD)
519 int nargin = args.length ();
521 if (nargin < 1 || nargin > 2)
528 static_assert (COLAMD_KNOBS <= 40,
529 "symamd: # of COLAMD_KNOBS exceeded. Please report this to bugs.octave.org");
530 double knob_storage[COLAMD_KNOBS];
531 double *knobs = &knob_storage[0];
532 COLAMD_NAME (_set_defaults) (knobs);
537 NDArray User_knobs = args(1).array_value ();
538 int nel_User_knobs = User_knobs.
numel ();
540 if (nel_User_knobs > 0)
541 knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW);
542 if (nel_User_knobs > 1)
543 spumoni =
static_cast<int> (User_knobs (1));
549 << knobs[COLAMD_DENSE_ROW] << std::endl;
556 if (args(0).issparse ())
558 if (args(0).iscomplex ())
560 scm = args(0).sparse_complex_matrix_value ();
568 sm = args(0).sparse_matrix_value ();
577 if (args(0).iscomplex ())
593 static_assert (COLAMD_STATS <= 40,
594 "symamd: # of COLAMD_STATS exceeded. Please report this to bugs.octave.org");
600 knobs, stats, &calloc, &
free))
602 SYMAMD_NAME (_report)(stats);
604 error (
"symamd: internal error!");
609 symetree (ridx, cidx, etree, perm, n_col);
618 out_perm(i) = perm[post[i]] + 1;
624 SYMAMD_NAME (_report)(stats);
631 out_stats(i) = stats[i];
637 out_stats(COLAMD_INFO1)++;
638 out_stats(COLAMD_INFO2)++;
645 octave_unused_parameter (args);
646 octave_unused_parameter (nargout);
653 DEFUN (etree, args, nargout,
671 int nargin = args.length ();
673 if (nargin < 1 || nargin > 2)
683 if (! args(0).issparse ())
684 error (
"etree: S must be a sparse matrix");
686 if (args(0).iscomplex ())
709 std::string str = args(1).xstring_value (
"etree: TYP must be a string");
710 if (str.find (
'C') == 0 || str.find (
'c') == 0)
720 error (
"etree: S is marked as symmetric, but is not square");
722 symetree (ridx, cidx, etree,
nullptr, n_col);
732 colend[i] = cidx[i+1];
735 coletree (ridx, colbeg, colend, etree, n_row, n_col);
742 if (etree[i] == n_col)
745 tree(i) = etree[i] + 1;
757 postorder(i) = post[i] + 1;
octave_idx_type numel(void) const
Number of elements in the array.
octave_idx_type cols(void) const
octave_idx_type * xridx(void)
octave_idx_type nnz(void) const
Actual number of nonzero terms.
octave_idx_type rows(void) const
octave_idx_type * xcidx(void)
Vector representing the dimensions (size) of an Array.
static octave_idx_type etdfs(octave_idx_type v, octave_idx_type *first_kid, octave_idx_type *next_kid, octave_idx_type *post, octave_idx_type postnum)
static void tree_postorder(octave_idx_type n, octave_idx_type *parent, octave_idx_type *post)
static octave_idx_type make_set(octave_idx_type i, octave_idx_type *pp)
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)
static octave_idx_type link(octave_idx_type s, octave_idx_type t, octave_idx_type *pp)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
static void symetree(const octave_idx_type *ridx, const octave_idx_type *cidx, octave_idx_type *Parent, octave_idx_type *P, octave_idx_type n)
ColumnVector real(const ComplexColumnVector &a)
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)
F77_RET_T const F77_INT F77_CMPLX * A
std::complex< double > w(std::complex< double > z, double relerr=0)
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
octave_value::octave_value(const Array< char > &chm, char type) return retval