Blender V2.61 - r43446

util.h

Go to the documentation of this file.
00001 
00004 #ifndef __SUPERLU_UTIL /* allow multiple inclusions */
00005 #define __SUPERLU_UTIL
00006 
00007 #include <stdio.h>
00008 #include <stdlib.h>
00009 #include <string.h>
00010 /*
00011 #ifndef __STDC__
00012 #include <malloc.h>
00013 #endif
00014 */
00015 #include <assert.h>
00016 
00017 /***********************************************************************
00018  * Macros
00019  ***********************************************************************/
00020 #define FIRSTCOL_OF_SNODE(i)    (xsup[i])
00021 /* No of marker arrays used in the symbolic factorization,
00022    each of size n */
00023 #define NO_MARKER     3
00024 #define NUM_TEMPV(m,w,t,b)  ( SUPERLU_MAX(m, (t + b)*w) )
00025 
00026 #ifndef USER_ABORT
00027 #define USER_ABORT(msg) \
00028  {  fprintf(stderr, "%s", msg); exit (-1); }
00029 #endif
00030 
00031 #define ABORT(err_msg) \
00032  { char msg[256];\
00033    sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
00034    USER_ABORT(msg); }
00035 
00036 
00037 #ifndef USER_MALLOC
00038 #if 1
00039 #define USER_MALLOC(size) superlu_malloc(size)
00040 #else
00041 /* The following may check out some uninitialized data */
00042 #define USER_MALLOC(size) memset (superlu_malloc(size), '\x0F', size)
00043 #endif
00044 #endif
00045 
00046 #define SUPERLU_MALLOC(size) USER_MALLOC(size)
00047 
00048 #ifndef USER_FREE
00049 #define USER_FREE(addr) superlu_free(addr)
00050 #endif
00051 
00052 #define SUPERLU_FREE(addr) USER_FREE(addr)
00053 
00054 #define CHECK_MALLOC(where) {                 \
00055     extern int superlu_malloc_total;        \
00056     printf("%s: malloc_total %d Bytes\n",     \
00057        where, superlu_malloc_total); \
00058 }
00059 
00060 #define SUPERLU_MAX(x, y)   ( (x) > (y) ? (x) : (y) )
00061 #define SUPERLU_MIN(x, y)   ( (x) < (y) ? (x) : (y) )
00062 
00063 /***********************************************************************
00064  * Constants 
00065  ***********************************************************************/
00066 #define EMPTY   (-1)
00067 /*#define NO    (-1)*/
00068 #define FALSE   0
00069 #define TRUE    1
00070 
00071 /***********************************************************************
00072  * Enumerate types
00073  ***********************************************************************/
00074 typedef enum {NO, YES}                                          yes_no_t;
00075 typedef enum {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED} fact_t;
00076 typedef enum {NOROWPERM, LargeDiag, MY_PERMR}                   rowperm_t;
00077 typedef enum {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}colperm_t;
00078 typedef enum {NOTRANS, TRANS, CONJ}                             trans_t;
00079 typedef enum {NOEQUIL, ROW, COL, BOTH}                          DiagScale_t;
00080 typedef enum {NOREFINE, SINGLE=1, SLU_DOUBLE, EXTRA}                IterRefine_t;
00081 typedef enum {LUSUP, UCOL, LSUB, USUB}                          MemType;
00082 typedef enum {HEAD, TAIL}                                       stack_end_t;
00083 typedef enum {SYSTEM, USER}                                     LU_space_t;
00084 
00085 /* 
00086  * The following enumerate type is used by the statistics variable 
00087  * to keep track of flop count and time spent at various stages.
00088  *
00089  * Note that not all of the fields are disjoint.
00090  */
00091 typedef enum {
00092     COLPERM, /* find a column ordering that minimizes fills */
00093     RELAX,   /* find artificial supernodes */
00094     ETREE,   /* compute column etree */
00095     EQUIL,   /* equilibrate the original matrix */
00096     FACT,    /* perform LU factorization */
00097     RCOND,   /* estimate reciprocal condition number */
00098     SOLVE,   /* forward and back solves */
00099     REFINE,  /* perform iterative refinement */
00100     SLU_FLOAT,   /* time spent in floating-point operations */
00101     TRSV,    /* fraction of FACT spent in xTRSV */
00102     GEMV,    /* fraction of FACT spent in xGEMV */
00103     FERR,    /* estimate error bounds after iterative refinement */
00104     NPHASES  /* total number of phases */
00105 } PhaseType;
00106 
00107 
00108 /***********************************************************************
00109  * Type definitions
00110  ***********************************************************************/
00111 typedef float    flops_t;
00112 typedef unsigned char Logical;
00113 
00114 /* 
00115  *-- This contains the options used to control the solve process.
00116  *
00117  * Fact   (fact_t)
00118  *        Specifies whether or not the factored form of the matrix
00119  *        A is supplied on entry, and if not, how the matrix A should
00120  *        be factorizaed.
00121  *        = DOFACT: The matrix A will be factorized from scratch, and the
00122  *             factors will be stored in L and U.
00123  *        = SamePattern: The matrix A will be factorized assuming
00124  *             that a factorization of a matrix with the same sparsity
00125  *             pattern was performed prior to this one. Therefore, this
00126  *             factorization will reuse column permutation vector 
00127  *             ScalePermstruct->perm_c and the column elimination tree
00128  *             LUstruct->etree.
00129  *        = SamePattern_SameRowPerm: The matrix A will be factorized
00130  *             assuming that a factorization of a matrix with the same
00131  *             sparsity pattern and similar numerical values was performed
00132  *             prior to this one. Therefore, this factorization will reuse
00133  *             both row and column scaling factors R and C, and the
00134  *             both row and column permutation vectors perm_r and perm_c,
00135  *             distributed data structure set up from the previous symbolic
00136  *             factorization.
00137  *        = FACTORED: On entry, L, U, perm_r and perm_c contain the 
00138  *              factored form of A. If DiagScale is not NOEQUIL, the matrix
00139  *              A has been equilibrated with scaling factors R and C.
00140  *
00141  * Equil  (yes_no_t)
00142  *        Specifies whether to equilibrate the system (scale A's row and
00143  *        columns to have unit norm).
00144  *
00145  * ColPerm (colperm_t)
00146  *        Specifies what type of column permutation to use to reduce fill.
00147  *        = NATURAL: use the natural ordering 
00148  *        = MMD_ATA: use minimum degree ordering on structure of A'*A
00149  *        = MMD_AT_PLUS_A: use minimum degree ordering on structure of A'+A
00150  *        = COLAMD: use approximate minimum degree column ordering
00151  *        = MY_PERMC: use the ordering specified in ScalePermstruct->perm_c[]
00152  *         
00153  * Trans  (trans_t)
00154  *        Specifies the form of the system of equations:
00155  *        = NOTRANS: A * X = B        (No transpose)
00156  *        = TRANS:   A**T * X = B     (Transpose)
00157  *        = CONJ:    A**H * X = B     (Transpose)
00158  *
00159  * IterRefine (IterRefine_t)
00160  *        Specifies whether to perform iterative refinement.
00161  *        = NO: no iterative refinement
00162  *        = WorkingPrec: perform iterative refinement in working precision
00163  *        = ExtraPrec: perform iterative refinement in extra precision
00164  *
00165  * PrintStat (yes_no_t)
00166  *        Specifies whether to print the solver's statistics.
00167  *
00168  * DiagPivotThresh (double, in [0.0, 1.0]) (only for sequential SuperLU)
00169  *        Specifies the threshold used for a diagonal entry to be an
00170  *        acceptable pivot.
00171  *
00172  * PivotGrowth (yes_no_t)
00173  *        Specifies whether to compute the reciprocal pivot growth.
00174  *
00175  * ConditionNumber (ues_no_t)
00176  *        Specifies whether to compute the reciprocal condition number.
00177  *
00178  * RowPerm (rowperm_t) (only for SuperLU_DIST)
00179  *        Specifies whether to permute rows of the original matrix.
00180  *        = NO: not to permute the rows
00181  *        = LargeDiag: make the diagonal large relative to the off-diagonal
00182  *        = MY_PERMR: use the permutation given in ScalePermstruct->perm_r[]
00183  *           
00184  * ReplaceTinyPivot (yes_no_t) (only for SuperLU_DIST)
00185  *        Specifies whether to replace the tiny diagonals by
00186  *        sqrt(epsilon)*||A|| during LU factorization.
00187  *
00188  * SolveInitialized (yes_no_t) (only for SuperLU_DIST)
00189  *        Specifies whether the initialization has been performed to the
00190  *        triangular solve.
00191  *
00192  * RefineInitialized (yes_no_t) (only for SuperLU_DIST)
00193  *        Specifies whether the initialization has been performed to the
00194  *        sparse matrix-vector multiplication routine needed in iterative
00195  *        refinement.
00196  */
00197 typedef struct {
00198     fact_t        Fact;
00199     yes_no_t      Equil;
00200     colperm_t     ColPerm;
00201     trans_t       Trans;
00202     IterRefine_t  IterRefine;
00203     yes_no_t      PrintStat;
00204     yes_no_t      SymmetricMode;
00205     double        DiagPivotThresh;
00206     yes_no_t      PivotGrowth;
00207     yes_no_t      ConditionNumber;
00208     rowperm_t     RowPerm;
00209     yes_no_t      ReplaceTinyPivot;
00210     yes_no_t      SolveInitialized;
00211     yes_no_t      RefineInitialized;
00212 } superlu_options_t;
00213 
00214 typedef struct {
00215     int     *panel_histo; /* histogram of panel size distribution */
00216     double  *utime;       /* running time at various phases */
00217     flops_t *ops;         /* operation count at various phases */
00218     int     TinyPivots;   /* number of tiny pivots */
00219     int     RefineSteps;  /* number of iterative refinement steps */
00220 } SuperLUStat_t;
00221 
00222 
00223 /***********************************************************************
00224  * Prototypes
00225  ***********************************************************************/
00226 #ifdef __cplusplus
00227 extern "C" {
00228 #endif
00229 
00230 extern void    Destroy_SuperMatrix_Store(SuperMatrix *);
00231 extern void    Destroy_CompCol_Matrix(SuperMatrix *);
00232 extern void    Destroy_CompRow_Matrix(SuperMatrix *);
00233 extern void    Destroy_SuperNode_Matrix(SuperMatrix *);
00234 extern void    Destroy_CompCol_Permuted(SuperMatrix *);
00235 extern void    Destroy_Dense_Matrix(SuperMatrix *);
00236 extern void    get_perm_c(int, SuperMatrix *, int *);
00237 extern void    set_default_options(superlu_options_t *options);
00238 extern void    sp_preorder (superlu_options_t *, SuperMatrix*, int*, int*,
00239                 SuperMatrix*);
00240 extern void    superlu_abort_and_exit(char*);
00241 extern void    *superlu_malloc (size_t);
00242 extern int     *intMalloc (int);
00243 extern int     *intCalloc (int);
00244 extern void    superlu_free (void*);
00245 extern void    SetIWork (int, int, int, int *, int **, int **, int **,
00246                          int **, int **, int **, int **);
00247 extern int     sp_coletree (int *, int *, int *, int, int, int *);
00248 extern void    relax_snode (const int, int *, const int, int *, int *);
00249 extern void    heap_relax_snode (const int, int *, const int, int *, int *);
00250 extern void    resetrep_col (const int, const int *, int *);
00251 extern int     spcoletree (int *, int *, int *, int, int, int *);
00252 extern int     *TreePostorder (int, int *);
00253 extern double  SuperLU_timer_ (void);
00254 extern int     sp_ienv (int);
00255 extern int     lsame_ (char *, char *);
00256 extern int     xerbla_ (char *, int *);
00257 extern void    ifill (int *, int, int);
00258 extern void    snode_profile (int, int *);
00259 extern void    super_stats (int, int *);
00260 extern void    PrintSumm (char *, int, int, int);
00261 extern void    StatInit(SuperLUStat_t *);
00262 extern void    StatPrint (SuperLUStat_t *);
00263 extern void    StatFree(SuperLUStat_t *);
00264 extern void    print_panel_seg(int, int, int, int, int *, int *);
00265 extern void    check_repfnz(int, int, int, int *);
00266 
00267 #ifdef __cplusplus
00268   }
00269 #endif
00270 
00271 #endif /* __SUPERLU_UTIL */