38 #define Long SuiteSparse_long
43 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
58 mexPrintf (
"dump matrix: nrow %d ncol %d Alen %d\n", n_row, n_col, Alen) ;
62 mexPrintf (
"A not present\n") ;
68 mexPrintf (
"p not present\n") ;
74 mexPrintf (
"column %d, p[col] %d, p [col+1] %d, length %d\n",
76 for (k =
p [
col] ; k <
p [
col+1] ; k++)
79 mexPrintf (
" %d",
row) ;
96 const mxArray *pargin [ ]
122 if (nargin != 3 || nargout > 2)
125 "csymamdtest: incorrect number of input and/or output arguments.") ;
128 if (mxGetNumberOfElements (pargin [1]) != 4)
130 mexErrMsgTxt (
"csymamdtest: must have 4 knobs for testing") ;
138 in_knobs = mxGetPr (pargin [1]) ;
140 i = mxGetNumberOfElements (pargin [1]) ;
144 spumoni = (in_knobs [2] != 0) ;
149 mexPrintf (
"\ncsymamd version %d.%d, %s:\n",
153 mexPrintf (
"knobs(1): %g, rows/cols with > "
154 "max(16,%g*sqrt(size(A,2))) entries removed\n",
159 mexPrintf (
"knobs(1): %g, no dense rows removed\n",
162 mexPrintf (
"knobs(2): %g, aggressive absorption: %s\n",
164 mexPrintf (
"knobs(3): %g, statistics and knobs printed\n",
166 mexPrintf (
"Testing: %g\n", in_knobs [3]) ;
171 Ainput = (mxArray *) pargin [0] ;
172 if (mxGetNumberOfDimensions (Ainput) != 2)
174 mexErrMsgTxt (
"csymamd: input matrix must be 2-dimensional.") ;
176 full = !mxIsSparse (Ainput) ;
179 mexCallMATLAB (1, &Ainput, 1, (mxArray **) pargin,
"sparse") ;
185 n_row = mxGetM (Ainput) ;
186 n_col = mxGetN (Ainput) ;
189 mexErrMsgTxt (
"csymamd: matrix must be square.") ;
193 p = (
Long *) mxCalloc (n_col+1,
sizeof (
Long)) ;
194 (void) memcpy (
p, mxGetJc (Ainput), (n_col+1)*
sizeof (
Long)) ;
199 mexPrintf (
"csymamdtest: nnz %d\n", nnz) ;
203 A = (
Long *) mxCalloc (nnz+1,
sizeof (
Long)) ;
204 (void) memcpy (
A, mxGetIr (Ainput), nnz*
sizeof (
Long)) ;
231 switch ((
Long) in_knobs [3])
237 mexPrintf (
"csymamdtest: no errors expected\n") ;
245 mexPrintf (
"csymamdtest: no errors expected (1)\n") ;
253 mexPrintf (
"csymamdtest: p [0] nonzero\n") ;
262 mexPrintf (
"csymamdtest: negative length last column\n") ;
271 mexPrintf (
"csymamdtest: no errors expected (4)\n") ;
279 mexPrintf (
"csymamdtest: row index out of range (-1)\n") ;
290 mexPrintf (
"Note: no row indices to put out of range\n") ;
299 mexPrintf (
"csymamdtest: row index out of range (ncol)\n") ;
310 mexPrintf (
"Note: no row indices to put out of range\n") ;
319 mexPrintf (
"csymamdtest: A not present\n") ;
328 mexPrintf (
"csymamdtest: p not present\n") ;
337 mexPrintf (
"csymamdtest: duplicate row index\n") ;
349 mexPrintf (
"Made duplicate row %d in col %d\n",
365 mexPrintf (
"csymamdtest: unsorted column\n") ;
379 mexPrintf (
"Unsorted column %d \n",
col) ;
394 mexPrintf (
"csymamdtest: massive jumbling\n") ;
398 for (
i = 0 ;
i < n_col ;
i++)
401 cp_end = &
A [
p [
i+1]] ;
404 *cp++ = rand() % n_row ;
416 mexPrintf (
"csymamdtest: stats not present\n") ;
425 mexPrintf (
"csymamdtest: ncol out of range\n") ;
440 mxDestroyArray (Ainput) ;
452 pargout [1] = mxCreateDoubleMatrix (1,
CCOLAMD_STATS, mxREAL) ;
453 out_stats = mxGetPr (pargout [1]) ;
471 pargout [0] = mxCreateDoubleMatrix (1, n_col, mxREAL) ;
472 out_perm = mxGetPr (pargout [0]) ;
473 for (
i = 0 ;
i < n_col ;
i++)
476 out_perm [
i] =
perm [
i] + 1 ;
481 mexErrMsgTxt (
"csymamd should have returned TRUE\n") ;
488 pargout [0] = mxCreateDoubleMatrix (1, 1, mxREAL) ;
489 out_perm = mxGetPr (pargout [0]) ;
494 mexErrMsgTxt (
"csymamd should have returned FALSE\n") ;