EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cs_ereach.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* find nonzero pattern of Cholesky L(k,1:k-1) using etree and triu(A(:,k)) */
3 CS_INT cs_ereach (const cs *A, CS_INT k, const CS_INT *parent, CS_INT *s, CS_INT *w)
4 {
5  CS_INT i, p, n, len, top, *Ap, *Ai ;
6  if (!CS_CSC (A) || !parent || !s || !w) return (-1) ; /* check inputs */
7  top = n = A->n ; Ap = A->p ; Ai = A->i ;
8  CS_MARK (w, k) ; /* mark node k as visited */
9  for (p = Ap [k] ; p < Ap [k+1] ; p++)
10  {
11  i = Ai [p] ; /* A(i,k) is nonzero */
12  if (i > k) continue ; /* only use upper triangular part of A */
13  for (len = 0 ; !CS_MARKED (w,i) ; i = parent [i]) /* traverse up etree*/
14  {
15  s [len++] = i ; /* L(k,i) is nonzero */
16  CS_MARK (w, i) ; /* mark i as visited */
17  }
18  while (len > 0) s [--top] = s [--len] ; /* push path onto stack */
19  }
20  for (p = top ; p < n ; p++) CS_MARK (w, s [p]) ; /* unmark all nodes */
21  CS_MARK (w, k) ; /* unmark node k */
22  return (top) ; /* s [top..n-1] contains pattern of L(k,:)*/
23 }
#define CS_MARKED(w, j)
Definition: cs.h:657
#define cs
Definition: cs.h:637
#define CS_MARK(w, j)
Definition: cs.h:658
#define CS_CSC(A)
Definition: cs.h:659
CS_INT cs_ereach(const cs *A, CS_INT k, const CS_INT *parent, CS_INT *s, CS_INT *w)
Definition: cs_ereach.c:3
#define CS_INT
Definition: cs.h:627