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

📄 xgammln.c

📁 适合大型数值计算代码 现在网络上已经找不到了 购买需要20$
💻 C
字号:
/* Driver for routine gammln */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#define NRANSI#include "nr.h"#include "nrutil.h"#define MAXSTR 80int main(void){	char txt[MAXSTR];	int i,nval;	float actual,calc,x;	FILE *fp;	if ((fp = fopen("fncval.dat","r")) == NULL)		nrerror("Data file fncval.dat not found\n");	fgets(txt,MAXSTR,fp);	while (strncmp(txt,"Gamma Function",14)) {		fgets(txt,MAXSTR,fp);		if (feof(fp)) nrerror("Data not found in fncval.dat\n");	}	fscanf(fp,"%d %*s",&nval);	printf("\n%s\n",txt);	printf("%10s %21s %21s\n","x","actual","gammln(x)");	for (i=1;i<=nval;i++) {		fscanf(fp,"%f %f",&x,&actual);		if (x > 0.0) {			calc=(x<1.0 ? gammln(x+1.0)-log(x) : gammln(x));			printf("%12.2f %20.6f %20.6f\n",x,				log(actual),calc);		}	}	fclose(fp);	return 0;}#undef NRANSI

⌨️ 快捷键说明

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