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
00089
00090
00091 typedef enum {NO, YES} yes_no_t;
00092 typedef enum {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED} fact_t;
00093 typedef enum {NOROWPERM, LargeDiag, MY_PERMR} rowperm_t;
00094 typedef enum {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}colperm_t;
00095 typedef enum {NOTRANS, TRANS, CONJ} trans_t;
00096 typedef enum {NOEQUIL, ROW, COL, BOTH} DiagScale_t;
00097 typedef enum {NOREFINE, SINGLE=1, DOUBLE, EXTRA} IterRefine_t;
00098 typedef enum {LUSUP, UCOL, LSUB, USUB} MemType;
00099 typedef enum {HEAD, TAIL} stack_end_t;
00100 typedef enum {SYSTEM, USER} LU_space_t;
00101
00102
00103
00104
00105
00106
00107
00108 typedef enum {
00109 COLPERM,
00110 RELAX,
00111 ETREE,
00112 EQUIL,
00113 FACT,
00114 RCOND,
00115 SOLVE,
00116 REFINE,
00117 TRSV,
00118 GEMV,
00119 FERR,
00120 NPHASES
00121 } PhaseType;
00122
00123
00124
00125
00126
00127 typedef float flops_t;
00128 typedef unsigned char Logical;
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
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 typedef struct {
00216 fact_t Fact;
00217 yes_no_t Equil;
00218 colperm_t ColPerm;
00219 trans_t Trans;
00220 IterRefine_t IterRefine;
00221 double DiagPivotThresh;
00222 yes_no_t PivotGrowth;
00223 yes_no_t ConditionNumber;
00224 rowperm_t RowPerm;
00225 yes_no_t SymmetricMode;
00226 yes_no_t PrintStat;
00227 yes_no_t ReplaceTinyPivot;
00228 yes_no_t SolveInitialized;
00229 yes_no_t RefineInitialized;
00230 } superlu_options_t;
00231
00232 typedef struct {
00233 int *panel_histo;
00234 double *utime;
00235 flops_t *ops;
00236 int TinyPivots;
00237 int RefineSteps;
00238 } SuperLUStat_t;
00239
00240 typedef struct {
00241 float for_lu;
00242 float total_needed;
00243 int expansions;
00244 } mem_usage_t;
00245
00246
00247
00248
00249
00250 #ifdef __cplusplus
00251 extern "C" {
00252 #endif
00253
00254 extern void Destroy_SuperMatrix_Store(SuperMatrix *);
00255 extern void Destroy_CompCol_Matrix(SuperMatrix *);
00256 extern void Destroy_CompRow_Matrix(SuperMatrix *);
00257 extern void Destroy_SuperNode_Matrix(SuperMatrix *);
00258 extern void Destroy_CompCol_Permuted(SuperMatrix *);
00259 extern void Destroy_Dense_Matrix(SuperMatrix *);
00260 extern void get_perm_c(int, SuperMatrix *, int *);
00261 extern void set_default_options(superlu_options_t *options);
00262 extern void sp_preorder (superlu_options_t *, SuperMatrix*, int*, int*,
00263 SuperMatrix*);
00264 extern void superlu_abort_and_exit(char*);
00265 extern void *superlu_malloc (size_t);
00266 extern int *intMalloc (int);
00267 extern int *intCalloc (int);
00268 extern void superlu_free (void*);
00269 extern void SetIWork (int, int, int, int *, int **, int **, int **,
00270 int **, int **, int **, int **);
00271 extern int sp_coletree (int *, int *, int *, int, int, int *);
00272 extern void relax_snode (const int, int *, const int, int *, int *);
00273 extern void heap_relax_snode (const int, int *, const int, int *, int *);
00274 extern void resetrep_col (const int, const int *, int *);
00275 extern int spcoletree (int *, int *, int *, int, int, int *);
00276 extern int *TreePostorder (int, int *);
00277 extern double SuperLU_timer_ ();
00278 extern int sp_ienv (int);
00279 extern int lsame_ (char *, char *);
00280 extern int xerbla_ (char *, int *);
00281 extern void ifill (int *, int, int);
00282 extern void snode_profile (int, int *);
00283 extern void super_stats (int, int *);
00284 extern void PrintSumm (char *, int, int, int);
00285 extern void StatInit(SuperLUStat_t *);
00286 extern void StatPrint (SuperLUStat_t *);
00287 extern void StatFree(SuperLUStat_t *);
00288 extern void print_panel_seg(int, int, int, int, int *, int *);
00289 extern void check_repfnz(int, int, int, int *);
00290
00291 #ifdef __cplusplus
00292 }
00293 #endif
00294
00295 #endif