40 int LanDos(
const int nvec,
int msteps,
int npts,
double *xdos,
double *ydos,
41 double *neig,
const double *
const intv) {
46 "ERROR: landos.c/LanDos only works with the standard eigenvalue "
47 "problem. Please use landosG.c/LanDos for the generalized problem. "
51 double *alp, *bet, nbet, nalp, t, *V;
66 double *S, *ritzVal, *gamma2;
68 size_t msteps_l = msteps;
69 Malloc(S, msteps_l * msteps_l,
double);
70 Malloc(gamma2, msteps,
double);
71 Malloc(ritzVal, msteps,
double);
72 const double lm = intv[2];
73 const double lM = intv[3];
74 const double tolBdwn = 1.e-13 * (abs(lM) + abs(lm));
75 const double aa =
max(intv[0], intv[2]);
76 const double bb =
min(intv[1], intv[3]);
77 const double kappa = 1.25;
78 const int M =
min(msteps, 30);
79 const double H = (lM - lm) / (M - 1);
80 const double sigma = H / sqrt(8 * log(kappa));
81 double sigma2 = 2 * sigma * sigma;
83 const double tol = 1e-08;
84 double width = sigma * sqrt(-2.0 * log(tol));
87 Malloc(alp, msteps,
double);
88 Malloc(bet, msteps,
double);
89 Malloc(V, (msteps + 1) * n_l,
double);
91 for (m = 0; m < nvec; m++) {
94 t =
DDOT(&n, v, &one, v, &one);
98 DSCAL(&n, &t, v, &one);
99 DCOPY(&n, v, &one, V, &one);
102 for (j = 0; j < msteps; j++) {
104 matvec_A(&V[j * n_l], &V[(j + 1) * n_l]);
108 DAXPY(&n, &nbet, &V[(j - 1) * n_l], &one, &V[(j + 1) * n_l], &one);
111 alp[j] =
DDOT(&n, &V[(j + 1) * n_l], &one, &V[j * n_l], &one);
112 wn += alp[j] * alp[j];
115 DAXPY(&n, &nalp, &V[j * n_l], &one, &V[(j + 1) * n_l], &one);
117 for (i = 0; i <= j; i++) {
118 t =
DDOT(&n, &V[(j + 1) * n_l], &one, &V[i * n_l], &one);
120 DAXPY(&n, &mt, &V[i * n_l], &one, &V[(j + 1) * n_l], &one);
122 bet[j] =
DDOT(&n, &V[(j + 1) * n_l], &one, &V[(j + 1) * n_l], &one);
123 if (bet[j] * (j + 1) <
orthTol * wn) {
124 fprintf(stdout,
"lanbounds: lucky break, j=%d, beta=%e, break\n", j,
129 if (bet[j] > tolBdwn) {
131 bet[j] = sqrt(bet[j]);
133 DSCAL(&n, &t, &V[(j + 1) * n_l], &one);
137 for (i = 0; i <= j; i++) {
138 t =
DDOT(&n, &V[(j + 1) * n_l], &one, &V[i * n_l], &one);
140 DAXPY(&n, &mt, &V[i * n_l], &one, &V[(j + 1) * n_l], &one);
142 bet[j] =
DDOT(&n, &V[(j + 1) * n_l], &one, &V[(j + 1) * n_l], &one);
144 bet[j] = sqrt(bet[j]);
146 DSCAL(&n, &t, &V[(j + 1) * n_l], &one);
157 for (i = 0; i < msteps; i++) {
160 gamma2[i] = S[i * msteps_l] * S[i * msteps_l];
164 for (i = 0; i < msteps; i++) {
166 const double t = ritzVal[i];
169 for (j = 0; j < npts; j++) {
170 if (fabs(xdos[j] - t) < width) ind[numPlaced++] = j;
173 for (j = 0; j < numPlaced; j++)
174 y[ind[j]] += gamma2[i] *
175 exp(-((xdos[ind[j]] - t) * (xdos[ind[j]] - t)) / sigma2);
180 double scaling = 1.0 / (nvec * sqrt(sigma2 *
PI));
182 DSCAL(&npts, &scaling, y, &one);
183 DCOPY(&npts, y, &one, ydos, &one);
186 *neig = y[npts - 1] * n;
int LanDos(const int nvec, int msteps, int npts, double *xdos, double *ydos, double *neig, const double *const intv)
double DDOT(int *n, double *x, int *incx, double *y, int *incy)
void DSCAL(int *n, double *a, double *x, int *incx)
#define Calloc(base, nmem, type)
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 randn_double(int n, double *v)
void DAXPY(int *n, double *alpha, double *x, int *incx, double *y, int *incy)
This file contains function prototypes and constant definitions for EVSL.
Defs for blaslapack routines.
evslData evsldata
global variable of EVSL
void linspace(double a, double b, int num, double *arr)
void simpson(double *xi, double *yi, int npts)
void DCOPY(int *n, double *dx, int *incx, double *dy, int *incy)