40 int dampcf(
int m,
int damping,
double *jac){
41 double thetJ = 0.0, thetL = 0.0, a1 = 0.0, a2 = 0.0, dm = (double) m;
54 for (k=1; k<=m; k++) {
57 }
else if (damping == 1){
60 jac[k] = a1*sin(k1*thetJ)/a2 + (1-k1*a1)*cos(k*thetJ) ;
63 jac[k] = sin(k*thetL)/(k*thetL);
79 double dif_eval(
double *v,
int m,
double thc,
double *jac){
83 fval += v[j]*cos(j*thc)*jac[j];
106 int chebxPltd(
int m,
double *mu,
int npts,
double *xi,
double *yi) {
107 int k, j, one = 1, n = npts;
108 double scal, *vkm1, *vkp1, *vk;
114 memset(vkm1, 0, n*
sizeof(
double));
119 for (k=0; k<m; k++) {
121 scal = (k == 0 ? 1.0 : 2.0);
123 vkp1[j] = scal*xi[j]*vk[j] - vkm1[j];
129 DAXPY(&n, &mu[k+1], vk, &one, yi, &one) ;
175 double *mu = pol->
mu;
177 double del = 0.1*sqrt((bIn-aIn)*0.5);
181 double a, b, x, e, c, sigma, sigma1, sigma_new, g0, g1, gnew, s1, s2, s3;
182 double *t0, *t1, *tnew;
185 int m1 = max_deg+1, j, k;
187 int work_size = 3*m1;
194 if (bIn >= (1.0-eps)) {
212 Calloc(t0, work_size,
double);
218 t1[0] = -c*(sigma1/e);
227 for(k=2;k<=max_deg;k++){
228 sigma_new = 1.0/(2.0/sigma1-sigma);
231 s3 = sigma*sigma_new;
233 tnew[j-1] = s1*(t1[j]+t1[j-2]);
234 tnew[1] = tnew[1] + s1*t1[0];
236 tnew[k] = s1*t1[k-1];
238 tnew[j] = tnew[j] - s2*t1[j] - s3*t0[j];
244 gnew = 2*(x-c)*s1*g1 - s3*g0;
254 memcpy(mu,t1,(mbest+1)*
sizeof(
double));
270 for(i = 1; i < size; i++){
271 if(array[i] < array[index])
287 int rootchb(
int m,
double *v,
double* jac,
double tha,
double thb,
double *mu,
289 int MaxIterBalan = 30;
294 double fval = 0.0, d;
295 double fa, fb, thN, thc;
296 tolBal = fabs(tha-thb)*1.e-13;
302 if ((fa>0) || (fb<0))
305 for (it=0; it<=MaxIterBalan; it++) {
311 d += jac[j]*j*sin(j*(thc))*v[j];
314 if ((fabs(fval)<tolBal) || fabs(thc - thN)<DBL_EPSILON*abs(thc))
318 if((thN < thb) || (thN > tha))
323 if((thN < thb) || (thN > tha) )
331 mu[j] = cos(j*(thc))*jac[j];
362 double *mu, *v, *jac, t=0.0, itv[2], vals[2];
364 double tha=0.0, thb=0.0, thc=0.0;
366 int m, j, nitv, mbest;
368 if (check_intv(intv, stdout) < 0) {
372 Malloc(mu, max_deg+1,
double);
374 Malloc(v, max_deg+1,
double);
375 Malloc(jac, max_deg+1,
double);
381 aa =
max(intv[0], intv[2]); bb =
min(intv[1], intv[3]);
382 if (intv[0] < intv[2] || intv[1] > intv[3]) {
383 fprintf(stdout,
" warning [%s (%d)]: interval (%e, %e) is adjusted to (%e, %e)\n",
384 __FILE__, __LINE__, intv[0], intv[1], aa, bb);
386 double lmin = intv[2], lmax = intv[3];
388 double cc = 0.5 * (lmax + lmin);
389 double dd = 0.5 * (lmax - lmin);
407 if (aa-IntTol <= -1.0) {
416 }
else if (bb + IntTol >= 1.0) {
436 min_deg = 2 + (int) 0.5/(bb-aa);
447 for (j=0; j<min_deg; j++)
448 v[j] = cos(j*thb) - cos(j*tha);
450 for (m=min_deg; m < max_deg; m++){
453 v[m] = cos(m*thb)-cos(m*tha);
455 if (
rootchb(m, v, jac, tha, thb, mu, &thc)) {
469 if (vals[0] <= t*thresh && vals[1] <= t*thresh) {
478 pol->
bar =
min(vals[0], vals[1])/t;
515 double *mu = pol->
mu;
525 double *vkm1 = vkp1+n;
526 double *w2 = ifGenEv ? vkm1 + n : NULL;
529 double t, s, *tmp, t1= 1.0 / dd, t2 = 2.0 / dd;
533 memcpy(vk, v, n*
sizeof(
double));
542 memcpy(y, v, n*
sizeof(
double));
543 DSCAL(&n, &s, y, &one);
546 for (k=1; k<=m; k++) {
548 t = k == 1 ? t1 : t2;
567 DAXPY(&n, &ncc, vk, &one, vkp1, &one);
568 DSCAL(&n, &t, vkp1, &one);
570 DAXPY(&n, &dmone, vkm1, &one, vkp1, &one);
572 DAXPY(&n, &s, vkp1, &one, y, &one);
void free_pol(polparams *pol)
void vecset(int n, double t, double *v)
int find_pol(double *intv, polparams *pol)
Sets the values in pol.
int chebxPltd(int m, double *mu, int npts, double *xi, double *yi)
function yi = chebxPltd computes yi = p_mu (xi),
void chext(polparams *pol, double aIn, double bIn)
Determines polynomial for end interval cases.
void DSCAL(int *n, double *a, double *x, int *incx)
#define Calloc(base, nmem, type)
This file contains function prototypes and constant definitions internally used in EVSL...
void set_pol_def(polparams *pol)
set default values for polparams struct.
#define Malloc(base, nmem, type)
evslStat evslstat
global statistics of EVSL
int rootchb(int m, double *v, double *jac, double tha, double thb, double *mu, double *thcOut)
Finds the roots of linear combination of chebyshev polynomials.
void DAXPY(int *n, double *alpha, double *x, int *incx, double *y, int *incy)
Defs for blaslapack routines.
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
int dampcf(int m, int damping, double *jac)
Computes damping coefficient for cheb. expansions.
double evsl_timer()
evsl timer for mac
double dif_eval(double *v, int m, double thc, double *jac)
function dif_eval(v, m, thc, jac) evaluates the difference between the right and left values of the p...
int indexofSmallestElement(double *array, int size)
Find the indexofSmallestElement in array.