3 #define HEAD(k,j) (ata ? head [k] : j)
4 #define NEXT(J) (ata ? next [J] : -1)
7 CS_INT i, k, p, m = AT->n, n = AT->m, *ATp = AT->p, *ATi = AT->i ;
8 *head = w+4*n, *next = w+5*n+1 ;
9 for (k = 0 ; k < n ; k++) w [post [k]] = k ;
10 for (i = 0 ; i < m ; i++)
12 for (k = n, p = ATp[i] ; p < ATp[i+1] ; p++) k =
CS_MIN (k, w [ATi[p]]);
13 (*next) [i] = (*head) [k] ;
19 CS_INT i, j, k, n, m, J, s, p, q, jleaf, *ATp, *ATi, *maxfirst, *prevleaf,
20 *ancestor, *head = NULL, *next = NULL, *colcount, *w, *first, *delta ;
22 if (!
CS_CSC (A) || !parent || !post)
return (NULL) ;
24 s = 4*n + (ata ? (n+m+1) : 0) ;
28 if (!AT || !colcount || !w)
return (
cs_idone (colcount, AT, w, 0)) ;
29 ancestor = w ; maxfirst = w+n ; prevleaf = w+2*n ; first = w+3*n ;
30 for (k = 0 ; k < s ; k++) w [k] = -1 ;
31 for (k = 0 ; k < n ; k++)
34 delta [j] = (first [j] == -1) ? 1 : 0 ;
35 for ( ; j != -1 && first [j] == -1 ; j = parent [j]) first [j] = k ;
37 ATp = AT->p ; ATi = AT->i ;
38 if (ata) init_ata (AT, post, w, &head, &next) ;
39 for (i = 0 ; i < n ; i++) ancestor [i] = i ;
40 for (k = 0 ; k < n ; k++)
43 if (parent [j] != -1) delta [parent [j]]-- ;
44 for (J =
HEAD (k,j) ; J != -1 ; J =
NEXT (J))
46 for (p = ATp [J] ; p < ATp [J+1] ; p++)
49 q =
cs_leaf (i, j, first, maxfirst, prevleaf, ancestor, &jleaf);
50 if (jleaf >= 1) delta [j]++ ;
51 if (jleaf == 2) delta [q]-- ;
54 if (parent [j] != -1) ancestor [j] = parent [j] ;
56 for (j = 0 ; j < n ; j++)
58 if (parent [j] != -1) colcount [parent [j]] += colcount [j] ;
60 return (
cs_idone (colcount, AT, w, 1)) ;
CS_INT cs_leaf(CS_INT i, CS_INT j, const CS_INT *first, CS_INT *maxfirst, CS_INT *prevleaf, CS_INT *ancestor, CS_INT *jleaf)
cs * cs_transpose(const cs *A, CS_INT values)
CS_INT * cs_counts(const cs *A, const CS_INT *parent, const CS_INT *post, CS_INT ata)
void * cs_malloc(CS_INT n, size_t size)
CS_INT * cs_idone(CS_INT *p, cs *C, void *w, CS_INT ok)