29 #if defined (HAVE_CONFIG_H)
78 for ( ; Flag[i] != k ; i = Parent[i])
128 postnum = etdfs (
w, first_kid, next_kid, post, postnum);
150 next_kid[v] = first_kid[dad];
155 etdfs (
n, first_kid, next_kid, post, 0);
175 if (firstcol[row] > col)
198 cset =
link (cset, rset, pp);
205 DEFUN (colamd, args, nargout,
275 #if defined (HAVE_COLAMD)
277 int nargin = args.length ();
279 if (nargin < 1 || nargin > 2)
286 static_assert (COLAMD_KNOBS <= 40,
287 "colamd: # of COLAMD_KNOBS exceeded. Please report this to bugs.octave.org");
288 double knob_storage[COLAMD_KNOBS];
289 double *knobs = &knob_storage[0];
290 COLAMD_NAME (_set_defaults) (knobs);
295 NDArray User_knobs = args(1).array_value ();
296 int nel_User_knobs = User_knobs.
numel ();
298 if (nel_User_knobs > 0)
299 knobs[COLAMD_DENSE_ROW] = User_knobs(0);
300 if (nel_User_knobs > 1)
301 knobs[COLAMD_DENSE_COL] = User_knobs(1);
302 if (nel_User_knobs > 2)
303 spumoni =
static_cast<int> (User_knobs(2));
310 <<
'.' << COLAMD_SUB_VERSION
311 <<
", " << COLAMD_DATE <<
":\n";
313 if (knobs[COLAMD_DENSE_ROW] >= 0)
315 <<
", rows with > max (16,"
316 << knobs[COLAMD_DENSE_ROW] <<
"* sqrt (columns(A)))"
317 <<
" entries removed\n";
320 <<
", only completely dense rows removed\n";
322 if (knobs[COLAMD_DENSE_COL] >= 0)
324 <<
", cols with > max (16,"
325 << knobs[COLAMD_DENSE_COL] <<
"* sqrt (size(A)))"
326 <<
" entries removed\n";
329 <<
", only completely dense columns removed\n";
332 <<
", statistics and knobs printed\n";
342 if (args(0).issparse ())
344 if (args(0).iscomplex ())
346 scm = args(0).sparse_complex_matrix_value ();
355 sm = args(0).sparse_matrix_value ();
366 if (args(0).iscomplex ())
389 static_assert (COLAMD_STATS <= 40,
390 "colamd: # of COLAMD_STATS exceeded. Please report this to bugs.octave.org");
393 if (! COLAMD_NAME () (n_row, n_col, Alen,
A, p, knobs, stats))
395 COLAMD_NAME (_report)(stats);
397 error (
"colamd: internal error!");
407 colbeg[i] = cidx[p[i]];
408 colend[i] = cidx[p[i]+1];
411 coletree (ridx, colbeg, colend, etree, n_row, n_col);
414 tree_postorder (n_col, etree, colbeg);
419 out_perm(i) = p[colbeg[i]] + 1;
421 retval(0) = out_perm;
425 COLAMD_NAME (_report)(stats);
432 out_stats(i) = stats[i];
433 retval(1) = out_stats;
438 out_stats(COLAMD_INFO1)++;
439 out_stats(COLAMD_INFO2)++;
446 octave_unused_parameter (args);
447 octave_unused_parameter (nargout);
454 DEFUN (symamd, args, nargout,
519 #if defined (HAVE_COLAMD)
521 int nargin = args.length ();
523 if (nargin < 1 || nargin > 2)
530 static_assert (COLAMD_KNOBS <= 40,
531 "symamd: # of COLAMD_KNOBS exceeded. Please report this to bugs.octave.org");
532 double knob_storage[COLAMD_KNOBS];
533 double *knobs = &knob_storage[0];
534 COLAMD_NAME (_set_defaults) (knobs);
539 NDArray User_knobs = args(1).array_value ();
540 int nel_User_knobs = User_knobs.
numel ();
542 if (nel_User_knobs > 0)
543 knobs[COLAMD_DENSE_ROW] = User_knobs(COLAMD_DENSE_ROW);
544 if (nel_User_knobs > 1)
545 spumoni =
static_cast<int> (User_knobs (1));
551 << knobs[COLAMD_DENSE_ROW] << std::endl;
558 if (args(0).issparse ())
560 if (args(0).iscomplex ())
562 scm = args(0).sparse_complex_matrix_value ();
570 sm = args(0).sparse_matrix_value ();
579 if (args(0).iscomplex ())
595 static_assert (COLAMD_STATS <= 40,
596 "symamd: # of COLAMD_STATS exceeded. Please report this to bugs.octave.org");
602 knobs, stats, &calloc, &
free))
604 SYMAMD_NAME (_report)(stats);
606 error (
"symamd: internal error!");
611 symetree (ridx, cidx, etree, perm, n_col);
615 tree_postorder (n_col, etree, post);
620 out_perm(i) = perm[post[i]] + 1;
622 retval(0) = out_perm;
626 SYMAMD_NAME (_report)(stats);
633 out_stats(i) = stats[i];
634 retval(1) = out_stats;
639 out_stats(COLAMD_INFO1)++;
640 out_stats(COLAMD_INFO2)++;
647 octave_unused_parameter (args);
648 octave_unused_parameter (nargout);
655 DEFUN (etree, args, nargout,
673 int nargin = args.length ();
675 if (nargin < 1 || nargin > 2)
689 if (args(0).iscomplex ())
691 scm = args(0).sparse_complex_matrix_value ();
698 else if (args(0).islogical ())
700 sbm = args(0).sparse_bool_matrix_value ();
709 sm = args(0).sparse_matrix_value ();
721 std::string str = args(1).xstring_value (
"etree: TYP must be a string");
722 if (str.find (
'C') == 0 || str.find (
'c') == 0)
732 error (
"etree: S is marked as symmetric, but is not square");
734 symetree (ridx, cidx, etree,
nullptr, n_col);
744 colend[i] = cidx[i+1];
747 coletree (ridx, colbeg, colend, etree, n_row, n_col);
754 if (etree[i] == n_col)
757 tree(i) = etree[i] + 1;
765 tree_postorder (n_col, etree, post);
769 postorder(i) = post[i] + 1;
771 retval(1) = postorder;
789 OCTAVE_END_NAMESPACE(
octave)
octave_idx_type numel() const
Number of elements in the array.
octave_idx_type cols() const
octave_idx_type * xcidx()
octave_idx_type nnz() const
Actual number of nonzero terms.
octave_idx_type rows() const
octave_idx_type * xridx()
Vector representing the dimensions (size) of an Array.
ColumnVector real(const ComplexColumnVector &a)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#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)
int link(const std::string &old_name, const std::string &new_name)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
suitesparse_integer * to_suitesparse_intptr(octave_idx_type *i)