18 #define FILTER_VINIT 1
60 int ChebLanNr(
double *intv,
int maxit,
double tol,
double *vinit,
61 polparams *pol,
int *nevOut,
double **lamo,
double **Wo,
62 double **reso, FILE *fstats) {
64 double tall, tm1 = 0.0, tt;
78 double done = 1.0, dzero = 0.0;
86 maxit =
min(n, maxit);
97 double bar = pol->
bar;
98 double gamB = pol->
gam;
100 if (check_intv(intv, fstats) < 0) {
102 *lamo = NULL; *Wo = NULL; *reso = NULL;
109 fprintf(fstats,
" ** Cheb Poly of deg = %d, gam = %.15e, bar: %.15e\n",
113 if (gamB > 1.0 || gamB < -1.0) {
114 fprintf(stdout,
"gamB error %.15e\n", gamB);
121 fprintf(fstats,
" ** Cheb-LanNr \n");
124 double *V, *dT, *eT, *Z;
125 Malloc(V, n_l*(maxit+1),
double);
128 Malloc(Z, n_l*(maxit+1),
double);
134 Malloc(dT, maxit,
double);
135 Malloc(eT, maxit,
double);
136 double *Rvec, *Lam, *res, *EvalT, *EvecT;
138 Malloc(Lam, maxit,
double);
139 Malloc(res, maxit,
double);
140 Malloc(EvalT, maxit,
double);
145 double *u, *wk, *w2, *vrand = NULL;
146 size_t wk_size = ifGenEv ? 4*n_l : 3*n_l;
147 Malloc(wk, wk_size,
double);
153 ChebAv(pol, vinit, V, wk);
157 DCOPY(&n, vinit, &one, V, &one);
164 t = 1.0 / sqrt(
DDOT(&n, V, &one, Z, &one));
165 DSCAL(&n, &t, Z, &one);
168 t = 1.0 /
DNRM2(&n, V, &one);
171 DSCAL(&n, &t, V, &one);
179 double *zold, *z, *znew;
182 double alpha, nalpha, beta=0.0, nbeta;
185 for (k=0; k<maxit; k++) {
187 zold = k > 0 ? Z+(k-1)*n_l : NULL;
202 DAXPY(&n, &nbeta, zold, &one, znew, &one);
205 alpha =
DDOT(&n, v, &one, znew, &one);
211 DAXPY(&n, &nalpha, z, &one, znew, &one);
219 beta = sqrt(
DDOT(&n, vnew, &one, znew, &one));
230 fprintf(fstats,
"it %4d: Lucky breakdown, beta = %.15e\n", k, beta);
236 ChebAv(pol, vrand, vnew, wk);
243 matvec_B(vnew, znew);
244 beta = sqrt(
DDOT(&n, vnew, &one, znew, &one));
247 DSCAL(&n, &t, vnew, &one);
249 DSCAL(&n, &t, znew, &one);
257 DSCAL(&n, &t, vnew, &one);
263 DSCAL(&n, &t, vnew, &one);
266 DSCAL(&n, &t, znew, &one);
274 maxit = 1 + (int) (maxit * 1.5);
275 Realloc(V, (maxit+1)*n_l,
double);
277 Realloc(Z, (maxit+1)*n_l,
double);
290 if ( (k < Ntest || (k-Ntest) % cycle != 0) && k != maxit-1 ) {
302 double vl = bar - DBL_EPSILON, vu = 2.0;
303 SymmTridEigS(EvalT, EvecT, kdim, vl, vu, &count, dT, eT);
312 for (i=0; i<count; i++) {
314 if (flami + DBL_EPSILON >= bar) {
321 fprintf(fstats,
"k %4d: nconv %4d tr1 %21.15e\n",
326 if ( (fabs(tr1-tr0) < 2e-12) || (fabs(tr1)+fabs(tr0) < 1e-10) ) {
333 fprintf(fstats,
"The max number of iterations [%d] has been reached. The eigenvalues computed may not have converged\n", maxit);
337 size_t kdim_l = kdim;
338 Malloc(EvecT, kdim_l*kdim_l,
double);
343 Malloc(Rvec, nconv*n_l,
double);
346 for (i=0; i<count; i++) {
352 y = &EvecT[i*kdim_l];
361 DGEMV(&cN, &n, &kdim, &done, V, &n, y, &one, &dzero, u, &one);
366 t = sqrt(
DDOT(&n, u, &one, w2, &one));
369 t =
DNRM2(&n, u, &one);
377 DSCAL(&n, &t, u, &one);
381 DSCAL(&n, &t, w2, &one);
387 t =
DDOT(&n, wk, &one, u, &one);
389 if (t < aa - DBL_EPSILON || t > bb + DBL_EPSILON) {
396 DAXPY(&n, &nt, w2, &one, wk, &one);
399 DAXPY(&n, &nt, u, &one, wk, &one);
402 res0 =
DNRM2(&n, wk, &one);
double DDOT(int *n, double *x, int *incx, double *y, int *incy)
void rand_double(int n, double *v)
void CGS_DGKS(int n, int k, int i_max, double *Q, double *v, double *nrmv, double *w)
Classical GS reortho with Daniel, Gragg, Kaufman, Stewart test.
void DSCAL(int *n, double *a, double *x, int *incx)
int SymmTridEig(double *eigVal, double *eigVec, int n, const double *diag, const double *sdiag)
compute all eigenvalues and eigenvectors of a symmetric tridiagonal matrix
This file contains function prototypes and constant definitions internally used in EVSL...
#define Malloc(base, nmem, type)
void DGEMV(char *trans, int *m, int *n, double *alpha, double *a, int *lda, double *x, int *incx, double *beta, double *y, int *incy)
evslStat evslstat
global statistics of EVSL
void CGS_DGKS2(int n, int k, int i_max, double *Z, double *Q, double *v, double *w)
Classical GS reortho. No test. just do i_max times used in generalized ev problems.
void DAXPY(int *n, double *alpha, double *x, int *incx, double *y, int *incy)
int ChebLanNr(double *intv, int maxit, double tol, double *vinit, polparams *pol, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats)
double DNRM2(int *n, double *x, int *incx)
Defs for blaslapack routines.
int SymmTridEigS(double *eigVal, double *eigVec, int n, double vl, double vu, int *nevO, const double *diag, const double *sdiag)
compute eigenvalues and eigenvectors of a symmetric tridiagonal matrix in a slice ...
int ChebAv(polparams *pol, double *v, double *y, double *w)
Computes y=P(A) v, where pn is a Cheb. polynomial expansion
evslData evsldata
global variable of EVSL
parameters for polynomial filter
#define Realloc(base, nmem, type)
double evsl_timer()
evsl timer for mac
void DCOPY(int *n, double *dx, int *incx, double *dy, int *incy)