18 #define FILTER_VINIT 1
54 int RatLanNr(
double *intv,
int maxit,
double tol,
double *vinit,
55 ratparams *rat,
int *nevOut,
double **lamo,
double **Wo,
56 double **reso, FILE *fstats) {
58 double tall, tm1 = 0.0, tt;
72 double done = 1.0, dzero = 0.0;
80 maxit =
min(n, maxit);
92 if (check_intv(intv, fstats) < 0) {
94 *lamo = NULL; *Wo = NULL; *reso = NULL;
104 fprintf(fstats,
" ** Rat-LanNr \n");
107 double *V, *dT, *eT, *Z;
108 Malloc(V, n_l*(maxit+1),
double);
111 Malloc(Z, n_l*(maxit+1),
double);
117 Malloc(dT, maxit,
double);
118 Malloc(eT, maxit,
double);
119 double *Rvec, *Lam, *res, *EvalT, *EvecT;
121 Malloc(Lam, maxit,
double);
122 Malloc(res, maxit,
double);
123 Malloc(EvalT, maxit,
double);
128 double *u, *wk, *w2, *vrand = NULL;
129 size_t wk_size = ifGenEv ? 6*n_l : 4*n_l;
130 Malloc(wk, wk_size,
double);
138 DCOPY(&n, V, &one, Z, &one);
141 DCOPY(&n, vinit, &one, Z, &one);
148 t = 1.0 / sqrt(
DDOT(&n, V, &one, Z, &one));
149 DSCAL(&n, &t, Z, &one);
152 t = 1.0 /
DNRM2(&n, V, &one);
155 DSCAL(&n, &t, V, &one);
163 double *zold, *z, *znew;
166 double alpha, nalpha, beta=0.0, nbeta;
169 for (k=0; k<maxit; k++) {
171 zold = k > 0 ? Z+(k-1)*n_l : NULL;
185 DAXPY(&n, &nbeta, zold, &one, znew, &one);
188 alpha =
DDOT(&n, v, &one, znew, &one);
194 DAXPY(&n, &nalpha, z, &one, znew, &one);
201 matvec_B(znew, vnew);
203 beta = sqrt(
DDOT(&n, vnew, &one, znew, &one));
214 fprintf(fstats,
"it %4d: Lucky breakdown, beta = %.15e\n", k, beta);
228 matvec_B(znew, vnew);
229 beta = sqrt(
DDOT(&n, vnew, &one, znew, &one));
232 DSCAL(&n, &t, vnew, &one);
234 DSCAL(&n, &t, znew, &one);
242 DSCAL(&n, &t, vnew, &one);
248 DSCAL(&n, &t, vnew, &one);
251 DSCAL(&n, &t, znew, &one);
259 maxit = 1 + (int) (maxit * 1.5);
260 Realloc(V, (maxit+1)*n_l,
double);
262 Realloc(Z, (maxit+1)*n_l,
double);
275 if ( (k < Ntest || (k-Ntest) % cycle != 0) && k != maxit-1 ) {
287 double vl = bar - DBL_EPSILON, vu = 10000.0;
288 SymmTridEigS(EvalT, EvecT, kdim, vl, vu, &count, dT, eT);
297 for (i=0; i<count; i++) {
299 if (flami + DBL_EPSILON >= bar) {
306 fprintf(fstats,
"k %4d: nconv %4d tr1 %21.15e\n",
311 if ( (fabs(tr1-tr0) < 2e-12) || (fabs(tr1)+fabs(tr0)<1e-10) ) {
318 fprintf(fstats,
"The max number of iterations [%d] has been reached. The eigenvalues computed may not have converged\n", maxit);
322 size_t kdim_l = kdim;
323 Malloc(EvecT, kdim_l*kdim_l,
double);
328 Malloc(Rvec, nconv*n_l,
double);
331 for (i=0; i<count; i++) {
334 if (fabs(flami) < bar) {
337 y = &EvecT[i*kdim_l];
347 DGEMV(&cN, &n, &kdim, &done, Z, &n, y, &one, &dzero, u, &one);
352 t = sqrt(
DDOT(&n, u, &one, w2, &one));
355 t =
DNRM2(&n, u, &one);
363 DSCAL(&n, &t, u, &one);
367 DSCAL(&n, &t, w2, &one);
373 t =
DDOT(&n, wk, &one, u, &one);
375 if (t < aa - DBL_EPSILON || t > bb + DBL_EPSILON) {
382 DAXPY(&n, &nt, w2, &one, wk, &one);
385 DAXPY(&n, &nt, u, &one, wk, &one);
391 for (j=0; j<n; j++) {
397 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
int RatLanNr(double *intv, int maxit, double tol, double *vinit, ratparams *rat, int *nevOut, double **lamo, double **Wo, double **reso, FILE *fstats)
Rational filtering Lanczos process [NON-restarted version].
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)
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 ...
evslData evsldata
global variable of EVSL
#define Realloc(base, nmem, type)
void RatFiltApply(int n, ratparams *rat, double *b, double *x, double *w6)
Apply rational filter R to a vetor b.
double evsl_timer()
evsl timer for mac
void DCOPY(int *n, double *dx, int *incx, double *dy, int *incy)
parameters for rational filter