27 #define Long SuiteSparse_long
40 const mxArray *pargin [ ]
66 if (nargin < 1 || nargin > 3 || nargout < 0 || nargout > 2)
68 mexErrMsgTxt (
"Usage: [p stats] = ccolamd (A, knobs, cmember)") ;
77 in_cmember = mxGetPr (pargin [2]) ;
78 cslen = mxGetNumberOfElements (pargin [2]) ;
81 cmember = (
Long *) mxCalloc (cslen,
sizeof (
Long)) ;
82 for (
i = 0 ;
i < cslen ;
i++)
85 cmember[
i] = ((
Long) in_cmember [
i] - 1) ;
98 in_knobs = mxGetPr (pargin [1]) ;
99 i = mxGetNumberOfElements (pargin [1]) ;
100 if (
i > 0) knobs [
CCOLAMD_LU] = (in_knobs [0] != 0) ;
104 if (
i > 4) spumoni = (in_knobs [4] != 0) ;
110 mexPrintf (
"\nccolamd version %d.%d, %s:\nknobs(1): %g, order for %s\n",
113 (knobs [
CCOLAMD_LU] != 0) ?
"lu(A)" :
"chol(A'*A)") ;
116 mexPrintf (
"knobs(2): %g, rows with > max(16,%g*sqrt(size(A,2)))"
121 mexPrintf (
"knobs(2): %g, no dense rows removed\n", in_knobs [1]) ;
125 mexPrintf (
"knobs(3): %g, cols with > max(16,%g*sqrt(min(size(A)))"
130 mexPrintf (
"knobs(3): no dense columns removed\n", in_knobs [2]) ;
132 mexPrintf (
"knobs(4): %g, aggressive absorption: %s\n",
134 mexPrintf (
"knobs(5): %g, statistics and knobs printed\n",
140 Ainput = (mxArray *) pargin [0] ;
141 if (mxGetNumberOfDimensions (Ainput) != 2)
143 mexErrMsgTxt (
"ccolamd: input matrix must be 2-dimensional") ;
145 full = !mxIsSparse (Ainput) ;
148 mexCallMATLAB (1, &Ainput, 1, (mxArray **) pargin,
"sparse") ;
154 n_row = mxGetM (Ainput) ;
155 n_col = mxGetN (Ainput) ;
158 p = (
Long *) mxCalloc (n_col+1,
sizeof (
Long)) ;
159 (void) memcpy (
p, mxGetJc (Ainput), (n_col+1)*
sizeof (
Long)) ;
164 mexErrMsgTxt (
"ccolamd: problem too large") ;
169 A = (
Long *) mxCalloc (Alen,
sizeof (
Long)) ;
170 (void) memcpy (
A, mxGetIr (Ainput), nnz*
sizeof (
Long)) ;
174 mxDestroyArray (Ainput) ;
178 if (cmember !=
NULL && cslen != n_col)
180 mexErrMsgTxt (
"ccolamd: cmember must be of length equal to #cols of A");
188 mexErrMsgTxt (
"ccolamd error!") ;
195 pargout [0] = mxCreateDoubleMatrix (1, n_col, mxREAL) ;
196 out_perm = mxGetPr (pargout [0]) ;
197 for (
i = 0 ;
i < n_col ;
i++)
200 out_perm [
i] =
p [
i] + 1 ;
214 pargout [1] = mxCreateDoubleMatrix (1,
CCOLAMD_STATS, mxREAL) ;
215 out_stats = mxGetPr (pargout [1]) ;