Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Const correctness2 #15

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions EVSL_1.1.1/DIRECT/Interface/evsl_cxsparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ int SetupBSolDirect(csrMat *B, void **data) {
/** @brief Solver function of B
*
* */
void BSolDirect(double *b, double *x, void *data) {
void BSolDirect(const double *b, double *x, void *data) {
BSolDataDirect *Bsol_data = (BSolDataDirect *) data;
cs_dis *S = Bsol_data->S;
cs_din *N = Bsol_data->N;
Expand All @@ -145,7 +145,7 @@ void BSolDirect(double *b, double *x, void *data) {
/** @brief Solver function of L^{T}
* x = L^{-T}*b
* */
void LTSolDirect(double *b, double *x, void *data) {
void LTSolDirect(const double *b, double *x, void *data) {
BSolDataDirect *Bsol_data = (BSolDataDirect *) data;
cs_dis *S = Bsol_data->S;
cs_din *N = Bsol_data->N;
Expand Down Expand Up @@ -320,7 +320,7 @@ int SetupASIGMABSolDirect(csrMat *A, csrMat *BB, int num,
* @warning: This function MUST be of this prototype
*
*------------------------------------------------------------------*/
void ASIGMABSolDirect(int n, double *br, double *bi, double *xr,
void ASIGMABSolDirect(int n, const double *br, const double *bi, double *xr,
double *xz, void *data) {

int i;
Expand Down
6 changes: 3 additions & 3 deletions EVSL_1.1.1/DIRECT/Interface/evsl_direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

/* functions for B solve */
int SetupBSolDirect(csrMat *B, void **data);
void BSolDirect(double *b, double *x, void *data);
void LTSolDirect(double *b, double *x, void *data);
void BSolDirect(const double *b, double *x, void *data);
void LTSolDirect(const double *b, double *x, void *data);
void FreeBSolDirectData(void *data);

/* functions for A-SIGMA*B solve */
int SetupASIGMABSolDirect(csrMat *A, csrMat *BB, int num, EVSL_Complex *zk, void **data);
void ASIGMABSolDirect(int n, double *br, double *bi, double *xr, double *xz, void *data);
void ASIGMABSolDirect(int n, const double *br, const double *bi, double *xr, double *xz, void *data);
void FreeASIGMABSolDirect(int num, void **data);

/* evsl_direct_f90.c */
Expand Down
6 changes: 3 additions & 3 deletions EVSL_1.1.1/DIRECT/Interface/evsl_pardiso.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int SetupBSolDirect(csrMat *B, void **data) {
/** @brief Solver function of B
*
* */
void BSolDirect(double *b, double *x, void *data) {
void BSolDirect(const double *b, double *x, void *data) {
BSolDataDirect *Bsol_data = (BSolDataDirect *) data;

MKL_INT maxfct = 1;
Expand Down Expand Up @@ -243,7 +243,7 @@ void BSolDirect(double *b, double *x, void *data) {
/** @brief Solver function of L^{T}
* x = L^{-T}*b
* */
void LTSolDirect(double *b, double *x, void *data) {
void LTSolDirect(const double *b, double *x, void *data) {
BSolDataDirect *Bsol_data = (BSolDataDirect *) data;

MKL_INT maxfct = 1;
Expand Down Expand Up @@ -512,7 +512,7 @@ int SetupASIGMABSolDirect(csrMat *A, csrMat *BB, int num,
* @warning: This function MUST be of this prototype
*
*------------------------------------------------------------------*/
void ASIGMABSolDirect(int n, double *br, double *bi, double *xr,
void ASIGMABSolDirect(int n, const double *br, const double *bi, double *xr,
double *xz, void *data) {

ASBSolDataDirect *sol_data = (ASBSolDataDirect *) data;
Expand Down
6 changes: 3 additions & 3 deletions EVSL_1.1.1/DIRECT/Interface/evsl_suitesparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ cholmod_dense cholmod_X, cholmod_B, *cholmod_Y=NULL, *cholmod_E=NULL,
/** @brief Solver function of B
*
* */
void BSolDirect(double *b, double *x, void *data) {
void BSolDirect(const double *b, double *x, void *data) {
//int n;

BSolDataDirect *Bsol_data = (BSolDataDirect *) data;
Expand Down Expand Up @@ -212,7 +212,7 @@ void FreeBSolDirectData(void *vdata) {
/** @brief Solver function of L^{T}
* x = L^{-T}*b
* */
void LTSolDirect(double *b, double *x, void *data) {
void LTSolDirect(const double *b, double *x, void *data) {
//int n;

BSolDataDirect *Bsol_data = (BSolDataDirect *) data;
Expand Down Expand Up @@ -246,7 +246,7 @@ void LTSolDirect(double *b, double *x, void *data) {
* @warning: This function MUST be of this prototype
*
*------------------------------------------------------------------*/
void ASIGMABSolDirect(int n, double *br, double *bi, double *xr,
void ASIGMABSolDirect(int n, const double *br, const double *bi, double *xr,
double *xz, void *data) {
void* Numeric = data;
double Control[UMFPACK_CONTROL];
Expand Down
44 changes: 22 additions & 22 deletions EVSL_1.1.1/INC/evsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,28 @@
)

/*- - - - - - - - - cheblanNr.c */
int ChebLanNr(double *intv, int maxit, double tol, double *vinit, polparams *pol, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats);
int ChebLanNr(const double *intv, int maxit, double tol, const double *vinit, const polparams* pol, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats);

/*- - - - - - - - - cheblanTr.c */
int ChebLanTr(int lanm, int nev, double *intv, int maxit, double tol, double *vinit, polparams *pol, int *nev2, double **vals, double **W, double **resW, FILE *fstats);
int ChebLanTr(int lanm, int nev, const double *intv, int maxit, double tol, const double *vinit, const polparams *pol, int *nev2, double **vals, double **W, double **resW, FILE *fstats);

/*- - - - - - - - - chebpoly.c */
void set_pol_def(polparams *pol);
int find_pol(double *intv, polparams *pol);
int find_pol(const double *intv, polparams *pol);
void free_pol(polparams *pol);
/* int ChebAv(polparams *pol, double *v, double *y, double *w); */

/*- - - - - - - - - chebsi.c */
int ChebSI(int nev, double *intv, int maxit, double tol, double *vinit, polparams *pol, int *nevo, double **lamo, double **Yo, double **reso, FILE *fstats);
int ChebSI(int nev, const double *intv, int maxit, double tol, const double *vinit, const polparams *pol, int *nevo, double **lamo, double **Yo, double **reso, FILE *fstats);

/*- - - - - - - - - - dos_utils.c */
void SetupBPol(int n, int max_deg, double tol, double lmin, double lmax, double (*ffun)(double), BSolDataPol *data);
void SetupPolRec(int n, int max_deg, double tol, double lmin, double lmax, BSolDataPol *data);
void SetupPolSqrt(int n, int max_deg, double tol, double lmin, double lmax, BSolDataPol *data);
void FreeBSolPolData(BSolDataPol *data);
void BSolPol(double *b, double *x, void *data);
void extrDiagCsr(csrMat *B, double *d);
void diagScalCsr(csrMat *A, double *d);
void BSolPol(const double *b, double *x, void *data);
void extrDiagCsr(const csrMat *B, double *d);
void diagScalCsr(csrMat *A, const double *d);

/*- - - - - - - - - evsl_memory.c */
void *_evsl_Malloc(size_t nbytes);
Expand All @@ -106,10 +106,10 @@ void *_evsl_Realloc(void *ptr, size_t nbytes);
void _evsl_Free(void *ptr);

/*- - - - - - - - - exDos.c */
int exDOS(double *vals, int n, int npts, double *x, double *y, double *intv);
int exDOS(const double *vals, int n, int npts, double *x, double *y, const double *intv);

/*- - - - - - - - - lanbounds.c */
int LanBounds(int msteps, double *v, double *lmin, double *lmax);
int LanBounds(int msteps, const double *v, double *lmin, double *lmax);

/*- - - - - - - - - - landos.c */
// Computes the density of states (DOS, or spectral density)
Expand All @@ -119,41 +119,41 @@ int LanDos(const int nvec, int msteps, const int npts, double *xdos, double *ydo
int LanDosG(const int nvec, int msteps, const int npts, double *xdos, double *ydos, double *neig, const double *const intv);

/*- - - - - - - - - lanTrbounds.c */
int LanTrbounds(int lanm, int maxit, double tol, double *vinit, int bndtype, double *lammin, double *lammax, FILE *fstats);
int LanTrbounds(int lanm, int maxit, double tol, const double *vinit, int bndtype, double *lammin, double *lammax, FILE *fstats);

/*- - - -- - - - - - misc_la.c */
int scalEigVec(int n, int nev, double *Y, double* sqrtdiag);

/*- - - - - - - - - ratfilter.c */
void set_ratf_def(ratparams *rat);
int find_ratf(double *intv, ratparams *rat);
int find_ratf(const double *intv, ratparams *rat);
int set_ratf_solfunc(ratparams *rat, csrMat *A, csrMat *B, SolFuncC *funcs, void **data);
void free_rat(ratparams *rat);

/*- - - - - - - - - ratlanNr.c */
int RatLanNr(double *intv, int maxit, double tol, double *vinit, ratparams *rat, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats);
int RatLanNr(const double *intv, int maxit, double tol, const double *vinit, ratparams *rat, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats);

/*- - - - - - - - - ratlanTr.c */
int RatLanTr(int lanm, int nev, double *intv, int maxit, double tol, double *vinit, ratparams *rat, int *nev2, double **vals, double **W, double **resW, FILE *fstats);
int RatLanTr(int lanm, int nev, const double *intv, int maxit, double tol, const double *vinit, ratparams *rat, int *nev2, double **vals, double **W, double **resW, FILE *fstats);

/*- - - - - - - - - spmat.c */
void csr_copy(csrMat *A, csrMat *B, int allocB);
void csr_copy(const csrMat *A, csrMat *B, int allocB);
// convert a COO matrix to a CSR matrix
int cooMat_to_csrMat(int cooidx, cooMat *coo, csrMat *csr);
int cooMat_to_csrMat(int cooidx, const cooMat *coo, csrMat *csr);
// free a CSR
void free_csr(csrMat *csr);
// free a COO
void free_coo(cooMat *coo);
// matvec y = A*x
void matvec_csr(double *x, double *y, void *data);
void matvec_csr(const double *x, double *y, void *data);
/* add two csr matrices */
int matadd(double alp, double bet, csrMat *A, csrMat *B, csrMat *C, int *mapA, int *mapB);
int matadd(double alp, double bet, const csrMat *A, const csrMat *B, csrMat *C, int *mapA, int *mapB);
/* sparse identity */
int speye(int n, csrMat *A);
/* extract upper triangular part of A */
void triuCsr(csrMat *A, csrMat *U);
void triuCsr(const csrMat *A, csrMat *U);

int arrays_copyto_csrMat(int nrow, int ncol, int *ia, int *ja, double *a, csrMat *A);
int arrays_copyto_csrMat(int nrow, int ncol, const int *ia, const int *ja, const double *a, csrMat *A);
/*- - - - - - - - - evsl.c */
/* set an external matvec function */
int SetAMatvec(int n, MVFunc func, void *data);
Expand All @@ -175,11 +175,11 @@ int EVSLFinish();
void SetDiagScal(double *ds);

/*- - - - - - - - - spslicer.c */
int spslicer(double *sli, double *mu, int Mdeg, double *intv, int n_int, int npts);
int kpmdos(int Mdeg, int damping, int nvec, double *ab, double *mu, double *ecnt);
int spslicer(double *sli, const double *mu, int Mdeg, const double *intv, int n_int, int npts);
int kpmdos(int Mdeg, int damping, int nvec, const double *ab, double *mu, double *ecnt);

/*- - - - - - - - - - spslicer2.c */
void spslicer2(double *xi, double *yi, int n_int, int npts, double *sli);
void spslicer2(const double *xi, double *yi, int n_int, int npts, double *sli);

/*- - - - - - - - - timing.c */
double evsl_timer();
Expand Down
64 changes: 32 additions & 32 deletions EVSL_1.1.1/INC/internal_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,43 +29,43 @@
/*- - - - - - - - - chebpoly.c */
int chebxCoefd(int m, double gam, int damping, double *mu);
int dampcf(int m, int damping, double *jac);
int chebxPltd(int m, double *mu, int n, double *xi, double *yi);
int ChebAv(polparams *pol, double *v, double *y, double *w);
int chebxPltd(int m, const double *mu, int n, const double *xi, double *yi);
int ChebAv(const polparams *pol, const double *v, double *y, double *w);
void chext(polparams *pol, double aIn, double bIn);

/*- - - - - - - - - dos_utils.c */
int apfun(const double c, const double h, const double* xi, double (*ffun)(double), const int npts, double* yi);
double rec(const double a);
double isqrt(const double a);
int pnav(double *mu, const int m, const double cc, const double dd, double *v, double *y, double *w);
int pnav(const double *mu, const int m, const double cc, const double dd, const double *v, double *y, double *w);
int lsPol(double (*ffun)(double), BSolDataPol *pol);

/*- - - - - - - - - dump.c */
void savemat(csrMat *A, const char *fn);
void savedensemat(double *A, int lda, int m, int n, const char *fn);
void savemat(const csrMat *A, const char *fn);
void savedensemat(const double *A, int lda, int m, int n, const char *fn);
void save_vec(int n, const double *x, const char fn[]);

/*- - - - - - - - - misc_la.c */
int SymmTridEig(double *eigVal, double *eigVec, int n, const double *diag, const double *sdiag);
int SymmTridEigS(double *eigVal, double *eigVec, int n, double vl, double vu, int *nevO, const double *diag, const double *sdiag);
void SymEigenSolver(int n, double *A, int lda, double *Q, int ldq, double *lam);
void CGS_DGKS(int n, int k, int i_max, double *Q, double *v, double *nrmv, double *w);
void CGS_DGKS2(int n, int k, int i_max, double *Z, double *Q, double *v, double *w);
void orth(double *V, int n, int k, double *Vo, double *work);
void SymEigenSolver(int n, const double *A, int lda, double *Q, int ldq, double *lam);
void CGS_DGKS(int n, int k, int i_max, const double *Q, double *v, double *nrmv, double *w);
void CGS_DGKS2(int n, int k, int i_max, const double *Z, const double *Q, double *v, double *w);
void orth(const double *V, int n, int k, double *Vo, double *work);

/*- - - - - - - - - ratfilter.c */
void contQuad(int method, int n, EVSL_Complex *zk);
void ratf2p2(int n, int *mulp, EVSL_Complex *zk, EVSL_Complex *alp, int m, double *z, double *x);
void ratf2p2(int n, const int *mulp, const EVSL_Complex *zk, const EVSL_Complex *alp, int m, const double *z, double *x);
void pfe2(EVSL_Complex s1, EVSL_Complex s2, int k1, int k2, EVSL_Complex* alp, EVSL_Complex* bet);
EVSL_Complex integg2(EVSL_Complex s1, EVSL_Complex s2, EVSL_Complex* alp, int k1, EVSL_Complex* bet, int k2, double a, double b);
void weights(int n, EVSL_Complex* zk, int* pow, double lambda, EVSL_Complex* omega);
int scaleweigthts(int n, double a, double b, EVSL_Complex *zk, int* pow, EVSL_Complex* omegaM);
void weights(int n, const EVSL_Complex* zk, const int* pow, double lambda, EVSL_Complex* omega);
int scaleweigthts(int n, double a, double b, EVSL_Complex *zk, const int* pow, EVSL_Complex* omegaM);

/*- - - - - - - - - ratlanNr.c */
void RatFiltApply(int n, ratparams *rat, double *b, double *x, double *w3);
void RatFiltApply(int n, const ratparams *rat, const double *b, double *x, double *w3);

/*- - - - - - - - - - simpson.c */
void simpson(double *xi, double *yi, int npts);
void simpson(const double *xi, double *yi, int npts);

/*- - - - - - - - - spmat.c */
// memory allocation/reallocation for a CSR matrix
Expand All @@ -77,19 +77,19 @@ int time_seeder();

/*- - - - - - - - - vect.c */
void vecset(int n, double t, double *v);
void vec_perm(int n, int *p, double *x, double *y);
void vec_iperm(int n, int *p, double *x, double *y);
void vec_perm(int n, const int *p, const double *x, double *y);
void vec_iperm(int n, const int *p, const double *x, double *y);

/*------------------- inline functions */
/**
* @brief y = A * x
* This is the matvec function for the matrix A in evsldata
*/
static inline void matvec_A(double *x, double *y) {
static inline void matvec_A(const double *x, double *y) {
CHKERR(!evsldata.Amv);
double tms = evsl_timer();
const double tms = evsl_timer();
evsldata.Amv->func(x, y, evsldata.Amv->data);
double tme = evsl_timer();
const double tme = evsl_timer();
evslstat.t_mvA += tme - tms;
evslstat.n_mvA ++;
}
Expand All @@ -98,11 +98,11 @@ static inline void matvec_A(double *x, double *y) {
* @brief y = B * x
* This is the matvec function for the matrix B in evsldata
*/
static inline void matvec_B(double *x, double *y) {
static inline void matvec_B(const double *x, double *y) {
CHKERR(!evsldata.Bmv);
double tms = evsl_timer();
const double tms = evsl_timer();
evsldata.Bmv->func(x, y, evsldata.Bmv->data);
double tme = evsl_timer();
const double tme = evsl_timer();
evslstat.t_mvB += tme - tms;
evslstat.n_mvB ++;
}
Expand All @@ -111,11 +111,11 @@ static inline void matvec_B(double *x, double *y) {
* @brief y = B \ x
* This is the solve function for the matrix B in evsldata
*/
static inline void solve_B(double *x, double *y) {
static inline void solve_B(const double *x, double *y) {
CHKERR(!evsldata.Bsol);
double tms = evsl_timer();
const double tms = evsl_timer();
evsldata.Bsol->func(x, y, evsldata.Bsol->data);
double tme = evsl_timer();
const double tme = evsl_timer();
evslstat.t_svB += tme - tms;
evslstat.n_svB ++;
}
Expand All @@ -124,11 +124,11 @@ static inline void solve_B(double *x, double *y) {
* @brief y = LT \ x or y = SQRT(B) \ x
* This is the solve function for the matrix B in evsldata
*/
static inline void solve_LT(double *x, double *y) {
static inline void solve_LT(const double *x, double *y) {
CHKERR(!evsldata.LTsol);
double tms = evsl_timer();
const double tms = evsl_timer();
evsldata.LTsol->func(x, y, evsldata.LTsol->data);
double tme = evsl_timer();
const double tme = evsl_timer();
evslstat.t_svLT += tme - tms;
evslstat.n_svLT ++;
}
Expand All @@ -138,19 +138,19 @@ static inline void solve_LT(double *x, double *y) {
* This is the solve function for the complex shifted matrix
*/
static inline void solve_ASigB(EVSLASIGMABSol *sol, int n,
double *br, double *bz,
const double *br, const double *bz,
double *xr, double *xz) {
double tms = evsl_timer();
const double tms = evsl_timer();
(sol->func)(n, br, bz, xr, xz, sol->data);
double tme = evsl_timer();
const double tme = evsl_timer();
evslstat.t_svASigB+= tme - tms;
evslstat.n_svASigB ++;
}

/**
* @brief check if an interval is valid
* */
static inline int check_intv(double *intv, FILE *fstats) {
static inline int check_intv(const double *intv, FILE *fstats) {
/* intv[4]: ( intv[0], intv[1] ) is the inteval of interest
* ( intv[2], intv[3] ) is the spectrum bounds
* return 0: ok
Expand Down
6 changes: 3 additions & 3 deletions EVSL_1.1.1/INC/struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ typedef struct _polparams {
* be the solution (complex vector), and "data" contains all the
* data needed by the solver.
*/
typedef void (*SolFuncC)(int n, double *br, double *bz, double *xr, double *xz, void *data);
typedef void (*SolFuncC)(int n, const double *br, const double *bz, double *xr, double *xz, void *data);

/**
* @brief function prototype for applying the solve B x = b
*/
typedef void (*SolFuncR)(double *b, double *x, void *data);
typedef void (*SolFuncR)(const double *b, double *x, void *data);

/**
* @brief matvec function prototype
*/
typedef void (*MVFunc)(double *x, double *y, void *data);
typedef void (*MVFunc)(const double *x, double *y, void *data);

/*!
* @brief user-provided function and data for solving (A - SIGMA*B) x = b
Expand Down
Loading