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