~ubuntu-branches/ubuntu/raring/python-scipy/raring-proposed

« back to all changes in this revision

Viewing changes to Lib/sandbox/pysparse/superlu/zsp_defs.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-07 14:12:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070107141212-mm0ebkh5b37hcpzn
* Remove build dependency on python-numpy-dev.
* python-scipy: Depend on python-numpy instead of python-numpy-dev.
* Package builds on other archs than i386. Closes: #402783.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
/*
 
4
 * -- SuperLU routine (version 2.0) --
 
5
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
 
6
 * and Lawrence Berkeley National Lab.
 
7
 * November 15, 1997
 
8
 *
 
9
 */
 
10
#ifndef __SUPERLU_zSP_DEFS /* allow multiple inclusions */
 
11
#define __SUPERLU_zSP_DEFS
 
12
 
 
13
/*
 
14
 * File name:           zsp_defs.h
 
15
 * Purpose:             Sparse matrix types and function prototypes
 
16
 * History:
 
17
 */
 
18
#ifdef _CRAY
 
19
#include <fortran.h>
 
20
#include <string.h>
 
21
#endif
 
22
#include "Cnames.h"
 
23
#include "supermatrix.h"
 
24
#include "dcomplex.h"
 
25
 
 
26
 
 
27
/* No of marker arrays used in the symbolic factorization,
 
28
   each of size n */
 
29
#define NO_MARKER     3
 
30
#define NUM_TEMPV(m,w,t,b)  ( SUPERLU_MAX(m, (t + b)*w) )
 
31
 
 
32
typedef enum {LUSUP, UCOL, LSUB, USUB} MemType;
 
33
typedef enum {HEAD, TAIL}              stack_end_t;
 
34
typedef enum {SYSTEM, USER}            LU_space_t;
 
35
 
 
36
/*
 
37
 * Global data structures used in LU factorization -
 
38
 * 
 
39
 *   nsuper: #supernodes = nsuper + 1, numbered [0, nsuper].
 
40
 *   (xsup,supno): supno[i] is the supernode no to which i belongs;
 
41
 *      xsup(s) points to the beginning of the s-th supernode.
 
42
 *      e.g.   supno 0 1 2 2 3 3 3 4 4 4 4 4   (n=12)
 
43
 *              xsup 0 1 2 4 7 12
 
44
 *      Note: dfs will be performed on supernode rep. relative to the new 
 
45
 *            row pivoting ordering
 
46
 *
 
47
 *   (xlsub,lsub): lsub[*] contains the compressed subscript of
 
48
 *      rectangular supernodes; xlsub[j] points to the starting
 
49
 *      location of the j-th column in lsub[*]. Note that xlsub 
 
50
 *      is indexed by column.
 
51
 *      Storage: original row subscripts
 
52
 *
 
53
 *      During the course of sparse LU factorization, we also use
 
54
 *      (xlsub,lsub) for the purpose of symmetric pruning. For each
 
55
 *      supernode {s,s+1,...,t=s+r} with first column s and last
 
56
 *      column t, the subscript set
 
57
 *              lsub[j], j=xlsub[s], .., xlsub[s+1]-1
 
58
 *      is the structure of column s (i.e. structure of this supernode).
 
59
 *      It is used for the storage of numerical values.
 
60
 *      Furthermore,
 
61
 *              lsub[j], j=xlsub[t], .., xlsub[t+1]-1
 
62
 *      is the structure of the last column t of this supernode.
 
63
 *      It is for the purpose of symmetric pruning. Therefore, the
 
64
 *      structural subscripts can be rearranged without making physical
 
65
 *      interchanges among the numerical values.
 
66
 *
 
67
 *      However, if the supernode has only one column, then we
 
68
 *      only keep one set of subscripts. For any subscript interchange
 
69
 *      performed, similar interchange must be done on the numerical
 
70
 *      values.
 
71
 *
 
72
 *      The last column structures (for pruning) will be removed
 
73
 *      after the numercial LU factorization phase.
 
74
 *
 
75
 *   (xlusup,lusup): lusup[*] contains the numerical values of the
 
76
 *      rectangular supernodes; xlusup[j] points to the starting
 
77
 *      location of the j-th column in storage vector lusup[*]
 
78
 *      Note: xlusup is indexed by column.
 
79
 *      Each rectangular supernode is stored by column-major
 
80
 *      scheme, consistent with Fortran 2-dim array storage.
 
81
 *
 
82
 *   (xusub,ucol,usub): ucol[*] stores the numerical values of
 
83
 *      U-columns outside the rectangular supernodes. The row
 
84
 *      subscript of nonzero ucol[k] is stored in usub[k].
 
85
 *      xusub[i] points to the starting location of column i in ucol.
 
86
 *      Storage: new row subscripts; that is subscripts of PA.
 
87
 */
 
88
typedef struct {
 
89
    int     *xsup;    /* supernode and column mapping */
 
90
    int     *supno;   
 
91
    int     *lsub;    /* compressed L subscripts */
 
92
    int     *xlsub;
 
93
    doublecomplex  *lusup;   /* L supernodes */
 
94
    int     *xlusup;
 
95
    doublecomplex  *ucol;    /* U columns */
 
96
    int     *usub;
 
97
    int     *xusub;
 
98
    int     nzlmax;   /* current max size of lsub */
 
99
    int     nzumax;   /*    "    "    "      ucol */
 
100
    int     nzlumax;  /*    "    "    "     lusup */
 
101
    int     n;        /* number of columns in the matrix */
 
102
    LU_space_t MemModel; /* 0 - system malloc'd; 1 - user provided */
 
103
} GlobalLU_t;
 
104
 
 
105
typedef struct {
 
106
    int panel_size;
 
107
    int relax;
 
108
    double diag_pivot_thresh;
 
109
    double drop_tol;
 
110
} factor_param_t;
 
111
 
 
112
typedef struct {
 
113
    float for_lu;
 
114
    float total_needed;
 
115
    int   expansions;
 
116
} mem_usage_t;
 
117
 
 
118
#ifdef __cplusplus
 
119
extern "C" {
 
120
#endif
 
121
 
 
122
/* Driver routines */
 
123
extern void
 
124
zgssv(SuperMatrix *, int *, int *, SuperMatrix *, SuperMatrix *, 
 
125
        SuperMatrix *, int *);
 
126
extern void
 
127
zgssvx(char *, char *, char *, SuperMatrix *, factor_param_t *,
 
128
       int *, int *, int *, char *, double *, double *,
 
129
       SuperMatrix *, SuperMatrix *, void *, int, SuperMatrix *, 
 
130
       SuperMatrix *, double *, double *, double *,
 
131
       double *, mem_usage_t *, int *);
 
132
 
 
133
/* Supernodal LU factor related */
 
134
extern void
 
135
zCreate_CompCol_Matrix(SuperMatrix *, int, int, int, doublecomplex *,
 
136
                       int *, int *, Stype_t, Dtype_t, Mtype_t);
 
137
extern void
 
138
zCopy_CompCol_Matrix(SuperMatrix *, SuperMatrix *);
 
139
extern void
 
140
zCreate_Dense_Matrix(SuperMatrix *, int, int, doublecomplex *, int,
 
141
                     Stype_t, Dtype_t, Mtype_t);
 
142
extern void
 
143
zCreate_SuperNode_Matrix(SuperMatrix *, int, int, int, doublecomplex *, 
 
144
                         int *, int *, int *, int *, int *,
 
145
                         Stype_t, Dtype_t, Mtype_t);
 
146
extern void
 
147
zCopy_Dense_Matrix(int, int, doublecomplex *, int, doublecomplex *, int);
 
148
 
 
149
extern void    Destroy_SuperMatrix_Store(SuperMatrix *);
 
150
extern void    Destroy_CompCol_Matrix(SuperMatrix *);
 
151
extern void    Destroy_SuperNode_Matrix(SuperMatrix *);
 
152
extern void    Destroy_CompCol_Permuted(SuperMatrix *);
 
153
extern void    Destroy_Dense_Matrix(SuperMatrix *);
 
154
extern void    get_perm_c(int, SuperMatrix *, int *);
 
155
extern void    sp_preorder (char*, SuperMatrix*, int*, int*, SuperMatrix*);
 
156
extern void    countnz (const int, int *, int *, int *, GlobalLU_t *);
 
157
extern void    fixupL (const int, const int *, GlobalLU_t *);
 
158
 
 
159
extern void    zallocateA (int, int, doublecomplex **, int **, int **);
 
160
extern void    zgstrf (char*, SuperMatrix*, double, double, int, int, int*,
 
161
                        void *, int, int *, int *, 
 
162
                        SuperMatrix *, SuperMatrix *, int *);
 
163
extern int     zsnode_dfs (const int, const int, const int *, const int *,
 
164
                             const int *, int *, int *, GlobalLU_t *);
 
165
extern int     zsnode_bmod (const int, const int, const int, doublecomplex *,
 
166
                              doublecomplex *, GlobalLU_t *);
 
167
extern void    zpanel_dfs (const int, const int, const int, SuperMatrix *,
 
168
                           int *, int *, doublecomplex *, int *, int *, int *,
 
169
                           int *, int *, int *, int *, GlobalLU_t *);
 
170
extern void    zpanel_bmod (const int, const int, const int, const int,
 
171
                           doublecomplex *, doublecomplex *, int *, int *,
 
172
                           GlobalLU_t *);
 
173
extern int     zcolumn_dfs (const int, const int, int *, int *, int *, int *,
 
174
                           int *, int *, int *, int *, int *, GlobalLU_t *);
 
175
extern int     zcolumn_bmod (const int, const int, doublecomplex *,
 
176
                           doublecomplex *, int *, int *, int, GlobalLU_t *);
 
177
extern int     zcopy_to_ucol (int, int, int *, int *, int *,
 
178
                              doublecomplex *, GlobalLU_t *);         
 
179
extern int     zpivotL (const int, const double, int *, int *, 
 
180
                              int *, int *, int *, GlobalLU_t *);
 
181
extern void    zpruneL (const int, const int *, const int, const int,
 
182
                             const int *, const int *, int *, GlobalLU_t *);
 
183
extern void    zreadmt (int *, int *, int *, doublecomplex **, int **, int **);
 
184
extern void    zGenXtrue (int, int, doublecomplex *, int);
 
185
extern void    zFillRHS (char *, int, doublecomplex *, int, SuperMatrix *,
 
186
                        SuperMatrix *);
 
187
extern void    zgstrs (char *, SuperMatrix *, SuperMatrix *, int *, int *,
 
188
                        SuperMatrix *, int *);
 
189
 
 
190
 
 
191
/* Driver related */
 
192
 
 
193
extern void    zgsequ (SuperMatrix *, double *, double *, double *,
 
194
                             double *, double *, int *);
 
195
extern void    zlaqgs (SuperMatrix *, double *, double *, double,
 
196
                             double, double, char *);
 
197
extern void    zgscon (char *, SuperMatrix *, SuperMatrix *,
 
198
                        double, double *, int *);
 
199
extern double  zPivotGrowth(int, SuperMatrix *, int *, 
 
200
                            SuperMatrix *, SuperMatrix *);
 
201
extern void    zgsrfs (char *, SuperMatrix *, SuperMatrix *, 
 
202
                        SuperMatrix *, int *, int *, char *, double *,
 
203
                        double *, SuperMatrix *, SuperMatrix *, 
 
204
                        double *, double *, int *);
 
205
 
 
206
extern int     sp_ztrsv (char *, char *, char *, SuperMatrix *,
 
207
                        SuperMatrix *, doublecomplex *, int *);
 
208
extern int     sp_zgemv (char *, doublecomplex, SuperMatrix *, doublecomplex *,
 
209
                        int, doublecomplex, doublecomplex *, int);
 
210
 
 
211
extern int     sp_zgemm (char *, char *, int, int, int, doublecomplex,
 
212
                        SuperMatrix *, doublecomplex *, int, doublecomplex, 
 
213
                        doublecomplex *, int);
 
214
 
 
215
/* Memory-related */
 
216
extern int     zLUMemInit (char *, void *, int, int, int, int, int,
 
217
                             SuperMatrix *, SuperMatrix *,
 
218
                             GlobalLU_t *, int **, doublecomplex **);
 
219
extern void    zSetRWork (int, int, doublecomplex *, doublecomplex **, doublecomplex **);
 
220
extern void    zLUWorkFree (int *, doublecomplex *, GlobalLU_t *);
 
221
extern int     zLUMemXpand (int, int, MemType, int *, GlobalLU_t *);
 
222
 
 
223
extern doublecomplex  *doublecomplexMalloc(int);
 
224
extern doublecomplex  *doublecomplexCalloc(int);
 
225
extern double  *doubleMalloc(int);
 
226
extern double  *doubleCalloc(int);
 
227
extern int     zmemory_usage(const int, const int, const int, const int);
 
228
extern int     zQuerySpace (SuperMatrix *, SuperMatrix *, int,
 
229
                                mem_usage_t *);
 
230
 
 
231
/* Auxiliary routines */
 
232
extern void    zreadhb(int *, int *, int *, doublecomplex **, int **, int **);
 
233
extern void    zCompRow_to_CompCol(int, int, int, doublecomplex*, int*, int*,
 
234
                                   doublecomplex **, int **, int **);
 
235
extern void    zfill (doublecomplex *, int, doublecomplex);
 
236
extern void    zinf_norm_error (int, SuperMatrix *, doublecomplex *);
 
237
extern void    PrintPerf (SuperMatrix *, SuperMatrix *, mem_usage_t *,
 
238
                         doublecomplex, doublecomplex, doublecomplex *, doublecomplex *, char *);
 
239
 
 
240
/* Routines for debugging */
 
241
extern void    zPrint_CompCol_Matrix(char *, SuperMatrix *);
 
242
extern void    zPrint_SuperNode_Matrix(char *, SuperMatrix *);
 
243
extern void    zPrint_Dense_Matrix(char *, SuperMatrix *);
 
244
extern void    print_lu_col(char *, int, int, int *, GlobalLU_t *);
 
245
extern void    check_tempv(int, doublecomplex *);
 
246
 
 
247
#ifdef __cplusplus
 
248
  }
 
249
#endif
 
250
 
 
251
#endif /* __SUPERLU_zSP_DEFS */
 
252