Skip to content

Commit

Permalink
BLD: Replace complex occurences with singlecomplex in SuperLU
Browse files Browse the repository at this point in the history
- Replace all occurences of complex with singlecomplex
- Add a second patch file for the complex changes (to make it easier
  to remove once the upstream patch is merged)

Closes scipygh-19036.
  • Loading branch information
lysnikolaou authored and rgommers committed Aug 15, 2023
1 parent d4efe36 commit ab8e93b
Show file tree
Hide file tree
Showing 39 changed files with 2,427 additions and 336 deletions.
30 changes: 15 additions & 15 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/ccolumn_bmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ at the top-level directory.
/*
* Function prototypes
*/
void cusolve(int, int, complex*, complex*);
void clsolve(int, int, complex*, complex*);
void cmatvec(int, int, int, complex*, complex*, complex*);
void cusolve(int, int, singlecomplex*, singlecomplex*);
void clsolve(int, int, singlecomplex*, singlecomplex*);
void cmatvec(int, int, int, singlecomplex*, singlecomplex*, singlecomplex*);



Expand All @@ -60,8 +60,8 @@ int
ccolumn_bmod (
const int jcol, /* in */
const int nseg, /* in */
complex *dense, /* in */
complex *tempv, /* working array */
singlecomplex *dense, /* in */
singlecomplex *tempv, /* working array */
int *segrep, /* in */
int *repfnz, /* in */
int fpanelc, /* in -- first column in the current panel */
Expand All @@ -76,7 +76,7 @@ ccolumn_bmod (
ftcs3 = _cptofcd("U", strlen("U"));
#endif
int incx = 1, incy = 1;
complex alpha, beta;
singlecomplex alpha, beta;

/* krep = representative of current k-th supernode
* fsupc = first supernodal column
Expand All @@ -86,7 +86,7 @@ ccolumn_bmod (
* kfnz = first nonz in the k-th supernodal segment
* no_zeros = no of leading zeros in a supernodal U-segment
*/
complex ukj, ukj1, ukj2;
singlecomplex ukj, ukj1, ukj2;
int luptr, luptr1, luptr2;
int fsupc, nsupc, nsupr, segsze;
int nrow; /* No of rows in the matrix of matrix-vector */
Expand All @@ -99,22 +99,22 @@ ccolumn_bmod (
panel and the first column of the current snode. */
int *xsup, *supno;
int *lsub, *xlsub;
complex *lusup;
singlecomplex *lusup;
int *xlusup;
int nzlumax;
complex *tempv1;
complex zero = {0.0, 0.0};
complex one = {1.0, 0.0};
complex none = {-1.0, 0.0};
complex comp_temp, comp_temp1;
singlecomplex *tempv1;
singlecomplex zero = {0.0, 0.0};
singlecomplex one = {1.0, 0.0};
singlecomplex none = {-1.0, 0.0};
singlecomplex comp_temp, comp_temp1;
int mem_error;
flops_t *ops = stat->ops;

xsup = Glu->xsup;
supno = Glu->supno;
lsub = Glu->lsub;
xlsub = Glu->xlsub;
lusup = (complex *) Glu->lusup;
lusup = (singlecomplex *) Glu->lusup;
xlusup = Glu->xlusup;
nzlumax = Glu->nzlumax;
jcolp1 = jcol + 1;
Expand Down Expand Up @@ -295,7 +295,7 @@ ccolumn_bmod (
while ( new_next > nzlumax ) {
if (mem_error = cLUMemXpand(jcol, nextlu, LUSUP, &nzlumax, Glu))
return (mem_error);
lusup = (complex *) Glu->lusup;
lusup = (singlecomplex *) Glu->lusup;
lsub = Glu->lsub;
}

Expand Down
10 changes: 5 additions & 5 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/ccopy_to_ucol.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ccopy_to_ucol(
int *segrep, /* in */
int *repfnz, /* in */
int *perm_r, /* in */
complex *dense, /* modified - reset to zero on return */
singlecomplex *dense, /* modified - reset to zero on return */
GlobalLU_t *Glu /* modified */
)
{
Expand All @@ -53,16 +53,16 @@ ccopy_to_ucol(
int new_next, mem_error;
int *xsup, *supno;
int *lsub, *xlsub;
complex *ucol;
singlecomplex *ucol;
int *usub, *xusub;
int nzumax;
complex zero = {0.0, 0.0};
singlecomplex zero = {0.0, 0.0};

xsup = Glu->xsup;
supno = Glu->supno;
lsub = Glu->lsub;
xlsub = Glu->xlsub;
ucol = (complex *) Glu->ucol;
ucol = (singlecomplex *) Glu->ucol;
usub = Glu->usub;
xusub = Glu->xusub;
nzumax = Glu->nzumax;
Expand All @@ -86,7 +86,7 @@ ccopy_to_ucol(
while ( new_next > nzumax ) {
if (mem_error = cLUMemXpand(jcol, nextu, UCOL, &nzumax, Glu))
return (mem_error);
ucol = (complex *) Glu->ucol;
ucol = (singlecomplex *) Glu->ucol;
if (mem_error = cLUMemXpand(jcol, nextu, USUB, &nzumax, Glu))
return (mem_error);
usub = Glu->usub;
Expand Down
10 changes: 5 additions & 5 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cdiagonal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ int cfill_diag(int n, NCformat *Astore)
/* fill explicit zeros on the diagonal entries, so that the matrix is not
structurally singular. */
{
complex *nzval = (complex *)Astore->nzval;
singlecomplex *nzval = (singlecomplex *)Astore->nzval;
int *rowind = Astore->rowind;
int *colptr = Astore->colptr;
int nnz = colptr[n];
int fill = 0;
complex *nzval_new;
complex zero = {0.0, 0.0};
singlecomplex *nzval_new;
singlecomplex zero = {0.0, 0.0};
int *rowind_new;
int i, j, diag;

Expand Down Expand Up @@ -75,12 +75,12 @@ int cfill_diag(int n, NCformat *Astore)
int cdominate(int n, NCformat *Astore)
/* make the matrix diagonally dominant */
{
complex *nzval = (complex *)Astore->nzval;
singlecomplex *nzval = (singlecomplex *)Astore->nzval;
int *rowind = Astore->rowind;
int *colptr = Astore->colptr;
int nnz = colptr[n];
int fill = 0;
complex *nzval_new;
singlecomplex *nzval_new;
int *rowind_new;
int i, j, diag;
double s;
Expand Down
6 changes: 3 additions & 3 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgscon.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ cgscon(char *norm, SuperMatrix *L, SuperMatrix *U,
/* Local variables */
int kase, kase1, onenrm, i;
float ainvnm;
complex *work;
singlecomplex *work;
int isave[3];
extern int crscl_(int *, complex *, complex *, int *);
extern int crscl_(int *, singlecomplex *, singlecomplex *, int *);

extern int clacon2_(int *, complex *, complex *, float *, int *, int []);
extern int clacon2_(int *, singlecomplex *, singlecomplex *, float *, int *, int []);


/* Test the input parameters. */
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgsequ.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cgsequ(SuperMatrix *A, float *r, float *c, float *rowcnd,

/* Local variables */
NCformat *Astore;
complex *Aval;
singlecomplex *Aval;
int i, j, irow;
float rcmin, rcmax;
float bignum, smlnum;
Expand Down
6 changes: 3 additions & 3 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgsisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
{

DNformat *Bstore, *Xstore;
complex *Bmat, *Xmat;
singlecomplex *Bmat, *Xmat;
int ldb, ldx, nrhs, n;
SuperMatrix *AA;/* A in SLU_NC format used by the factorization routine.*/
SuperMatrix AC; /* Matrix postmultiplied by Pc */
Expand Down Expand Up @@ -549,7 +549,7 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
int nnz = Astore->nnz;
int *colptr = Astore->colptr;
int *rowind = Astore->rowind;
complex *nzval = (complex *)Astore->nzval;
singlecomplex *nzval = (singlecomplex *)Astore->nzval;

if ( mc64 ) {
t0 = SuperLU_timer_();
Expand Down Expand Up @@ -678,7 +678,7 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
}

if ( nrhs > 0 ) { /* Solve the system */
complex *rhs_work;
singlecomplex *rhs_work;

/* Scale and permute the right-hand side if equilibration
and permutation from MC64 were performed. */
Expand Down
20 changes: 10 additions & 10 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgsitrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,21 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
iswap is the inverse of swap. After the
factorization, it is equal to perm_r. */
int *iwork;
complex *cwork;
singlecomplex *cwork;
int *segrep, *repfnz, *parent, *xplore;
int *panel_lsub; /* dense[]/panel_lsub[] pair forms a w-wide SPA */
int *marker, *marker_relax;
complex *dense, *tempv;
singlecomplex *dense, *tempv;
float *stempv;
int *relax_end, *relax_fsupc;
complex *a;
singlecomplex *a;
int *asub;
int *xa_begin, *xa_end;
int *xsup, *supno;
int *xlsub, *xlusup, *xusub;
int nzlumax;
float *amax;
complex drop_sum;
singlecomplex drop_sum;
float alpha, omega; /* used in MILU, mimicing DRIC */
float *swork2; /* used by the second dropping rule */

Expand Down Expand Up @@ -247,7 +247,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
int nnzAj; /* number of nonzeros in A(:,1:j) */
int nnzLj, nnzUj;
double tol_L = drop_tol, tol_U = drop_tol;
complex zero = {0.0, 0.0};
singlecomplex zero = {0.0, 0.0};
float one = 1.0;

/* Executable */
Expand Down Expand Up @@ -492,7 +492,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
xlsub[jj + 1]++;
assert(xlusup[jj]==xlusup[jj+1]);
xlusup[jj + 1]++;
((complex *) Glu->lusup)[xlusup[jj]] = zero;
((singlecomplex *) Glu->lusup)[xlusup[jj]] = zero;

/* Choose a row index (pivrow) for fill-in */
for (i = jj; i < n; i++)
Expand Down Expand Up @@ -628,21 +628,21 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
may have changed, */
((SCformat *)L->Store)->nnz = nnzL;
((SCformat *)L->Store)->nsuper = Glu->supno[n];
((SCformat *)L->Store)->nzval = (complex *) Glu->lusup;
((SCformat *)L->Store)->nzval = (singlecomplex *) Glu->lusup;
((SCformat *)L->Store)->nzval_colptr = Glu->xlusup;
((SCformat *)L->Store)->rowind = Glu->lsub;
((SCformat *)L->Store)->rowind_colptr = Glu->xlsub;
((NCformat *)U->Store)->nnz = nnzU;
((NCformat *)U->Store)->nzval = (complex *) Glu->ucol;
((NCformat *)U->Store)->nzval = (singlecomplex *) Glu->ucol;
((NCformat *)U->Store)->rowind = Glu->usub;
((NCformat *)U->Store)->colptr = Glu->xusub;
} else {
cCreate_SuperNode_Matrix(L, A->nrow, min_mn, nnzL,
(complex *) Glu->lusup, Glu->xlusup,
(singlecomplex *) Glu->lusup, Glu->xlusup,
Glu->lsub, Glu->xlsub, Glu->supno, Glu->xsup,
SLU_SC, SLU_C, SLU_TRLU);
cCreate_CompCol_Matrix(U, min_mn, min_mn, nnzU,
(complex *) Glu->ucol, Glu->usub, Glu->xusub,
(singlecomplex *) Glu->ucol, Glu->usub, Glu->xusub,
SLU_NC, SLU_C, SLU_TRU);
}

Expand Down
20 changes: 10 additions & 10 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgsrfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,34 +149,34 @@ cgsrfs(trans_t trans, SuperMatrix *A, SuperMatrix *L, SuperMatrix *U,

/* Table of constant values */
int ione = 1;
complex ndone = {-1., 0.};
complex done = {1., 0.};
singlecomplex ndone = {-1., 0.};
singlecomplex done = {1., 0.};

/* Local variables */
NCformat *Astore;
complex *Aval;
singlecomplex *Aval;
SuperMatrix Bjcol;
DNformat *Bstore, *Xstore, *Bjcol_store;
complex *Bmat, *Xmat, *Bptr, *Xptr;
singlecomplex *Bmat, *Xmat, *Bptr, *Xptr;
int kase;
float safe1, safe2;
int i, j, k, irow, nz, count, notran, rowequ, colequ;
int ldb, ldx, nrhs;
float s, xk, lstres, eps, safmin;
char transc[1];
trans_t transt;
complex *work;
singlecomplex *work;
float *rwork;
int *iwork;
int isave[3];

extern int clacon2_(int *, complex *, complex *, float *, int *, int []);
extern int clacon2_(int *, singlecomplex *, singlecomplex *, float *, int *, int []);
#ifdef _CRAY
extern int CCOPY(int *, complex *, int *, complex *, int *);
extern int CSAXPY(int *, complex *, complex *, int *, complex *, int *);
extern int CCOPY(int *, singlecomplex *, int *, singlecomplex *, int *);
extern int CSAXPY(int *, singlecomplex *, singlecomplex *, int *, singlecomplex *, int *);
#else
extern int ccopy_(int *, complex *, int *, complex *, int *);
extern int caxpy_(int *, complex *, complex *, int *, complex *, int *);
extern int ccopy_(int *, singlecomplex *, int *, singlecomplex *, int *);
extern int caxpy_(int *, singlecomplex *, singlecomplex *, int *, singlecomplex *, int *);
#endif

Astore = A->Store;
Expand Down
2 changes: 1 addition & 1 deletion scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgssvx.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ cgssvx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,


DNformat *Bstore, *Xstore;
complex *Bmat, *Xmat;
singlecomplex *Bmat, *Xmat;
int ldb, ldx, nrhs;
SuperMatrix *AA;/* A in SLU_NC format used by the factorization routine.*/
SuperMatrix AC; /* Matrix postmultiplied by Pc */
Expand Down
14 changes: 7 additions & 7 deletions scipy/sparse/linalg/_dsolve/SuperLU/SRC/cgstrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ cgstrf (superlu_options_t *options, SuperMatrix *A,
options->Fact == SamePattern_SameRowPerm */
int *iperm_c; /* inverse of perm_c */
int *iwork;
complex *cwork;
singlecomplex *cwork;
int *segrep, *repfnz, *parent, *xplore;
int *panel_lsub; /* dense[]/panel_lsub[] pair forms a w-wide SPA */
int *xprune;
int *marker;
complex *dense, *tempv;
singlecomplex *dense, *tempv;
int *relax_end;
complex *a;
singlecomplex *a;
int *asub;
int *xa_begin, *xa_end;
int *xsup, *supno;
Expand Down Expand Up @@ -431,21 +431,21 @@ cgstrf (superlu_options_t *options, SuperMatrix *A,
may have changed, */
((SCformat *)L->Store)->nnz = nnzL;
((SCformat *)L->Store)->nsuper = Glu->supno[n];
((SCformat *)L->Store)->nzval = (complex *) Glu->lusup;
((SCformat *)L->Store)->nzval = (singlecomplex *) Glu->lusup;
((SCformat *)L->Store)->nzval_colptr = Glu->xlusup;
((SCformat *)L->Store)->rowind = Glu->lsub;
((SCformat *)L->Store)->rowind_colptr = Glu->xlsub;
((NCformat *)U->Store)->nnz = nnzU;
((NCformat *)U->Store)->nzval = (complex *) Glu->ucol;
((NCformat *)U->Store)->nzval = (singlecomplex *) Glu->ucol;
((NCformat *)U->Store)->rowind = Glu->usub;
((NCformat *)U->Store)->colptr = Glu->xusub;
} else {
cCreate_SuperNode_Matrix(L, A->nrow, min_mn, nnzL,
(complex *) Glu->lusup, Glu->xlusup,
(singlecomplex *) Glu->lusup, Glu->xlusup,
Glu->lsub, Glu->xlsub, Glu->supno, Glu->xsup,
SLU_SC, SLU_C, SLU_TRLU);
cCreate_CompCol_Matrix(U, min_mn, min_mn, nnzU,
(complex *) Glu->ucol, Glu->usub, Glu->xusub,
(singlecomplex *) Glu->ucol, Glu->usub, Glu->xusub,
SLU_NC, SLU_C, SLU_TRU);
}

Expand Down
Loading

0 comments on commit ab8e93b

Please sign in to comment.