kusano 7d535a
kusano 7d535a
/*! @file slu_ddefs.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_dSP_DEFS /* allow multiple inclusions */
kusano 7d535a
#define __SUPERLU_dSP_DEFS
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * File name:		dsp_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
    double  *lusup;   /* L supernodes */
kusano 7d535a
    int     *xlusup;
kusano 7d535a
    double  *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
dgssv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
dgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
kusano 7d535a
       char *, double *, double *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       void *, int, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       double *, double *, double *, double *,
kusano 7d535a
       mem_usage_t *, SuperLUStat_t *, int *);
kusano 7d535a
    /* ILU */
kusano 7d535a
extern void
kusano 7d535a
dgsisv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
dgsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
kusano 7d535a
       char *, double *, double *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
       void *, int, SuperMatrix *, SuperMatrix *, double *, double *,
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
dCreate_CompCol_Matrix(SuperMatrix *, int, int, int, double *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
dCreate_CompRow_Matrix(SuperMatrix *, int, int, int, double *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
dCopy_CompCol_Matrix(SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void
kusano 7d535a
dCreate_Dense_Matrix(SuperMatrix *, int, int, double *, int,
kusano 7d535a
		     Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
dCreate_SuperNode_Matrix(SuperMatrix *, int, int, int, double *, 
kusano 7d535a
		         int *, int *, int *, int *, int *,
kusano 7d535a
			 Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
dCopy_Dense_Matrix(int, int, double *, int, double *, 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    dallocateA (int, int, double **, int **, int **);
kusano 7d535a
extern void    dgstrf (superlu_options_t*, SuperMatrix*,
kusano 7d535a
                       int, int, int*, void *, int, int *, int *, 
kusano 7d535a
                       SuperMatrix *, SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     dsnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			     const int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     dsnode_bmod (const int, const int, const int, double *,
kusano 7d535a
                              double *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    dpanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			   int *, int *, double *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    dpanel_bmod (const int, const int, const int, const int,
kusano 7d535a
                           double *, double *, int *, int *,
kusano 7d535a
			   GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     dcolumn_dfs (const int, const int, int *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     dcolumn_bmod (const int, const int, double *,
kusano 7d535a
			   double *, int *, int *, int,
kusano 7d535a
                           GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     dcopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                              double *, GlobalLU_t *);         
kusano 7d535a
extern int     dpivotL (const int, const double, int *, int *, 
kusano 7d535a
                         int *, int *, int *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    dpruneL (const int, const int *, const int, const int,
kusano 7d535a
			  const int *, const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    dreadmt (int *, int *, int *, double **, int **, int **);
kusano 7d535a
extern void    dGenXtrue (int, int, double *, int);
kusano 7d535a
extern void    dFillRHS (trans_t, int, double *, int, SuperMatrix *,
kusano 7d535a
			  SuperMatrix *);
kusano 7d535a
extern void    dgstrs (trans_t, SuperMatrix *, SuperMatrix *, int *, int *,
kusano 7d535a
                        SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
/* ILU */
kusano 7d535a
extern void    dgsitrf (superlu_options_t*, SuperMatrix*, int, int, int*,
kusano 7d535a
		        void *, int, int *, int *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                        SuperLUStat_t*, int *);
kusano 7d535a
extern int     dldperm(int, int, int, int [], int [], double [],
kusano 7d535a
                        int [],	double [], double []);
kusano 7d535a
extern int     ilu_dsnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			       const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    ilu_dpanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			       int *, int *, double *, double *, int *, int *,
kusano 7d535a
			       int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     ilu_dcolumn_dfs (const int, const int, int *, int *, int *,
kusano 7d535a
				int *, int *, int *, int *, int *,
kusano 7d535a
				GlobalLU_t *);
kusano 7d535a
extern int     ilu_dcopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                                  double *, int, milu_t, double, int,
kusano 7d535a
                                  double *, int *, GlobalLU_t *, double *);
kusano 7d535a
extern int     ilu_dpivotL (const int, const double, int *, int *, int, int *,
kusano 7d535a
			    int *, int *, int *, double, milu_t,
kusano 7d535a
                            double, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     ilu_ddrop_row (superlu_options_t *, int, int, double,
kusano 7d535a
                              int, int *, double *, GlobalLU_t *, 
kusano 7d535a
                              double *, double *, int);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Driver related */
kusano 7d535a
kusano 7d535a
extern void    dgsequ (SuperMatrix *, double *, double *, double *,
kusano 7d535a
			double *, double *, int *);
kusano 7d535a
extern void    dlaqgs (SuperMatrix *, double *, double *, double,
kusano 7d535a
                        double, double, char *);
kusano 7d535a
extern void    dgscon (char *, SuperMatrix *, SuperMatrix *, 
kusano 7d535a
		         double, double *, SuperLUStat_t*, int *);
kusano 7d535a
extern double   dPivotGrowth(int, SuperMatrix *, int *, 
kusano 7d535a
                            SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void    dgsrfs (trans_t, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                       SuperMatrix *, int *, int *, char *, double *, 
kusano 7d535a
                       double *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                       double *, double *, SuperLUStat_t*, int *);
kusano 7d535a
kusano 7d535a
extern int     sp_dtrsv (char *, char *, char *, SuperMatrix *,
kusano 7d535a
			SuperMatrix *, double *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     sp_dgemv (char *, double, SuperMatrix *, double *,
kusano 7d535a
			int, double, double *, int);
kusano 7d535a
kusano 7d535a
extern int     sp_dgemm (char *, char *, int, int, int, double,
kusano 7d535a
			SuperMatrix *, double *, int, double, 
kusano 7d535a
			double *, int);
kusano 7d535a
extern         double dlamch_(char *);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Memory-related */
kusano 7d535a
extern int     dLUMemInit (fact_t, void *, int, int, int, int, int,
kusano 7d535a
                            double, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                            GlobalLU_t *, int **, double **);
kusano 7d535a
extern void    dSetRWork (int, int, double *, double **, double **);
kusano 7d535a
extern void    dLUWorkFree (int *, double *, GlobalLU_t *);
kusano 7d535a
extern int     dLUMemXpand (int, int, MemType, int *, GlobalLU_t *);
kusano 7d535a
kusano 7d535a
extern double  *doubleMalloc(int);
kusano 7d535a
extern double  *doubleCalloc(int);
kusano 7d535a
extern int     dmemory_usage(const int, const int, const int, const int);
kusano 7d535a
extern int     dQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
extern int     ilu_dQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
kusano 7d535a
/*! \brief Auxiliary routines */
kusano 7d535a
extern void    dreadhb(int *, int *, int *, double **, int **, int **);
kusano 7d535a
extern void    dreadrb(int *, int *, int *, double **, int **, int **);
kusano 7d535a
extern void    dreadtriple(int *, int *, int *, double **, int **, int **);
kusano 7d535a
extern void    dCompRow_to_CompCol(int, int, int, double*, int*, int*,
kusano 7d535a
		                   double **, int **, int **);
kusano 7d535a
extern void    dfill (double *, int, double);
kusano 7d535a
extern void    dinf_norm_error (int, SuperMatrix *, double *);
kusano 7d535a
extern void    PrintPerf (SuperMatrix *, SuperMatrix *, mem_usage_t *,
kusano 7d535a
			 double, double, double *, double *, char *);
kusano 7d535a
extern double  dqselect(int, double *, int);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Routines for debugging */
kusano 7d535a
extern void    dPrint_CompCol_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    dPrint_SuperNode_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    dPrint_Dense_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    dprint_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, double *);
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
  }
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* __SUPERLU_dSP_DEFS */
kusano 7d535a