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 int cs_ereach (const cs *A, int k, const int *parent, int *s, int *w)
4 {
5  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:138
#define CS_MARK(w, j)
Definition: cs.h:139
int n
Definition: cs.h:20
int cs_ereach(const cs *A, int k, const int *parent, int *s, int *w)
Definition: cs_ereach.c:3
#define CS_CSC(A)
Definition: cs.h:140
int * p
Definition: cs.h:21
Definition: cs.h:16
int * i
Definition: cs.h:22


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31