$search
00001 #include "cs.h" 00002 /* find nonzero pattern of Cholesky L(k,1:k-1) using etree and triu(A(:,k)) */ 00003 int cs_ereach (const cs *A, int k, const int *parent, int *s, int *w) 00004 { 00005 int i, p, n, len, top, *Ap, *Ai ; 00006 if (!CS_CSC (A) || !parent || !s || !w) return (-1) ; /* check inputs */ 00007 top = n = A->n ; Ap = A->p ; Ai = A->i ; 00008 CS_MARK (w, k) ; /* mark node k as visited */ 00009 for (p = Ap [k] ; p < Ap [k+1] ; p++) 00010 { 00011 i = Ai [p] ; /* A(i,k) is nonzero */ 00012 if (i > k) continue ; /* only use upper triangular part of A */ 00013 for (len = 0 ; !CS_MARKED (w,i) ; i = parent [i]) /* traverse up etree*/ 00014 { 00015 s [len++] = i ; /* L(k,i) is nonzero */ 00016 CS_MARK (w, i) ; /* mark i as visited */ 00017 } 00018 while (len > 0) s [--top] = s [--len] ; /* push path onto stack */ 00019 } 00020 for (p = top ; p < n ; p++) CS_MARK (w, s [p]) ; /* unmark all nodes */ 00021 CS_MARK (w, k) ; /* unmark node k */ 00022 return (top) ; /* s [top..n-1] contains pattern of L(k,:)*/ 00023 }