EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
cs_leaf.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* consider A(i,j), node j in ith row subtree and return lca(jprev,j) */
3 CS_INT cs_leaf (CS_INT i, CS_INT j, const CS_INT *first, CS_INT *maxfirst, CS_INT *prevleaf,
4  CS_INT *ancestor, CS_INT *jleaf)
5 {
6  CS_INT q, s, sparent, jprev ;
7  if (!first || !maxfirst || !prevleaf || !ancestor || !jleaf) return (-1) ;
8  *jleaf = 0 ;
9  if (i <= j || first [j] <= maxfirst [i]) return (-1) ; /* j not a leaf */
10  maxfirst [i] = first [j] ; /* update max first[j] seen so far */
11  jprev = prevleaf [i] ; /* jprev = previous leaf of ith subtree */
12  prevleaf [i] = j ;
13  *jleaf = (jprev == -1) ? 1: 2 ; /* j is first or subsequent leaf */
14  if (*jleaf == 1) return (i) ; /* if 1st leaf, q = root of ith subtree */
15  for (q = jprev ; q != ancestor [q] ; q = ancestor [q]) ;
16  for (s = jprev ; s != q ; s = sparent)
17  {
18  sparent = ancestor [s] ; /* path compression */
19  ancestor [s] = q ;
20  }
21  return (q) ; /* q = least common ancester (jprev,j) */
22 }
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)
Definition: cs_leaf.c:3
#define CS_INT
Definition: cs.h:627