21 int LanBounds(
int msteps,
double *v,
double *lmin,
double *lmax) {
23 double *alp, *bet, nbet, nalp, t, *V, *Z;
30 msteps =
min(n, msteps);
31 Malloc(alp, msteps,
double);
32 Malloc(bet, msteps,
double);
33 Malloc(V, (msteps+1)*n_l,
double);
36 Malloc(Z, (msteps+1)*n_l,
double);
45 t = 1.0 / sqrt(
DDOT(&n, v, &one, Z, &one));
46 DSCAL(&n, &t, Z, &one);
49 t = 1.0 /
DNRM2(&n, v, &one);
52 DCOPY(&n, v, &one, V, &one);
54 DSCAL(&n, &t, V, &one);
57 for (j=0; j<msteps; j++) {
61 matvec_A(&V[j*n_l], &Z[(j+1)*n_l]);
66 DAXPY(&n, &nbet, &Z[(j-1)*n_l], &one, &Z[(j+1)*n_l], &one);
71 alp[j] =
DDOT(&n, &Z[(j+1)*n_l], &one, &V[j*n_l], &one);
72 wn += alp[j] * alp[j];
76 DAXPY(&n, &nalp, &Z[j*n_l], &one, &Z[(j+1)*n_l], &one);
78 for (i=0; i<=j; i++) {
81 t =
DDOT(&n, &Z[(j+1)*n_l], &one, &V[i*n_l], &one);
83 DAXPY(&n, &mt, &Z[i*n_l], &one, &Z[(j+1)*n_l], &one);
87 solve_B(&Z[(j+1)*n_l], &V[(j+1)*n_l]);
91 bet[j] =
DDOT(&n, &V[(j+1)*n_l], &one, &Z[(j+1)*n_l], &one);
92 if (bet[j]*(j+1) <
orthTol*wn) {
93 fprintf(stdout,
"lanbounds: lucky break, j=%d, beta=%e, break\n", j, bet[j]);
98 bet[j] = sqrt(bet[j]);
101 DSCAL(&n, &t, &V[(j+1)*n_l], &one);
104 DSCAL(&n, &t, &Z[(j+1)*n_l], &one);
108 double bottomBeta = bet[msteps-1];
110 size_t msteps_l = msteps;
111 Malloc(S, msteps_l*msteps_l,
double);
112 Malloc(ritzVal, msteps,
double);
116 *lmin = ritzVal[0] - fabs(bottomBeta * S[msteps-1]);
117 *lmax = ritzVal[msteps-1] + fabs(bottomBeta * S[msteps_l*msteps_l-1]);
120 double amin, amax, x;
123 for (j=0; j<msteps; j++) {
124 t = fabs(bottomBeta * S[(j+1)*msteps-1]);
126 if (x<amin) amin = x;
128 if (x>amax) amax = x;
double DDOT(int *n, double *x, int *incx, double *y, int *incy)
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 DAXPY(int *n, double *alpha, double *x, int *incx, double *y, int *incy)
int LanBounds(int msteps, double *v, double *lmin, double *lmax)
double DNRM2(int *n, double *x, int *incx)
Defs for blaslapack routines.
evslData evsldata
global variable of EVSL
void DCOPY(int *n, double *dx, int *incx, double *dy, int *incy)