"platforms/reference/vscode:/vscode.git/clone" did not exist on "4d75af9fcb74411f8e32f7261f0d99010ae064c8"
Commit db674874 authored by peastman's avatar peastman
Browse files

Merge pull request #615 from peastman/master

Switched to a slightly faster (and more accurate) approximation for erfc()
parents e96caceb 3e47d824
...@@ -10,13 +10,10 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) { ...@@ -10,13 +10,10 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
#else #else
// This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as // This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as
// the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum // the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum
// error of 3e-7. // error of 1.5e-7.
real t = 1.0f+(0.0705230784f+(0.0422820123f+(0.0092705272f+(0.0001520143f+(0.0002765672f+0.0000430638f*alphaR)*alphaR)*alphaR)*alphaR)*alphaR)*alphaR; const real t = RECIP(1.0f+0.3275911f*alphaR);
t *= t; const real erfcAlphaR = (0.254829592f+(-0.284496736f+(1.421413741f+(-1.453152027f+1.061405429f*t)*t)*t)*t)*t*expAlphaRSqr;
t *= t;
t *= t;
const real erfcAlphaR = RECIP(t*t);
#endif #endif
real tempForce = 0.0f; real tempForce = 0.0f;
if (needCorrection) { if (needCorrection) {
......
...@@ -10,13 +10,10 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) { ...@@ -10,13 +10,10 @@ if ((!isExcluded && r2 < CUTOFF_SQUARED) || needCorrection) {
#else #else
// This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as // This approximation for erfc is from Abramowitz and Stegun (1964) p. 299. They cite the following as
// the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum // the original source: C. Hastings, Jr., Approximations for Digital Computers (1955). It has a maximum
// error of 3e-7. // error of 1.5e-7.
real t = 1.0f+(0.0705230784f+(0.0422820123f+(0.0092705272f+(0.0001520143f+(0.0002765672f+0.0000430638f*alphaR)*alphaR)*alphaR)*alphaR)*alphaR)*alphaR; const real t = RECIP(1.0f+0.3275911f*alphaR);
t *= t; const real erfcAlphaR = (0.254829592f+(-0.284496736f+(1.421413741f+(-1.453152027f+1.061405429f*t)*t)*t)*t)*t*expAlphaRSqr;
t *= t;
t *= t;
const real erfcAlphaR = RECIP(t*t);
#endif #endif
real tempForce = 0; real tempForce = 0;
if (needCorrection) { if (needCorrection) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment