1 
2 /*! @file slu_cdefs.h
3  * \brief Header file for real operations
4  *
5  * <pre>
6  * -- SuperLU routine (version 4.1) --
7  * Univ. of California Berkeley, Xerox Palo Alto Research Center,
8  * and Lawrence Berkeley National Lab.
9  * November, 2010
10  *
11  * Global data structures used in LU factorization -
12  *
13  *   nsuper: #supernodes = nsuper + 1, numbered [0, nsuper].
14  *   (xsup,supno): supno[i] is the supernode no to which i belongs;
15  *	xsup(s) points to the beginning of the s-th supernode.
16  *	e.g.   supno 0 1 2 2 3 3 3 4 4 4 4 4   (n=12)
17  *	        xsup 0 1 2 4 7 12
18  *	Note: dfs will be performed on supernode rep. relative to the new
19  *	      row pivoting ordering
20  *
21  *   (xlsub,lsub): lsub[*] contains the compressed subscript of
22  *	rectangular supernodes; xlsub[j] points to the starting
23  *	location of the j-th column in lsub[*]. Note that xlsub
24  *	is indexed by column.
25  *	Storage: original row subscripts
26  *
27  *      During the course of sparse LU factorization, we also use
28  *	(xlsub,lsub) for the purpose of symmetric pruning. For each
29  *	supernode {s,s+1,...,t=s+r} with first column s and last
30  *	column t, the subscript set
31  *		lsub[j], j=xlsub[s], .., xlsub[s+1]-1
32  *	is the structure of column s (i.e. structure of this supernode).
33  *	It is used for the storage of numerical values.
34  *	Furthermore,
35  *		lsub[j], j=xlsub[t], .., xlsub[t+1]-1
36  *	is the structure of the last column t of this supernode.
37  *	It is for the purpose of symmetric pruning. Therefore, the
38  *	structural subscripts can be rearranged without making physical
39  *	interchanges among the numerical values.
40  *
41  *	However, if the supernode has only one column, then we
42  *	only keep one set of subscripts. For any subscript interchange
43  *	performed, similar interchange must be done on the numerical
44  *	values.
45  *
46  *	The last column structures (for pruning) will be removed
47  *	after the numercial LU factorization phase.
48  *
49  *   (xlusup,lusup): lusup[*] contains the numerical values of the
50  *	rectangular supernodes; xlusup[j] points to the starting
51  *	location of the j-th column in storage vector lusup[*]
52  *	Note: xlusup is indexed by column.
53  *	Each rectangular supernode is stored by column-major
54  *	scheme, consistent with Fortran 2-dim array storage.
55  *
56  *   (xusub,ucol,usub): ucol[*] stores the numerical values of
57  *	U-columns outside the rectangular supernodes. The row
58  *	subscript of nonzero ucol[k] is stored in usub[k].
59  *	xusub[i] points to the starting location of column i in ucol.
60  *	Storage: new row subscripts; that is subscripts of PA.
61  * </pre>
62  */
63 #ifndef __SUPERLU_cSP_DEFS /* allow multiple inclusions */
64 #define __SUPERLU_cSP_DEFS
65 
66 /*
67  * File name:		csp_defs.h
68  * Purpose:             Sparse matrix types and function prototypes
69  * History:
70  */
71 
72 #ifdef _CRAY
73 #include <fortran.h>
74 #include <string.h>
75 #endif
76 
77 /* Define my integer type int_t */
78 typedef int int_t; /* default */
79 
80 #include <math.h>
81 #include <limits.h>
82 #include "slu_Cnames.h"
83 #include "supermatrix.h"
84 #include "slu_util.h"
85 #include "slu_scomplex.h"
86 
87 
88 
89 typedef struct {
90     int     *xsup;    /* supernode and column mapping */
91     int     *supno;
92     int     *lsub;    /* compressed L subscripts */
93     int	    *xlsub;
94     complex  *lusup;   /* L supernodes */
95     int     *xlusup;
96     complex  *ucol;    /* U columns */
97     int     *usub;
98     int	    *xusub;
99     int     nzlmax;   /* current max size of lsub */
100     int     nzumax;   /*    "    "    "      ucol */
101     int     nzlumax;  /*    "    "    "     lusup */
102     int     n;        /* number of columns in the matrix */
103     LU_space_t MemModel; /* 0 - system malloc'd; 1 - user provided */
104     int     num_expansions;
105     ExpHeader *expanders; /* Array of pointers to 4 types of memory */
106     LU_stack_t stack;     /* use user supplied memory */
107 } GlobalLU_t;
108 
109 
110 /* -------- Prototypes -------- */
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
116 /*! \brief Driver routines */
117 extern void
118 cgssv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
119       SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
120 extern void
121 cgssvx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
122        char *, float *, float *, SuperMatrix *, SuperMatrix *,
123        void *, int, SuperMatrix *, SuperMatrix *,
124        float *, float *, float *, float *,
125        mem_usage_t *, SuperLUStat_t *, int *);
126     /* ILU */
127 extern void
128 cgsisv(superlu_options_t *, SuperMatrix *, int *, int *, SuperMatrix *,
129       SuperMatrix *, SuperMatrix *, SuperLUStat_t *, int *);
130 extern void
131 cgsisx(superlu_options_t *, SuperMatrix *, int *, int *, int *,
132        char *, float *, float *, SuperMatrix *, SuperMatrix *,
133        void *, int, SuperMatrix *, SuperMatrix *, float *, float *,
134        mem_usage_t *, SuperLUStat_t *, int *);
135 
136 
137 /*! \brief Supernodal LU factor related */
138 extern void
139 cCreate_CompCol_Matrix(SuperMatrix *, int, int, int, complex *,
140 		       int *, int *, Stype_t, Dtype_t, Mtype_t);
141 extern void
142 cCreate_CompRow_Matrix(SuperMatrix *, int, int, int, complex *,
143 		       int *, int *, Stype_t, Dtype_t, Mtype_t);
144 extern void
145 cCopy_CompCol_Matrix(SuperMatrix *, SuperMatrix *);
146 extern void
147 cCreate_Dense_Matrix(SuperMatrix *, int, int, complex *, int,
148 		     Stype_t, Dtype_t, Mtype_t);
149 extern void
150 cCreate_SuperNode_Matrix(SuperMatrix *, int, int, int, complex *,
151 		         int *, int *, int *, int *, int *,
152 			 Stype_t, Dtype_t, Mtype_t);
153 extern void
154 cCopy_Dense_Matrix(int, int, complex *, int, complex *, int);
155 
156 extern void    countnz (const int, int *, int *, int *, GlobalLU_t *);
157 extern void    ilu_countnz (const int, int *, int *, GlobalLU_t *);
158 extern void    fixupL (const int, const int *, GlobalLU_t *);
159 
160 extern void    callocateA (int, int, complex **, int **, int **);
161 extern void    cgstrf (superlu_options_t*, SuperMatrix*,
162                        int, int, int*, void *, int, int *, int *,
163                        SuperMatrix *, SuperMatrix *, SuperLUStat_t*, int *);
164 extern int     csnode_dfs (const int, const int, const int *, const int *,
165 			     const int *, int *, int *, GlobalLU_t *);
166 extern int     csnode_bmod (const int, const int, const int, complex *,
167                               complex *, GlobalLU_t *, SuperLUStat_t*);
168 extern void    cpanel_dfs (const int, const int, const int, SuperMatrix *,
169 			   int *, int *, complex *, int *, int *, int *,
170 			   int *, int *, int *, int *, GlobalLU_t *);
171 extern void    cpanel_bmod (const int, const int, const int, const int,
172                            complex *, complex *, int *, int *,
173 			   GlobalLU_t *, SuperLUStat_t*);
174 extern int     ccolumn_dfs (const int, const int, int *, int *, int *, int *,
175 			   int *, int *, int *, int *, int *, GlobalLU_t *);
176 extern int     ccolumn_bmod (const int, const int, complex *,
177 			   complex *, int *, int *, int,
178                            GlobalLU_t *, SuperLUStat_t*);
179 extern int     ccopy_to_ucol (int, int, int *, int *, int *,
180                               complex *, GlobalLU_t *);
181 extern int     cpivotL (const int, const double, int *, int *,
182                          int *, int *, int *, GlobalLU_t *, SuperLUStat_t*);
183 extern void    cpruneL (const int, const int *, const int, const int,
184 			  const int *, const int *, int *, GlobalLU_t *);
185 extern void    creadmt (int *, int *, int *, complex **, int **, int **);
186 extern void    cGenXtrue (int, int, complex *, int);
187 extern void    cFillRHS (trans_t, int, complex *, int, SuperMatrix *,
188 			  SuperMatrix *);
189 extern void    cgstrs (trans_t, SuperMatrix *, SuperMatrix *, int *, int *,
190                         SuperMatrix *, SuperLUStat_t*, int *);
191 /* ILU */
192 extern void    cgsitrf (superlu_options_t*, SuperMatrix*, int, int, int*,
193 		        void *, int, int *, int *, SuperMatrix *, SuperMatrix *,
194                         SuperLUStat_t*, int *);
195 extern int     cldperm(int, int, int, int [], int [], complex [],
196                         int [],	float [], float []);
197 extern int     ilu_csnode_dfs (const int, const int, const int *, const int *,
198 			       const int *, int *, GlobalLU_t *);
199 extern void    ilu_cpanel_dfs (const int, const int, const int, SuperMatrix *,
200 			       int *, int *, complex *, float *, int *, int *,
201 			       int *, int *, int *, int *, GlobalLU_t *);
202 extern int     ilu_ccolumn_dfs (const int, const int, int *, int *, int *,
203 				int *, int *, int *, int *, int *,
204 				GlobalLU_t *);
205 extern int     ilu_ccopy_to_ucol (int, int, int *, int *, int *,
206                                   complex *, int, milu_t, double, int,
207                                   complex *, int *, GlobalLU_t *, float *);
208 extern int     ilu_cpivotL (const int, const double, int *, int *, int, int *,
209 			    int *, int *, int *, double, milu_t,
210                             complex, GlobalLU_t *, SuperLUStat_t*);
211 extern int     ilu_cdrop_row (superlu_options_t *, int, int, double,
212                               int, int *, double *, GlobalLU_t *,
213                               float *, float *, int);
214 
215 
216 /*! \brief Driver related */
217 
218 extern void    cgsequ (SuperMatrix *, float *, float *, float *,
219 			float *, float *, int *);
220 extern void    claqgs (SuperMatrix *, float *, float *, float,
221                         float, float, char *);
222 extern void    cgscon (char *, SuperMatrix *, SuperMatrix *,
223 		         float, float *, SuperLUStat_t*, int *);
224 extern float   cPivotGrowth(int, SuperMatrix *, int *,
225                             SuperMatrix *, SuperMatrix *);
226 extern void    cgsrfs (trans_t, SuperMatrix *, SuperMatrix *,
227                        SuperMatrix *, int *, int *, char *, float *,
228                        float *, SuperMatrix *, SuperMatrix *,
229                        float *, float *, SuperLUStat_t*, int *);
230 
231 extern int     sp_ctrsv (char *, char *, char *, SuperMatrix *,
232 			SuperMatrix *, complex *, SuperLUStat_t*, int *);
233 extern int     sp_cgemv (char *, complex, SuperMatrix *, complex *,
234 			int, complex, complex *, int);
235 
236 extern int     sp_cgemm (char *, char *, int, int, int, complex,
237 			SuperMatrix *, complex *, int, complex,
238 			complex *, int);
239 extern         float slamch_(char *);
240 
241 
242 /*! \brief Memory-related */
243 extern int     cLUMemInit (fact_t, void *, int, int, int, int, int,
244                             float, SuperMatrix *, SuperMatrix *,
245                             GlobalLU_t *, int **, complex **);
246 extern void    cSetRWork (int, int, complex *, complex **, complex **);
247 extern void    cLUWorkFree (int *, complex *, GlobalLU_t *);
248 extern int     cLUMemXpand (int, int, MemType, int *, GlobalLU_t *);
249 
250 extern complex  *complexMalloc(int);
251 extern complex  *complexCalloc(int);
252 extern float  *floatMalloc(int);
253 extern float  *floatCalloc(int);
254 extern int     cmemory_usage(const int, const int, const int, const int);
255 extern int     cQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
256 extern int     ilu_cQuerySpace (SuperMatrix *, SuperMatrix *, mem_usage_t *);
257 
258 /*! \brief Auxiliary routines */
259 extern void    creadhb(int *, int *, int *, complex **, int **, int **);
260 extern void    creadrb(int *, int *, int *, complex **, int **, int **);
261 extern void    creadtriple(int *, int *, int *, complex **, int **, int **);
262 extern void    cCompRow_to_CompCol(int, int, int, complex*, int*, int*,
263 		                   complex **, int **, int **);
264 extern void    cfill (complex *, int, complex);
265 extern void    cinf_norm_error (int, SuperMatrix *, complex *);
266 extern void    PrintPerf (SuperMatrix *, SuperMatrix *, mem_usage_t *,
267 			 complex, complex, complex *, complex *, char *);
268 extern float  sqselect(int, float *, int);
269 
270 
271 /*! \brief Routines for debugging */
272 extern void    cPrint_CompCol_Matrix(char *, SuperMatrix *);
273 extern void    cPrint_SuperNode_Matrix(char *, SuperMatrix *);
274 extern void    cPrint_Dense_Matrix(char *, SuperMatrix *);
275 extern void    cprint_lu_col(char *, int, int, int *, GlobalLU_t *);
276 extern int     print_double_vec(char *, int, double *);
277 extern void    check_tempv(int, complex *);
278 
279 #ifdef __cplusplus
280   }
281 #endif
282 
283 #endif /* __SUPERLU_cSP_DEFS */
284 
285