~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to intern/opennl/superlu/util.h

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __SUPERLU_UTIL /* allow multiple inclusions */
 
2
#define __SUPERLU_UTIL
 
3
 
 
4
#include <stdio.h>
 
5
#include <stdlib.h>
 
6
#include <string.h>
 
7
/*
 
8
#ifndef __STDC__
 
9
#include <malloc.h>
 
10
#endif
 
11
*/
 
12
#include <assert.h>
 
13
 
 
14
/***********************************************************************
 
15
 * Macros
 
16
 ***********************************************************************/
 
17
#define FIRSTCOL_OF_SNODE(i)    (xsup[i])
 
18
/* No of marker arrays used in the symbolic factorization,
 
19
   each of size n */
 
20
#define NO_MARKER     3
 
21
#define NUM_TEMPV(m,w,t,b)  ( SUPERLU_MAX(m, (t + b)*w) )
 
22
 
 
23
#ifndef USER_ABORT
 
24
#define USER_ABORT(msg) superlu_abort_and_exit(msg)
 
25
#endif
 
26
 
 
27
#define ABORT(err_msg) \
 
28
 { char msg[256];\
 
29
   sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\
 
30
   USER_ABORT(msg); }
 
31
 
 
32
 
 
33
#ifndef USER_MALLOC
 
34
#if 1
 
35
#define USER_MALLOC(size) superlu_malloc(size)
 
36
#else
 
37
/* The following may check out some uninitialized data */
 
38
#define USER_MALLOC(size) memset (superlu_malloc(size), '\x0F', size)
 
39
#endif
 
40
#endif
 
41
 
 
42
#define SUPERLU_MALLOC(size) USER_MALLOC(size)
 
43
 
 
44
#ifndef USER_FREE
 
45
#define USER_FREE(addr) superlu_free(addr)
 
46
#endif
 
47
 
 
48
#define SUPERLU_FREE(addr) USER_FREE(addr)
 
49
 
 
50
#define CHECK_MALLOC(where) {                 \
 
51
    extern int superlu_malloc_total;        \
 
52
    printf("%s: malloc_total %d Bytes\n",     \
 
53
           where, superlu_malloc_total); \
 
54
}
 
55
 
 
56
#define SUPERLU_MAX(x, y)       ( (x) > (y) ? (x) : (y) )
 
57
#define SUPERLU_MIN(x, y)       ( (x) < (y) ? (x) : (y) )
 
58
 
 
59
/***********************************************************************
 
60
 * Constants 
 
61
 ***********************************************************************/
 
62
#define EMPTY   (-1)
 
63
/*#define NO    (-1)*/
 
64
#define FALSE   0
 
65
#define TRUE    1
 
66
 
 
67
/***********************************************************************
 
68
 * Enumerate types
 
69
 ***********************************************************************/
 
70
typedef enum {NO, YES}                                          yes_no_t;
 
71
typedef enum {DOFACT, SamePattern, SamePattern_SameRowPerm, FACTORED} fact_t;
 
72
typedef enum {NOROWPERM, LargeDiag, MY_PERMR}                   rowperm_t;
 
73
typedef enum {NATURAL, MMD_ATA, MMD_AT_PLUS_A, COLAMD, MY_PERMC}colperm_t;
 
74
typedef enum {NOTRANS, TRANS, CONJ}                             trans_t;
 
75
typedef enum {NOEQUIL, ROW, COL, BOTH}                          DiagScale_t;
 
76
typedef enum {NOREFINE, SINGLE=1, SLU_DOUBLE, EXTRA}                IterRefine_t;
 
77
typedef enum {LUSUP, UCOL, LSUB, USUB}                          MemType;
 
78
typedef enum {HEAD, TAIL}                                       stack_end_t;
 
79
typedef enum {SYSTEM, USER}                                     LU_space_t;
 
80
 
 
81
/* 
 
82
 * The following enumerate type is used by the statistics variable 
 
83
 * to keep track of flop count and time spent at various stages.
 
84
 *
 
85
 * Note that not all of the fields are disjoint.
 
86
 */
 
87
typedef enum {
 
88
    COLPERM, /* find a column ordering that minimizes fills */
 
89
    RELAX,   /* find artificial supernodes */
 
90
    ETREE,   /* compute column etree */
 
91
    EQUIL,   /* equilibrate the original matrix */
 
92
    FACT,    /* perform LU factorization */
 
93
    RCOND,   /* estimate reciprocal condition number */
 
94
    SOLVE,   /* forward and back solves */
 
95
    REFINE,  /* perform iterative refinement */
 
96
    SLU_FLOAT,   /* time spent in floating-point operations */
 
97
    TRSV,    /* fraction of FACT spent in xTRSV */
 
98
    GEMV,    /* fraction of FACT spent in xGEMV */
 
99
    FERR,    /* estimate error bounds after iterative refinement */
 
100
    NPHASES  /* total number of phases */
 
101
} PhaseType;
 
102
 
 
103
 
 
104
/***********************************************************************
 
105
 * Type definitions
 
106
 ***********************************************************************/
 
107
typedef float    flops_t;
 
108
typedef unsigned char Logical;
 
109
 
 
110
/* 
 
111
 *-- This contains the options used to control the solve process.
 
112
 *
 
113
 * Fact   (fact_t)
 
114
 *        Specifies whether or not the factored form of the matrix
 
115
 *        A is supplied on entry, and if not, how the matrix A should
 
116
 *        be factorizaed.
 
117
 *        = DOFACT: The matrix A will be factorized from scratch, and the
 
118
 *             factors will be stored in L and U.
 
119
 *        = SamePattern: The matrix A will be factorized assuming
 
120
 *             that a factorization of a matrix with the same sparsity
 
121
 *             pattern was performed prior to this one. Therefore, this
 
122
 *             factorization will reuse column permutation vector 
 
123
 *             ScalePermstruct->perm_c and the column elimination tree
 
124
 *             LUstruct->etree.
 
125
 *        = SamePattern_SameRowPerm: The matrix A will be factorized
 
126
 *             assuming that a factorization of a matrix with the same
 
127
 *             sparsity pattern and similar numerical values was performed
 
128
 *             prior to this one. Therefore, this factorization will reuse
 
129
 *             both row and column scaling factors R and C, and the
 
130
 *             both row and column permutation vectors perm_r and perm_c,
 
131
 *             distributed data structure set up from the previous symbolic
 
132
 *             factorization.
 
133
 *        = FACTORED: On entry, L, U, perm_r and perm_c contain the 
 
134
 *              factored form of A. If DiagScale is not NOEQUIL, the matrix
 
135
 *              A has been equilibrated with scaling factors R and C.
 
136
 *
 
137
 * Equil  (yes_no_t)
 
138
 *        Specifies whether to equilibrate the system (scale A's row and
 
139
 *        columns to have unit norm).
 
140
 *
 
141
 * ColPerm (colperm_t)
 
142
 *        Specifies what type of column permutation to use to reduce fill.
 
143
 *        = NATURAL: use the natural ordering 
 
144
 *        = MMD_ATA: use minimum degree ordering on structure of A'*A
 
145
 *        = MMD_AT_PLUS_A: use minimum degree ordering on structure of A'+A
 
146
 *        = COLAMD: use approximate minimum degree column ordering
 
147
 *        = MY_PERMC: use the ordering specified in ScalePermstruct->perm_c[]
 
148
 *         
 
149
 * Trans  (trans_t)
 
150
 *        Specifies the form of the system of equations:
 
151
 *        = NOTRANS: A * X = B        (No transpose)
 
152
 *        = TRANS:   A**T * X = B     (Transpose)
 
153
 *        = CONJ:    A**H * X = B     (Transpose)
 
154
 *
 
155
 * IterRefine (IterRefine_t)
 
156
 *        Specifies whether to perform iterative refinement.
 
157
 *        = NO: no iterative refinement
 
158
 *        = WorkingPrec: perform iterative refinement in working precision
 
159
 *        = ExtraPrec: perform iterative refinement in extra precision
 
160
 *
 
161
 * PrintStat (yes_no_t)
 
162
 *        Specifies whether to print the solver's statistics.
 
163
 *
 
164
 * DiagPivotThresh (double, in [0.0, 1.0]) (only for sequential SuperLU)
 
165
 *        Specifies the threshold used for a diagonal entry to be an
 
166
 *        acceptable pivot.
 
167
 *
 
168
 * PivotGrowth (yes_no_t)
 
169
 *        Specifies whether to compute the reciprocal pivot growth.
 
170
 *
 
171
 * ConditionNumber (ues_no_t)
 
172
 *        Specifies whether to compute the reciprocal condition number.
 
173
 *
 
174
 * RowPerm (rowperm_t) (only for SuperLU_DIST)
 
175
 *        Specifies whether to permute rows of the original matrix.
 
176
 *        = NO: not to permute the rows
 
177
 *        = LargeDiag: make the diagonal large relative to the off-diagonal
 
178
 *        = MY_PERMR: use the permutation given in ScalePermstruct->perm_r[]
 
179
 *           
 
180
 * ReplaceTinyPivot (yes_no_t) (only for SuperLU_DIST)
 
181
 *        Specifies whether to replace the tiny diagonals by
 
182
 *        sqrt(epsilon)*||A|| during LU factorization.
 
183
 *
 
184
 * SolveInitialized (yes_no_t) (only for SuperLU_DIST)
 
185
 *        Specifies whether the initialization has been performed to the
 
186
 *        triangular solve.
 
187
 *
 
188
 * RefineInitialized (yes_no_t) (only for SuperLU_DIST)
 
189
 *        Specifies whether the initialization has been performed to the
 
190
 *        sparse matrix-vector multiplication routine needed in iterative
 
191
 *        refinement.
 
192
 */
 
193
typedef struct {
 
194
    fact_t        Fact;
 
195
    yes_no_t      Equil;
 
196
    colperm_t     ColPerm;
 
197
    trans_t       Trans;
 
198
    IterRefine_t  IterRefine;
 
199
    yes_no_t      PrintStat;
 
200
    yes_no_t      SymmetricMode;
 
201
    double        DiagPivotThresh;
 
202
    yes_no_t      PivotGrowth;
 
203
    yes_no_t      ConditionNumber;
 
204
    rowperm_t     RowPerm;
 
205
    yes_no_t      ReplaceTinyPivot;
 
206
    yes_no_t      SolveInitialized;
 
207
    yes_no_t      RefineInitialized;
 
208
} superlu_options_t;
 
209
 
 
210
typedef struct {
 
211
    int     *panel_histo; /* histogram of panel size distribution */
 
212
    double  *utime;       /* running time at various phases */
 
213
    flops_t *ops;         /* operation count at various phases */
 
214
    int     TinyPivots;   /* number of tiny pivots */
 
215
    int     RefineSteps;  /* number of iterative refinement steps */
 
216
} SuperLUStat_t;
 
217
 
 
218
 
 
219
/***********************************************************************
 
220
 * Prototypes
 
221
 ***********************************************************************/
 
222
#ifdef __cplusplus
 
223
extern "C" {
 
224
#endif
 
225
 
 
226
extern void    Destroy_SuperMatrix_Store(SuperMatrix *);
 
227
extern void    Destroy_CompCol_Matrix(SuperMatrix *);
 
228
extern void    Destroy_CompRow_Matrix(SuperMatrix *);
 
229
extern void    Destroy_SuperNode_Matrix(SuperMatrix *);
 
230
extern void    Destroy_CompCol_Permuted(SuperMatrix *);
 
231
extern void    Destroy_Dense_Matrix(SuperMatrix *);
 
232
extern void    get_perm_c(int, SuperMatrix *, int *);
 
233
extern void    set_default_options(superlu_options_t *options);
 
234
extern void    sp_preorder (superlu_options_t *, SuperMatrix*, int*, int*,
 
235
                            SuperMatrix*);
 
236
extern void    superlu_abort_and_exit(char*);
 
237
extern void    *superlu_malloc (size_t);
 
238
extern int     *intMalloc (int);
 
239
extern int     *intCalloc (int);
 
240
extern void    superlu_free (void*);
 
241
extern void    SetIWork (int, int, int, int *, int **, int **, int **,
 
242
                         int **, int **, int **, int **);
 
243
extern int     sp_coletree (int *, int *, int *, int, int, int *);
 
244
extern void    relax_snode (const int, int *, const int, int *, int *);
 
245
extern void    heap_relax_snode (const int, int *, const int, int *, int *);
 
246
extern void    resetrep_col (const int, const int *, int *);
 
247
extern int     spcoletree (int *, int *, int *, int, int, int *);
 
248
extern int     *TreePostorder (int, int *);
 
249
extern double  SuperLU_timer_ ();
 
250
extern int     sp_ienv (int);
 
251
extern int     lsame_ (char *, char *);
 
252
extern int     xerbla_ (char *, int *);
 
253
extern void    ifill (int *, int, int);
 
254
extern void    snode_profile (int, int *);
 
255
extern void    super_stats (int, int *);
 
256
extern void    PrintSumm (char *, int, int, int);
 
257
extern void    StatInit(SuperLUStat_t *);
 
258
extern void    StatPrint (SuperLUStat_t *);
 
259
extern void    StatFree(SuperLUStat_t *);
 
260
extern void    print_panel_seg(int, int, int, int, int *, int *);
 
261
extern void    check_repfnz(int, int, int, int *);
 
262
 
 
263
#ifdef __cplusplus
 
264
  }
 
265
#endif
 
266
 
 
267
#endif /* __SUPERLU_UTIL */