public static int searchNzRowsElim( DMatrixSparseCSC A , int k , int parent[], int s[], int w[] ) {
        int top = A.numCols;

        // Traversing through the column in A is the same as the row in A since it's symmetric
        int idx0 = A.col_idx[k], idx1 = A.col_idx[k+1];

        w[k] = -w[k]-2;  // makr node k as visited
        for (int p = idx0; p < idx1; p++) {
            int i = A.nz_rows[p];   // A[k,i] is not zero

            if( i > k ) // only consider upper triangular part of A
                continue;

            // move up the elimination tree
            int len = 0;
            for(;w[i]>=0; i = parent[i]) {
                s[len++] = i; // L[k,i] is not zero
                w[i] = -w[i]-2; // mark i as being visited
            }
            while( len > 0 ) {
                s[--top] = s[--len];
            }
        }

        // unmark all nodes
        for( int p = top; p < A.numCols; p++ ) {
            w[s[p]] = -w[s[p]]-2;
        }
        w[k] = -w[k]-2;
        return top;
    }
public static int searchNzRowsElim ( DMatrixSparseCSC A , int k , int parent [ ] , int s [ ] , int w [ ] ) { int top = A . numCols ; int idx0 = A . col_idx [ k ] , idx1 = A . col_idx [ k + 1 ] ; w [ k ] = - w [ k ] - 2 ; for ( int p = idx0 ; p < idx1 ; p ++ ) { int i = A . nz_rows [ p ] ; if ( i > k ) continue ; int len = 0 ; for ( ; w [ i ] >= 0 ; i = parent [ i ] ) { s [ len ++ ] = i ; w [ i ] = - w [ i ] - 2 ; } while ( len > 0 ) { s [ -- top ] = s [ -- len ] ; } } for ( int p = top ; p < A . numCols ; p ++ ) { w [ s [ p ] ] = - w [ s [ p ] ] - 2 ; } w [ k ] = - w [ k ] - 2 ; return top ; }
<p>Given an elimination tree compute the non-zero elements in the specified row of L given the
symmetric A matrix.  This is in general much faster than general purpose algorithms</p>

<p>Functionally equivalent to cs_ereach() in csparse</p>

@param A Symmetric matrix.
@param k Row in A being processed.
@param parent elimination tree.
@param s (Output) s[top:(n-1)] = pattern of L[k,:].  Must have length A.numCols
@param w workspace array used internally.  All elements must be &ge; 0 on input. Must be of size A.numCols
@return Returns the index of the first element in the xi list.  Also known as top.