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") ;
72 for (col = 0 ; col <
MIN (n_col, limit) ; col++)
74 mexPrintf (
"column %d, p[col] %d, p [col+1] %d, length %d\n",
75 col, p [col], p [col+1], p [col+1] - p [col]) ;
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)) ;
206 perm = (
Long *) mxCalloc (n_col+1,
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") ;
264 result = (n_col == 0) ;
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") ;
341 for (col = 0 ; col < n_col ; col++)
343 length = p [col+1] - p [
col] ;
346 A [p [col+1]-2] = A [p [col+1] - 1] ;
349 mexPrintf (
"Made duplicate row %d in col %d\n",
350 A [p [col+1] - 1], col) ;
365 mexPrintf (
"csymamdtest: unsorted column\n") ;
369 for (col = 0 ; col < n_col ; col++)
371 length = p [col+1] - p [
col] ;
375 A [p [
col]] = A[p [
col] + 1] ;
376 A [p [
col] + 1] =
i ;
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") ;
435 ok =
csymamd_l (n_col, A, p, perm, knobs, stats, &mxCalloc, &mxFree,
440 mxDestroyArray (Ainput) ;
452 pargout [1] = mxCreateDoubleMatrix (1,
CCOLAMD_STATS, mxREAL) ;
453 out_stats = mxGetPr (pargout [1]) ;
456 out_stats [
i] = (stats ==
NULL) ? (-1) : (stats [
i]) ;
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") ;
#define CCOLAMD_SUB_VERSION
void csymamd_l_report(SuiteSparse_long stats[CCOLAMD_STATS])
#define CCOLAMD_DENSE_ROW
SuiteSparse_long csymamd_l(SuiteSparse_long n, SuiteSparse_long A[], SuiteSparse_long p[], SuiteSparse_long perm[], double knobs[CCOLAMD_KNOBS], SuiteSparse_long stats[CCOLAMD_STATS], void *(*allocate)(size_t, size_t), void(*release)(void *), SuiteSparse_long cmember[], SuiteSparse_long stype)
#define CCOLAMD_MAIN_VERSION
Matrix< SCALARA, Dynamic, Dynamic > A
void ccolamd_l_set_defaults(double knobs[CCOLAMD_KNOBS])
void mexFunction(int nargout, mxArray *pargout[], int nargin, const mxArray *pargin[])
idx_t idx_t idx_t idx_t idx_t * perm
#define CCOLAMD_DENSE_COL
static void dump_matrix(Long A[], Long p[], Long n_row, Long n_col, Long Alen, Long limit)
#define CCOLAMD_AGGRESSIVE