00001
00011 #ifndef __SUPERLU_UTIL
00012 #define __SUPERLU_UTIL
00013
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017
00018
00019
00020
00021
00022 #include <assert.h>
00023
00024
00025
00026
00027 #define FIRSTCOL_OF_SNODE(i) (xsup[i])
00028
00029
00030 #define NO_MARKER 3
00031 #define NUM_TEMPV(m,w,t,b) ( SUPERLU_MAX(m, (t + b)*w) )
00032
00033 #ifndef USER_ABORT
00034 #define USER_ABORT(msg) superlu_abort_and_exit(msg)
00035 #endif
00036
00037 #define ABORT(err_msg) \
00038 { char msg[256];\
00039 sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
00040 USER_ABORT(msg); }
00041
00042
00043 #ifndef USER_MALLOC
00044 #if 1
00045 #define USER_MALLOC(size) superlu_malloc(size)
00046 #else
00047
00048 #define USER_MALLOC(size) memset (superlu_malloc(size), '\x0F', size)
00049 #endif
00050 #endif
00051
00052 #define SUPERLU_MALLOC(size) USER_MALLOC(size)
00053
00054 #ifndef USER_FREE
00055 #define USER_FREE(addr) superlu_free(addr)
00056 #endif
00057
00058 #define SUPERLU_FREE(addr) USER_FREE(addr)
00059
00060 #define CHECK_MALLOC(where) { \
00061 extern int superlu_malloc_total; \
00062 printf("%s: malloc_total %d Bytes\n", \
00063 where, superlu_malloc_total); \
00064 }
00065
00066 #define SUPERLU_MAX(x, y) ( (x) > (y) ? (x) : (y) )
00067 #define SUPERLU_MIN(x, y) ( (x) < (y) ? (x) : (y) )
00068
00069
00070
00071
00072 #define L_SUB_START(col) ( Lstore->rowind_colptr[col] )
00073 #define L_SUB(ptr) ( Lstore->rowind[ptr] )
00074 #define L_NZ_START(col) ( Lstore->nzval_colptr[col] )
00075 #define L_FST_SUPC(superno) ( Lstore->sup_to_col[superno] )
00076 #define U_NZ_START(col) ( Ustore->colptr[col] )
00077 #define U_SUB(ptr) ( Ustore->rowind[ptr] )
00078
00079
00080
00081
00082
00083 #define EMPTY (-1)
00084
00085 #define FALSE 0
00086 #define TRUE 1
00087
00088 #define NO_MEMTYPE 4
00089
00090
00091
00092
00093 #define GluIntArray(n) (5 * (n) + 5)
00094
00095
00096 #define NODROP ( 0x0000 )
00097 #define DROP_BASIC ( 0x0001 )
00098 #define DROP_PROWS ( 0x0002 )
00099 #define DROP_COLUMN ( 0x0004 )
00100
00101 #define DROP_AREA ( 0x0008 )
00102
00103
00104 #define DROP_SECONDARY ( 0x000E )
00105 #define DROP_DYNAMIC ( 0x0010 )
00106 #define DROP_INTERP ( 0x0100 )
00107
00108
00109 #if 1
00110 #define MILU_ALPHA (1.0e-2)
00111 #else
00112 #define MILU_ALPHA 1.0
00113 #endif
00114
00115
00116
00117
00118
00119 typedef enum {NO, YES} yes_no_t;
00120 typedef enum {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED} fact_t;
00121 typedef enum {NOROWPERM, LargeDiag, MY_PERMR} rowperm_t;
00122 typedef enum {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}colperm_t;
00123 typedef enum {NOTRANS, TRANS, CONJ} trans_t;
00124 typedef enum {NOEQUIL, ROW, COL, BOTH} DiagScale_t;
00125 typedef enum {NOREFINE, SINGLE=1, DOUBLE, EXTRA} IterRefine_t;
00126 typedef enum {LUSUP, UCOL, LSUB, USUB} MemType;
00127 typedef enum {HEAD, TAIL} stack_end_t;
00128 typedef enum {SYSTEM, USER} LU_space_t;
00129 typedef enum {ONE_NORM, TWO_NORM, INF_NORM} norm_t;
00130 typedef enum {SILU, SMILU_1, SMILU_2, SMILU_3} milu_t;
00131 #if 0
00132 typedef enum {NODROP = 0x0000,
00133 DROP_BASIC = 0x0001,
00134 DROP_PROWS = 0x0002,
00135 DROP_COLUMN = 0x0004,
00136
00137 DROP_AREA = 0x0008,
00138
00139
00140 DROP_SECONDARY = 0x000E,
00141 DROP_DYNAMIC = 0x0010,
00142 DROP_INTERP = 0x0100} rule_t;
00143 #endif
00144
00145
00146
00147
00148
00149
00150
00151
00152 typedef enum {
00153 COLPERM,
00154 RELAX,
00155 ETREE,
00156 EQUIL,
00157 FACT,
00158 RCOND,
00159 SOLVE,
00160 REFINE,
00161 TRSV,
00162 GEMV,
00163 FERR,
00164 NPHASES
00165 } PhaseType;
00166
00167
00168
00169
00170
00171 typedef float flops_t;
00172 typedef unsigned char Logical;
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 typedef struct {
00260 fact_t Fact;
00261 yes_no_t Equil;
00262 colperm_t ColPerm;
00263 trans_t Trans;
00264 IterRefine_t IterRefine;
00265 double DiagPivotThresh;
00266 yes_no_t PivotGrowth;
00267 yes_no_t ConditionNumber;
00268 rowperm_t RowPerm;
00269 yes_no_t SymmetricMode;
00270 yes_no_t PrintStat;
00271 yes_no_t ReplaceTinyPivot;
00272 yes_no_t SolveInitialized;
00273 yes_no_t RefineInitialized;
00274 double ILU_DropTol;
00275 double ILU_FillTol;
00276 double ILU_FillFactor;
00277 int ILU_DropRule;
00278 norm_t ILU_Norm;
00279 milu_t ILU_MILU;
00280 } superlu_options_t;
00281
00283 typedef struct e_node {
00284 int size;
00285 void *mem;
00286 } ExpHeader;
00287
00288 typedef struct {
00289 int size;
00290 int used;
00291 int top1;
00292 int top2;
00293 void *array;
00294 } LU_stack_t;
00295
00296 typedef struct {
00297 int *panel_histo;
00298 double *utime;
00299 flops_t *ops;
00300 int TinyPivots;
00301 int RefineSteps;
00302 int expansions;
00303 } SuperLUStat_t;
00304
00305 typedef struct {
00306 float for_lu;
00307 float total_needed;
00308 } mem_usage_t;
00309
00310
00311
00312
00313
00314 #ifdef __cplusplus
00315 extern "C" {
00316 #endif
00317
00318 extern void Destroy_SuperMatrix_Store(SuperMatrix *);
00319 extern void Destroy_CompCol_Matrix(SuperMatrix *);
00320 extern void Destroy_CompRow_Matrix(SuperMatrix *);
00321 extern void Destroy_SuperNode_Matrix(SuperMatrix *);
00322 extern void Destroy_CompCol_Permuted(SuperMatrix *);
00323 extern void Destroy_Dense_Matrix(SuperMatrix *);
00324 extern void get_perm_c(int, SuperMatrix *, int *);
00325 extern void set_default_options(superlu_options_t *options);
00326 extern void ilu_set_default_options(superlu_options_t *options);
00327 extern void sp_preorder (superlu_options_t *, SuperMatrix*, int*, int*,
00328 SuperMatrix*);
00329 extern void superlu_abort_and_exit(char*);
00330 extern void *superlu_malloc (size_t);
00331 extern int *intMalloc (int);
00332 extern int *intCalloc (int);
00333 extern void superlu_free (void*);
00334 extern void SetIWork (int, int, int, int *, int **, int **, int **,
00335 int **, int **, int **, int **);
00336 extern int sp_coletree (int *, int *, int *, int, int, int *);
00337 extern void relax_snode (const int, int *, const int, int *, int *);
00338 extern void heap_relax_snode (const int, int *, const int, int *, int *);
00339 extern int mark_relax(int, int *, int *, int *, int *, int *, int *);
00340 extern void ilu_relax_snode (const int, int *, const int, int *,
00341 int *, int *);
00342 extern void ilu_heap_relax_snode (const int, int *, const int, int *,
00343 int *, int*);
00344 extern void resetrep_col (const int, const int *, int *);
00345 extern int spcoletree (int *, int *, int *, int, int, int *);
00346 extern int *TreePostorder (int, int *);
00347 extern double SuperLU_timer_ ();
00348 extern int sp_ienv (int);
00349 extern int lsame_ (char *, char *);
00350 extern int xerbla_ (char *, int *);
00351 extern void ifill (int *, int, int);
00352 extern void snode_profile (int, int *);
00353 extern void super_stats (int, int *);
00354 extern void check_repfnz(int, int, int, int *);
00355 extern void PrintSumm (char *, int, int, int);
00356 extern void StatInit(SuperLUStat_t *);
00357 extern void StatPrint (SuperLUStat_t *);
00358 extern void StatFree(SuperLUStat_t *);
00359 extern void print_panel_seg(int, int, int, int, int *, int *);
00360 extern int print_int_vec(char *,int, int *);
00361 extern int PrintInt10(char *, int, int *);
00362
00363 #ifdef __cplusplus
00364 }
00365 #endif
00366
00367 #endif