00001 #include "cs.h"
00002 
00003 css *cs_schol (int order, const cs *A)
00004 {
00005     int n, *c, *post, *P ;
00006     cs *C ;
00007     css *S ;
00008     if (!CS_CSC (A)) return (NULL) ;        
00009     n = A->n ;
00010     S = cs_calloc (1, sizeof (css)) ;       
00011     if (!S) return (NULL) ;                 
00012     P = cs_amd (order, A) ;                 
00013     S->pinv = cs_pinv (P, n) ;              
00014     cs_free (P) ;
00015     if (order && !S->pinv) return (cs_sfree (S)) ;
00016     C = cs_symperm (A, S->pinv, 0) ;        
00017     S->parent = cs_etree (C, 0) ;           
00018     post = cs_post (S->parent, n) ;         
00019     c = cs_counts (C, S->parent, post, 0) ; 
00020     cs_free (post) ;
00021     cs_spfree (C) ;
00022     S->cp = cs_malloc (n+1, sizeof (int)) ; 
00023     S->unz = S->lnz = cs_cumsum (S->cp, c, n) ; 
00024     cs_free (c) ;
00025     return ((S->lnz >= 0) ? S : cs_sfree (S)) ;
00026 }