kusano 7d535a
kusano 7d535a
/*! @file ilu_csnode_dfs.c
kusano 7d535a
 * \brief Determines the union of row structures of columns within the relaxed node
kusano 7d535a
 *
kusano 7d535a
 * 
kusano 7d535a
 * -- SuperLU routine (version 4.0) --
kusano 7d535a
 * Lawrence Berkeley National Laboratory
kusano 7d535a
 * June 30, 2009
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#include "slu_cdefs.h"
kusano 7d535a
kusano 7d535a
/*! \brief
kusano 7d535a
 *
kusano 7d535a
 * 
kusano 7d535a
 * Purpose
kusano 7d535a
 * =======
kusano 7d535a
 *    ilu_csnode_dfs() - Determine the union of the row structures of those
kusano 7d535a
 *    columns within the relaxed snode.
kusano 7d535a
 *    Note: The relaxed snodes are leaves of the supernodal etree, therefore,
kusano 7d535a
 *    the portion outside the rectangular supernode must be zero.
kusano 7d535a
 *
kusano 7d535a
 * Return value
kusano 7d535a
 * ============
kusano 7d535a
 *     0   success;
kusano 7d535a
 *    >0   number of bytes allocated when run out of memory.
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
int
kusano 7d535a
ilu_csnode_dfs(
kusano 7d535a
	   const int  jcol,	    /* in - start of the supernode */
kusano 7d535a
	   const int  kcol,	    /* in - end of the supernode */
kusano 7d535a
	   const int  *asub,	    /* in */
kusano 7d535a
	   const int  *xa_begin,    /* in */
kusano 7d535a
	   const int  *xa_end,	    /* in */
kusano 7d535a
	   int	      *marker,	    /* modified */
kusano 7d535a
	   GlobalLU_t *Glu	    /* modified */
kusano 7d535a
	   )
kusano 7d535a
{
kusano 7d535a
kusano 7d535a
    register int i, k, nextl;
kusano 7d535a
    int 	 nsuper, krow, kmark, mem_error;
kusano 7d535a
    int 	 *xsup, *supno;
kusano 7d535a
    int 	 *lsub, *xlsub;
kusano 7d535a
    int 	 nzlmax;
kusano 7d535a
kusano 7d535a
    xsup    = Glu->xsup;
kusano 7d535a
    supno   = Glu->supno;
kusano 7d535a
    lsub    = Glu->lsub;
kusano 7d535a
    xlsub   = Glu->xlsub;
kusano 7d535a
    nzlmax  = Glu->nzlmax;
kusano 7d535a
kusano 7d535a
    nsuper = ++supno[jcol];	/* Next available supernode number */
kusano 7d535a
    nextl = xlsub[jcol];
kusano 7d535a
kusano 7d535a
    for (i = jcol; i <= kcol; i++)
kusano 7d535a
    {
kusano 7d535a
	/* For each nonzero in A[*,i] */
kusano 7d535a
	for (k = xa_begin[i]; k < xa_end[i]; k++)
kusano 7d535a
	{
kusano 7d535a
	    krow = asub[k];
kusano 7d535a
	    kmark = marker[krow];
kusano 7d535a
	    if ( kmark != kcol )
kusano 7d535a
	    { /* First time visit krow */
kusano 7d535a
		marker[krow] = kcol;
kusano 7d535a
		lsub[nextl++] = krow;
kusano 7d535a
		if ( nextl >= nzlmax )
kusano 7d535a
		{
kusano 7d535a
		    if ( (mem_error = cLUMemXpand(jcol, nextl, LSUB, &nzlmax,
kusano 7d535a
			    Glu)) != 0)
kusano 7d535a
			return (mem_error);
kusano 7d535a
		    lsub = Glu->lsub;
kusano 7d535a
		}
kusano 7d535a
	    }
kusano 7d535a
	}
kusano 7d535a
	supno[i] = nsuper;
kusano 7d535a
    }
kusano 7d535a
kusano 7d535a
    /* Supernode > 1 */
kusano 7d535a
    if ( jcol < kcol )
kusano 7d535a
	for (i = jcol+1; i <= kcol; i++) xlsub[i] = nextl;
kusano 7d535a
kusano 7d535a
    xsup[nsuper+1] = kcol + 1;
kusano 7d535a
    supno[kcol+1]  = nsuper;
kusano 7d535a
    xlsub[kcol+1]  = nextl;
kusano 7d535a
kusano 7d535a
    return 0;
kusano 7d535a
}