⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erf.c

📁 蒙特卡罗模拟光子成像C语言版,代码简洁专业
💻 C
字号:
/* Supply the missing error function for windows.  Not the most
 * accurate way to calculate error functions, perhaps, but better 
 * than nothing. 
 */

/* 2/sqrt(pi) from glibc math.h */
#define M_2_SQRTPI	1.12837916709551257390

/* Abramowitz+Stegun, 7.1.5 */

double erf(double x)
{
  double coef = x;
  double e    = coef;
  double del;
  int k;

  for (k = 1; k < 30; k++) 
    {
      coef *= -x*x/k;
      del   = coef/(2.0*k+1.0);
      e    += del;
    }

  return (M_2_SQRTPI * e);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -