kusano 7d535a
kusano 7d535a
/*! @file slu_zdefs.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_zSP_DEFS /* allow multiple inclusions */
kusano 7d535a
#define __SUPERLU_zSP_DEFS
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * File name:		zsp_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
#include "slu_dcomplex.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
    doublecomplex  *lusup;   /* L supernodes */
kusano 7d535a
    int     *xlusup;
kusano 7d535a
    doublecomplex  *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
zgssv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
zgssvx(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
zgsisv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
kusano 7d535a
      SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
kusano 7d535a
extern void
kusano 7d535a
zgsisx(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
zCreate_CompCol_Matrix(SuperMatrix *, int, int, int, doublecomplex *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
zCreate_CompRow_Matrix(SuperMatrix *, int, int, int, doublecomplex *,
kusano 7d535a
		       int *, int *, Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
zCopy_CompCol_Matrix(SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void
kusano 7d535a
zCreate_Dense_Matrix(SuperMatrix *, int, int, doublecomplex *, int,
kusano 7d535a
		     Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
zCreate_SuperNode_Matrix(SuperMatrix *, int, int, int, doublecomplex *, 
kusano 7d535a
		         int *, int *, int *, int *, int *,
kusano 7d535a
			 Stype_t, Dtype_t, Mtype_t);
kusano 7d535a
extern void
kusano 7d535a
zCopy_Dense_Matrix(int, int, doublecomplex *, int, doublecomplex *, 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    zallocateA (int, int, doublecomplex **, int **, int **);
kusano 7d535a
extern void    zgstrf (superlu_options_t*, SuperMatrix*,
kusano 7d535a
                       int, int, int*, void *, int, int *, int *, 
kusano 7d535a
                       SuperMatrix *, SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     zsnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			     const int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     zsnode_bmod (const int, const int, const int, doublecomplex *,
kusano 7d535a
                              doublecomplex *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    zpanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			   int *, int *, doublecomplex *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    zpanel_bmod (const int, const int, const int, const int,
kusano 7d535a
                           doublecomplex *, doublecomplex *, int *, int *,
kusano 7d535a
			   GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     zcolumn_dfs (const int, const int, int *, int *, int *, int *,
kusano 7d535a
			   int *, int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     zcolumn_bmod (const int, const int, doublecomplex *,
kusano 7d535a
			   doublecomplex *, int *, int *, int,
kusano 7d535a
                           GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     zcopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                              doublecomplex *, GlobalLU_t *);         
kusano 7d535a
extern int     zpivotL (const int, const double, int *, int *, 
kusano 7d535a
                         int *, int *, int *, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern void    zpruneL (const int, const int *, const int, const int,
kusano 7d535a
			  const int *, const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    zreadmt (int *, int *, int *, doublecomplex **, int **, int **);
kusano 7d535a
extern void    zGenXtrue (int, int, doublecomplex *, int);
kusano 7d535a
extern void    zFillRHS (trans_t, int, doublecomplex *, int, SuperMatrix *,
kusano 7d535a
			  SuperMatrix *);
kusano 7d535a
extern void    zgstrs (trans_t, SuperMatrix *, SuperMatrix *, int *, int *,
kusano 7d535a
                        SuperMatrix *, SuperLUStat_t*, int *);
kusano 7d535a
/* ILU */
kusano 7d535a
extern void    zgsitrf (superlu_options_t*, SuperMatrix*, int, int, int*,
kusano 7d535a
		        void *, int, int *, int *, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                        SuperLUStat_t*, int *);
kusano 7d535a
extern int     zldperm(int, int, int, int [], int [], doublecomplex [],
kusano 7d535a
                        int [],	double [], double []);
kusano 7d535a
extern int     ilu_zsnode_dfs (const int, const int, const int *, const int *,
kusano 7d535a
			       const int *, int *, GlobalLU_t *);
kusano 7d535a
extern void    ilu_zpanel_dfs (const int, const int, const int, SuperMatrix *,
kusano 7d535a
			       int *, int *, doublecomplex *, double *, int *, int *,
kusano 7d535a
			       int *, int *, int *, int *, GlobalLU_t *);
kusano 7d535a
extern int     ilu_zcolumn_dfs (const int, const int, int *, int *, int *,
kusano 7d535a
				int *, int *, int *, int *, int *,
kusano 7d535a
				GlobalLU_t *);
kusano 7d535a
extern int     ilu_zcopy_to_ucol (int, int, int *, int *, int *,
kusano 7d535a
                                  doublecomplex *, int, milu_t, double, int,
kusano 7d535a
                                  doublecomplex *, int *, GlobalLU_t *, double *);
kusano 7d535a
extern int     ilu_zpivotL (const int, const double, int *, int *, int, int *,
kusano 7d535a
			    int *, int *, int *, double, milu_t,
kusano 7d535a
                            doublecomplex, GlobalLU_t *, SuperLUStat_t*);
kusano 7d535a
extern int     ilu_zdrop_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    zgsequ (SuperMatrix *, double *, double *, double *,
kusano 7d535a
			double *, double *, int *);
kusano 7d535a
extern void    zlaqgs (SuperMatrix *, double *, double *, double,
kusano 7d535a
                        double, double, char *);
kusano 7d535a
extern void    zgscon (char *, SuperMatrix *, SuperMatrix *, 
kusano 7d535a
		         double, double *, SuperLUStat_t*, int *);
kusano 7d535a
extern double   zPivotGrowth(int, SuperMatrix *, int *, 
kusano 7d535a
                            SuperMatrix *, SuperMatrix *);
kusano 7d535a
extern void    zgsrfs (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_ztrsv (char *, char *, char *, SuperMatrix *,
kusano 7d535a
			SuperMatrix *, doublecomplex *, SuperLUStat_t*, int *);
kusano 7d535a
extern int     sp_zgemv (char *, doublecomplex, SuperMatrix *, doublecomplex *,
kusano 7d535a
			int, doublecomplex, doublecomplex *, int);
kusano 7d535a
kusano 7d535a
extern int     sp_zgemm (char *, char *, int, int, int, doublecomplex,
kusano 7d535a
			SuperMatrix *, doublecomplex *, int, doublecomplex, 
kusano 7d535a
			doublecomplex *, int);
kusano 7d535a
extern         double dlamch_(char *);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Memory-related */
kusano 7d535a
extern int     zLUMemInit (fact_t, void *, int, int, int, int, int,
kusano 7d535a
                            double, SuperMatrix *, SuperMatrix *,
kusano 7d535a
                            GlobalLU_t *, int **, doublecomplex **);
kusano 7d535a
extern void    zSetRWork (int, int, doublecomplex *, doublecomplex **, doublecomplex **);
kusano 7d535a
extern void    zLUWorkFree (int *, doublecomplex *, GlobalLU_t *);
kusano 7d535a
extern int     zLUMemXpand (int, int, MemType, int *, GlobalLU_t *);
kusano 7d535a
kusano 7d535a
extern doublecomplex  *doublecomplexMalloc(int);
kusano 7d535a
extern doublecomplex  *doublecomplexCalloc(int);
kusano 7d535a
extern double  *doubleMalloc(int);
kusano 7d535a
extern double  *doubleCalloc(int);
kusano 7d535a
extern int     zmemory_usage(const int, const int, const int, const int);
kusano 7d535a
extern int     zQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
extern int     ilu_zQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
kusano 7d535a
kusano 7d535a
/*! \brief Auxiliary routines */
kusano 7d535a
extern void    zreadhb(int *, int *, int *, doublecomplex **, int **, int **);
kusano 7d535a
extern void    zreadrb(int *, int *, int *, doublecomplex **, int **, int **);
kusano 7d535a
extern void    zreadtriple(int *, int *, int *, doublecomplex **, int **, int **);
kusano 7d535a
extern void    zCompRow_to_CompCol(int, int, int, doublecomplex*, int*, int*,
kusano 7d535a
		                   doublecomplex **, int **, int **);
kusano 7d535a
extern void    zfill (doublecomplex *, int, doublecomplex);
kusano 7d535a
extern void    zinf_norm_error (int, SuperMatrix *, doublecomplex *);
kusano 7d535a
extern void    PrintPerf (SuperMatrix *, SuperMatrix *, mem_usage_t *,
kusano 7d535a
			 doublecomplex, doublecomplex, doublecomplex *, doublecomplex *, char *);
kusano 7d535a
extern double  dqselect(int, double *, int);
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*! \brief Routines for debugging */
kusano 7d535a
extern void    zPrint_CompCol_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    zPrint_SuperNode_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    zPrint_Dense_Matrix(char *, SuperMatrix *);
kusano 7d535a
extern void    zprint_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, doublecomplex *);
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
  }
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* __SUPERLU_zSP_DEFS */
kusano 7d535a