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\
53 @var{S} is a complex or real sparse matrix.\n\
56 Is the type of the factorization and can be one of\n\
60 Factorize @var{S}. This is the default.\n\
63 Factorize @code{@var{S}' * @var{S}}.\n\
66 Factorize @tcode{@var{S} * @var{S}'}.\n\
69 Factorize @tcode{@var{S}'}\n\
73 The default is to return the Cholesky@tie{}factorization for @var{r}, and if\n\
74 @var{mode} is @qcode{'L'}, the conjugate transpose of the\n\
75 Cholesky@tie{}factorization is returned. The conjugate transpose version is\n\
76 faster and uses less memory, but returns the same values for @var{count},\n\
77 @var{h}, @var{parent} and @var{post} outputs.\n\
80 The output variables are\n\
84 The row counts of the Cholesky@tie{}factorization as determined by @var{typ}.\n\
87 The height of the elimination tree.\n\
90 The elimination tree itself.\n\
93 A sparse boolean matrix whose structure is that of the Cholesky\n\
94 factorization as determined by @var{typ}.\n\
99 int nargin = args.
length ();
101 if (nargin < 1 || nargin > 3 || nargout > 5)
109 cholmod_common Common;
110 cholmod_common *cm = &Common;
111 CHOLMOD_NAME(start) (cm);
117 cm->print_function = 0;
121 cm->print =
static_cast<int> (spu) + 2;
126 cm->complex_divide = CHOLMOD_NAME(divcomplex);
127 cm->hypotenuse = CHOLMOD_NAME(hypot);
130 cholmod_sparse Astore;
131 cholmod_sparse *
A = &Astore;
135 #ifdef USE_64_BIT_IDX_T
136 A->itype = CHOLMOD_LONG;
138 A->itype = CHOLMOD_INT;
140 A->dtype = CHOLMOD_DOUBLE;
144 if (args(0).is_real_type ())
152 A->xtype = CHOLMOD_REAL;
157 else if (args(0).is_complex_type ())
165 A->xtype = CHOLMOD_COMPLEX;
179 std::string str = args(1).string_value ();
180 ch = tolower (str.c_str ()[0]);
194 error (
"symbfact: unrecognized TYP in symbolic factorization");
197 if (A->stype && A->nrow != A->ncol)
198 error (
"symbfact: S must be a square matrix");
208 cholmod_sparse *
F = CHOLMOD_NAME(
transpose) (
A, 0, cm);
209 cholmod_sparse *Aup, *Alo;
211 if (A->stype == 1 || coletree)
222 CHOLMOD_NAME(etree) (Aup, Parent, cm);
224 if (cm->status < CHOLMOD_OK)
226 error (
"matrix corrupted");
230 if (CHOLMOD_NAME(postorder) (Parent, n, 0, Post, cm) != n)
232 error (
"postorder failed");
236 CHOLMOD_NAME(rowcolcounts) (Alo, 0, 0, Parent, Post, 0,
237 ColCount, First, Level, cm);
239 if (cm->status < CHOLMOD_OK)
241 error (
"matrix corrupted");
247 cholmod_sparse *A1, *A2;
254 else if (A->stype == -1)
296 = CHOLMOD_NAME (allocate_sparse) (n, 1, n,
false,
true,
297 0, CHOLMOD_PATTERN, cm);
305 CHOLMOD_NAME (row_subtree) (A1, A2, k, Parent, R, cm) ;
307 L.
xridx (W[Ri[p]]++) = k ;
310 L.
xridx (W[k]++) = k ;
314 CHOLMOD_NAME (free_sparse) (&R, cm) ;
332 tmp(i) = Post[i] + 1;
339 tmp(i) = Parent[i] + 1;
347 for (
int i = 0 ; i < n ; i++)
348 height = (height > Level[i] ? height : Level[i]);
350 retval(1) =
static_cast<double> (height);
354 tmp(i) = ColCount[i];
360 error (
"symbfact: not available in this version of Octave");