double doublefact(int n){ if(n==-1) return 1; else if (n==0) return 1; else if (n==1) return 1; else return n*doublefact(n-2); }
double volintegral (double d1, double d2, double d3, int l, int m, int n, int shape) { if ((l%2==1) || (m%2==1) || (n%2==1)) return 0.0; else switch (shape) { /* ell. cylinder shape */ case 1: return 4.0*PI*pow(d1, l+1)*pow(d2, m+1)*pow(d3, n+1)/(double)(n+1) *doublefact(l-1)*doublefact(m-1)/doublefact(l+m+2); /* spheroid shape */ case 2: return 4.0*PI*pow(d1, l+1)*pow(d2, m+1)*pow(d3, n+1) *doublefact(l-1)*doublefact(m-1)*doublefact(n-1)/ doublefact(l+m+n+3); /* rp shape */ default: return 8.0/((l+1)*(m+1)*(n+1))*pow(d1, l+1)*pow(d2,m+1)* pow(d3, n+1); } }
std::vector<contr_t> slater_fit_midpoint(double zeta, int am, int nf) { // Returned basis std::vector<contr_t> ret(nf); // Weight must have decayed to const double decayfac=1e-6; // Determine the limits double min, max; determine_slater_limits(zeta,am,decayfac,min,max); // Convert to logarithm scale used in the integration min=log10(min); max=log10(max); // printf("lower=%e, max at %e, upper=%e\n",min,log10(maxz),max); // Quadrature points std::vector<double> lga(nf); double dlga=(max-min)/nf; // Form quadrature points for(int i=0;i<nf;i++) { lga[i]=min+(i+0.5)*dlga; ret[i].z=pow(10.0,lga[i]); } // Initialize weights for(int i=0;i<nf;i++) { ret[i].c=0.0; } // Common factor is double cfac=pow(zeta,am+5.0/2.0)/(pow(2.0,5.0/4.0)*pow(M_PI,1.0/4.0))*sqrt(doublefact(2*am+1)/fact(2*am+2))/log(10.0)*dlga; // Calculate weights using midpoint method for(int i=0;i<nf;i++) ret[i].c=cfac*calc_slater_weight(zeta,ret[i].z,am); return ret; }