kusano 7d535a
kusano 7d535a
/*! @file slu_sdefs.h
kusano 7d535a
 * \brief Header file for real operations
kusano 7d535a
 * 
kusano 7d535a
 * 
 
kusano 7d535a
 * -- SuperLU routine (version 4.1) --
kusano 7d535a
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
kusano 7d535a
 * and Lawrence Berkeley National Lab.
kusano 7d535a
 * November, 2010
kusano 7d535a
 * 
kusano 7d535a
 * Global data structures used in LU factorization -
kusano 7d535a
 * 
kusano 7d535a
 *   nsuper: #supernodes = nsuper + 1, numbered [0, nsuper].
kusano 7d535a
 *   (xsup,supno): supno[i] is the supernode no to which i belongs;
kusano 7d535a
 *	xsup(s) points to the beginning of the s-th supernode.
kusano 7d535a
 *	e.g.   supno 0 1 2 2 3 3 3 4 4 4 4 4   (n=12)
kusano 7d535a
 *	        xsup 0 1 2 4 7 12
kusano 7d535a
 *	Note: dfs will be performed on supernode rep. relative to the new 
kusano 7d535a
 *	      row pivoting ordering
kusano 7d535a
 *
kusano 7d535a
 *   (xlsub,lsub): lsub[*] contains the compressed subscript of
kusano 7d535a
 *	rectangular supernodes; xlsub[j] points to the starting
kusano 7d535a
 *	location of the j-th column in lsub[*]. Note that xlsub 
kusano 7d535a
 *	is indexed by column.
kusano 7d535a
 *	Storage: original row subscripts
kusano 7d535a
 *
kusano 7d535a
 *      During the course of sparse LU factorization, we also use
kusano 7d535a
 *	(xlsub,lsub) for the purpose of symmetric pruning. For each
kusano 7d535a
 *	supernode {s,s+1,...,t=s+r} with first column s and last
kusano 7d535a
 *	column t, the subscript set
kusano 7d535a
 *		lsub[j], j=xlsub[s], .., xlsub[s+1]-1
kusano 7d535a
 *	is the structure of column s (i.e. structure of this supernode).
kusano 7d535a
 *	It is used for the storage of numerical values.
kusano 7d535a
 *	Furthermore,
kusano 7d535a
 *		lsub[j], j=xlsub[t], .., xlsub[t+1]-1
kusano 7d535a
 *	is the structure of the last column t of this supernode.
kusano 7d535a
 *	It is for the purpose of symmetric pruning. Therefore, the
kusano 7d535a
 *	structural subscripts can be rearranged without making physical
kusano 7d535a
 *	interchanges among the numerical values.
kusano 7d535a
 *
kusano 7d535a
 *	However, if the supernode has only one column, then we
kusano 7d535a
 *	only keep one set of subscripts. For any subscript interchange
kusano 7d535a
 *	performed, similar interchange must be done on the numerical
kusano 7d535a
 *	values.
kusano 7d535a
 *
kusano 7d535a
 *	The last column structures (for pruning) will be removed
kusano 7d535a
 *	after the numercial LU factorization phase.
kusano 7d535a
 *
kusano 7d535a
 *   (xlusup,lusup): lusup[*] contains the numerical values of the
kusano 7d535a
 *	rectangular supernodes; xlusup[j] points to the starting
kusano 7d535a
 *	location of the j-th column in storage vector lusup[*]
kusano 7d535a
 *	Note: xlusup is indexed by column.
kusano 7d535a
 *	Each rectangular supernode is stored by column-major
kusano 7d535a
 *	scheme, consistent with Fortran 2-dim array storage.
kusano 7d535a
 *
kusano 7d535a
 *   (xusub,ucol,usub): ucol[*] stores the numerical values of
kusano 7d535a
 *	U-columns outside the rectangular supernodes. The row
kusano 7d535a
 *	subscript of nonzero ucol[k] is stored in usub[k].
kusano 7d535a
 *	xusub[i] points to the starting location of column i in ucol.
kusano 7d535a
 *	Storage: new row subscripts; that is subscripts of PA.
kusano 7d535a
 * 
kusano 7d535a
 */
kusano 7d535a
#ifndef __SUPERLU_sSP_DEFS /* allow multiple inclusions */
kusano 7d535a
#define __SUPERLU_sSP_DEFS
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * File name:		ssp_defs.h
kusano 7d535a
 * Purpose:             Sparse matrix types and function prototypes
kusano 7d535a
 * History:
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef _CRAY
kusano 7d535a
#include <fortran.h></fortran.h>
kusano 7d535a
#include <string.h></string.h>
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/* Define my integer type int_t */
kusano 7d535a
typedef int int_t; /* default */
kusano 7d535a
kusano 7d535a
#include <math.h></math.h>
kusano 7d535a
#include <limits.h></limits.h>
kusano 7d535a
#include "slu_Cnames.h"
kusano 7d535a
#include "supermatrix.h"
kusano 7d535a
#include "slu_util.h"
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
typedef struct {
kusano 7d535a
    int     *xsup;    /* supernode and column mapping */
kusano 7d535a
    int     *supno;   
kusano 7d535a
    int     *lsub;    /* compressed L subscripts */
kusano 7d535a
    int	    *xlsub;
kusano 7d535a
    float  *lusup;   /* L supernodes */
kusano 7d535a
    int     *xlusup;
kusano 7d535a
    float  *ucol;    /* U columns */
kusano 7d535a
    int     *usub;
kusano 7d535a
    int	    *xusub;
kusano 7d535a
    int     nzlmax;   /* current max size of lsub */
kusano 7d535a
    int     nzumax;   /*    "    "    "      ucol */
kusano 7d535a
    int     nzlumax;  /*    "    "    "     lusup */
kusano 7d535a
    int     n;        /* number of columns in the matrix */
kusano 7d535a
    LU_space_t MemModel; /* 0 - system malloc'd; 1 - user provided */
kusano 7d535a
    int     num_expansions;
kusano 7d535a
    ExpHeader *expanders; /* Array of pointers to 4 types of memory */
kusano 7d535a
    LU_stack_t stack;     /* use user supplied memory */
kusano 7d535a
} GlobalLU_t;
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* -------- Prototypes -------- */
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
extern "C" {
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/*! \brief Driver routines */
kusano 7d535a
extern void
kusano 7d535a
sgssv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
sgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
kusano 7d535a
       char *, float *, float *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       void *, int, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       float *, float *, float *, float *,
kusano 7d535a
       mem_usage_t *, SuperLUStat_t *, int *);
kusano 7d535a
    /* ILU */
kusano 7d535a
extern void
kusano 7d535a
sgsisv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
sgsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
kusano 7d535a
       char *, float *, float *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       void *, int, SuperMatrix *, SuperMatrix *, float *, float *,
kusano 7d535a
       mem_usage_t *, SuperLUStat_t *, int *);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Supernodal LU factor related */
kusano 7d535a
extern void
kusano 7d535a
sCreate_CompCol_Matrix(SuperMatrix *, int, int, int, float *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
sCreate_CompRow_Matrix(SuperMatrix *, int, int, int, float *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
sCopy_CompCol_Matrix(SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void
kusano 7d535a
sCreate_Dense_Matrix(SuperMatrix *, int, int, float *, int,
kusano 7d535a
		     Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
sCreate_SuperNode_Matrix(SuperMatrix *, int, int, int, float *, 
kusano 7d535a
		         int *, int *, int *, int *, int *,
kusano 7d535a
			 Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
sCopy_Dense_Matrix(int, int, float *, int, float *, int);
kusano 7d535a
kusano 7d535a
extern void    countnz (const int, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    ilu_countnz (const int, int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    fixupL (const int, const int *, GlobalLU_t *);
kusano 7d535a
kusano 7d535a
extern void    sallocateA (int, int, float **, int **, int **);
kusano 7d535a
extern void    sgstrf (superlu_options_t*, SuperMatrix*,
kusano 7d535a
                       int, int, int*, void *, int, int *, int *, 
kusano 7d535a
                       SuperMatrix *, SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     ssnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			     const int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     ssnode_bmod (const int, const int, const int, float *,
kusano 7d535a
                              float *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    spanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			   int *, int *, float *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    spanel_bmod (const int, const int, const int, const int,
kusano 7d535a
                           float *, float *, int *, int *,
kusano 7d535a
			   GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     scolumn_dfs (const int, const int, int *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     scolumn_bmod (const int, const int, float *,
kusano 7d535a
			   float *, int *, int *, int,
kusano 7d535a
                           GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     scopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                              float *, GlobalLU_t *);         
kusano 7d535a
extern int     spivotL (const int, const double, int *, int *, 
kusano 7d535a
                         int *, int *, int *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    spruneL (const int, const int *, const int, const int,
kusano 7d535a
			  const int *, const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    sreadmt (int *, int *, int *, float **, int **, int **);
kusano 7d535a
extern void    sGenXtrue (int, int, float *, int);
kusano 7d535a
extern void    sFillRHS (trans_t, int, float *, int, SuperMatrix *,
kusano 7d535a
			  SuperMatrix *);
kusano 7d535a
extern void    sgstrs (trans_t, SuperMatrix *, SuperMatrix *, int *, int *,
kusano 7d535a
                        SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
/* ILU */
kusano 7d535a
extern void    sgsitrf (superlu_options_t*, SuperMatrix*, int, int, int*,
kusano 7d535a
		        void *, int, int *, int *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                        SuperLUStat_t*, int *);
kusano 7d535a
extern int     sldperm(int, int, int, int [], int [], float [],
kusano 7d535a
                        int [],	float [], float []);
kusano 7d535a
extern int     ilu_ssnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			       const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    ilu_spanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			       int *, int *, float *, float *, int *, int *,
kusano 7d535a
			       int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     ilu_scolumn_dfs (const int, const int, int *, int *, int *,
kusano 7d535a
				int *, int *, int *, int *, int *,
kusano 7d535a
				GlobalLU_t *);
kusano 7d535a
extern int     ilu_scopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                                  float *, int, milu_t, double, int,
kusano 7d535a
                                  float *, int *, GlobalLU_t *, float *);
kusano 7d535a
extern int     ilu_spivotL (const int, const double, int *, int *, int, int *,
kusano 7d535a
			    int *, int *, int *, double, milu_t,
kusano 7d535a
                            float, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     ilu_sdrop_row (superlu_options_t *, int, int, double,
kusano 7d535a
                              int, int *, double *, GlobalLU_t *, 
kusano 7d535a
                              float *, float *, int);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Driver related */
kusano 7d535a
kusano 7d535a
extern void    sgsequ (SuperMatrix *, float *, float *, float *,
kusano 7d535a
			float *, float *, int *);
kusano 7d535a
extern void    slaqgs (SuperMatrix *, float *, float *, float,
kusano 7d535a
                        float, float, char *);
kusano 7d535a
extern void    sgscon (char *, SuperMatrix *, SuperMatrix *, 
kusano 7d535a
		         float, float *, SuperLUStat_t*, int *);
kusano 7d535a
extern float   sPivotGrowth(int, SuperMatrix *, int *, 
kusano 7d535a
                            SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void    sgsrfs (trans_t, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                       SuperMatrix *, int *, int *, char *, float *, 
kusano 7d535a
                       float *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                       float *, float *, SuperLUStat_t*, int *);
kusano 7d535a
kusano 7d535a
extern int     sp_strsv (char *, char *, char *, SuperMatrix *,
kusano 7d535a
			SuperMatrix *, float *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     sp_sgemv (char *, float, SuperMatrix *, float *,
kusano 7d535a
			int, float, float *, int);
kusano 7d535a
kusano 7d535a
extern int     sp_sgemm (char *, char *, int, int, int, float,
kusano 7d535a
			SuperMatrix *, float *, int, float, 
kusano 7d535a
			float *, int);
kusano 7d535a
extern         float slamch_(char *);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Memory-related */
kusano 7d535a
extern int     sLUMemInit (fact_t, void *, int, int, int, int, int,
kusano 7d535a
                            float, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                            GlobalLU_t *, int **, float **);
kusano 7d535a
extern void    sSetRWork (int, int, float *, float **, float **);
kusano 7d535a
extern void    sLUWorkFree (int *, float *, GlobalLU_t *);
kusano 7d535a
extern int     sLUMemXpand (int, int, MemType, int *, GlobalLU_t *);
kusano 7d535a
kusano 7d535a
extern float  *floatMalloc(int);
kusano 7d535a
extern float  *floatCalloc(int);
kusano 7d535a
extern int     smemory_usage(const int, const int, const int, const int);
kusano 7d535a
extern int     sQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
extern int     ilu_sQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
kusano 7d535a
/*! \brief Auxiliary routines */
kusano 7d535a
extern void    sreadhb(int *, int *, int *, float **, int **, int **);
kusano 7d535a
extern void    sreadrb(int *, int *, int *, float **, int **, int **);
kusano 7d535a
extern void    sreadtriple(int *, int *, int *, float **, int **, int **);
kusano 7d535a
extern void    sCompRow_to_CompCol(int, int, int, float*, int*, int*,
kusano 7d535a
		                   float **, int **, int **);
kusano 7d535a
extern void    sfill (float *, int, float);
kusano 7d535a
extern void    sinf_norm_error (int, SuperMatrix *, float *);
kusano 7d535a
extern void    PrintPerf (SuperMatrix *, SuperMatrix *, mem_usage_t *,
kusano 7d535a
			 float, float, float *, float *, char *);
kusano 7d535a
extern float  sqselect(int, float *, int);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Routines for debugging */
kusano 7d535a
extern void    sPrint_CompCol_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    sPrint_SuperNode_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    sPrint_Dense_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    sprint_lu_col(char *, int, int, int *, GlobalLU_t *);
kusano 7d535a
extern int     print_double_vec(char *, int, double *);
kusano 7d535a
extern void    check_tempv(int, float *);
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
  }
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* __SUPERLU_sSP_DEFS */
kusano 7d535a