44 @deftypefn {Loadable Function} {[@var{count}, @var{h}, @var{parent}, @var{post}, @var{r}] =} symbfact (@var{S})\n\
45 @deftypefnx {Loadable Function} {[@dots{}] =} symbfact (@var{S}, @var{typ})\n\
46 @deftypefnx {Loadable Function} {[@dots{}] =} symbfact (@var{S}, @var{typ}, @var{mode})\n\
48 Perform a symbolic factorization analysis on the sparse matrix @var{S}.\n\
50 The input variables are\n\
54 @var{S} is a complex or real sparse matrix.\n\
57 Is the type of the factorization and can be one of\n\
61 Factorize @var{S}. This is the default.\n\
64 Factorize @code{@var{S}' * @var{S}}.\n\
67 Factorize @tcode{@var{S} * @var{S}'}.\n\
70 Factorize @tcode{@var{S}'}\n\
74 The default is to return the Cholesky@tie{}factorization for @var{r}, and if\n\
75 @var{mode} is @qcode{'L'}, the conjugate transpose of the\n\
76 Cholesky@tie{}factorization is returned. The conjugate transpose version is\n\
77 faster and uses less memory, but returns the same values for @var{count},\n\
78 @var{h}, @var{parent} and @var{post} outputs.\n\
81 The output variables are\n\
85 The row counts of the Cholesky@tie{}factorization as determined by @var{typ}.\n\
88 The height of the elimination tree.\n\
91 The elimination tree itself.\n\
94 A sparse boolean matrix whose structure is that of the Cholesky\n\
95 factorization as determined by @var{typ}.\n\
100 int nargin = args.
length ();
102 if (nargin < 1 || nargin > 3 || nargout > 5)
110 cholmod_common Common;
111 cholmod_common *cm = &Common;
112 CHOLMOD_NAME(start) (cm);
118 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, 0);
122 cm->print =
static_cast<int> (spu) + 2;
123 SUITESPARSE_ASSIGN_FPTR (printf_func, cm->print_function, &
SparseCholPrint);
127 SUITESPARSE_ASSIGN_FPTR2 (divcomplex_func, cm->complex_divide, divcomplex);
128 SUITESPARSE_ASSIGN_FPTR2 (hypot_func, cm->hypotenuse, hypot);
131 cholmod_sparse Astore;
132 cholmod_sparse *
A = &Astore;
136 #ifdef USE_64_BIT_IDX_T
137 A->itype = CHOLMOD_LONG;
139 A->itype = CHOLMOD_INT;
141 A->dtype = CHOLMOD_DOUBLE;
145 if (args(0).is_real_type ())
153 A->xtype = CHOLMOD_REAL;
158 else if (args(0).is_complex_type ())
166 A->xtype = CHOLMOD_COMPLEX;
180 std::string str = args(1).string_value ();
181 ch = tolower (str.c_str ()[0]);
195 error (
"symbfact: unrecognized TYP in symbolic factorization");
198 if (A->stype && A->nrow != A->ncol)
199 error (
"symbfact: S must be a square matrix");
209 cholmod_sparse *
F = CHOLMOD_NAME(
transpose) (
A, 0, cm);
210 cholmod_sparse *Aup, *Alo;
212 if (A->stype == 1 || coletree)
223 CHOLMOD_NAME(etree) (Aup, Parent, cm);
225 if (cm->status < CHOLMOD_OK)
227 error (
"matrix corrupted");
231 if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
233 error (
"postorder failed");
237 CHOLMOD_NAME(rowcolcounts) (Alo, 0, 0, Parent, Post, 0,
238 ColCount, First, Level, cm);
240 if (cm->status < CHOLMOD_OK)
242 error (
"matrix corrupted");
248 cholmod_sparse *A1, *A2;
255 else if (A->stype == -1)
297 = CHOLMOD_NAME (allocate_sparse) (n, 1, n,
false,
true,
298 0, CHOLMOD_PATTERN, cm);
306 CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ;
308 L.
xridx (W[Ri[p]]++) = k ;
311 L.
xridx (W[k]++) = k ;
315 CHOLMOD_NAME (free_sparse) (&R, cm) ;
333 tmp(i) = Post[i] + 1;
340 tmp(i) = Parent[i] + 1;
348 for (
int i = 0 ; i < n ; i++)
349 height = (height > Level[i] ? height : Level[i]);
351 retval(1) =
static_cast<double> (height);
355 tmp(i) = ColCount[i];
361 error (
"symbfact: not available in this version of Octave");
octave_idx_type * xridx(void)
octave_idx_type cols(void) const
void gripe_wrong_type_arg(const char *name, const char *s, bool is_error)
octave_idx_type rows(void) const
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
void SparseCholError(int status, char *file, int line, char *message)
F77_RET_T const octave_idx_type Complex * A
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)
octave_idx_type * xcidx(void)
void error(const char *fmt,...)
SparseBoolMatrix transpose(void) const
octave_idx_type * cidx(void)
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 double get_key(const std::string &key)
octave_idx_type nnz(void) const
int SparseCholPrint(const char *fmt,...)
octave_idx_type * ridx(void)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
#define DEFUN_DLD(name, args_name, nargout_name, doc)
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)