main.c
来自「这是一个实用的并行计算源代码」· C语言 代码 · 共 29 行
C
29 行
/* $Id: main.c,v 1.2 2005/06/20 03:28:52 zlb Exp $ *//* 递归方式自适应数值积分串行主程序 */#include <stdio.h>#include <stdlib.h>#include <math.h>#include "function.h"#include "integration.h"intmain(int argc, char **argv){ double a = 0.0, b = 1.0; double res, cpu0, cpu1, wall0, wall1; if (argc != 2) { fprintf(stderr, "Usage: %s epsilon\n", argv[0]); fprintf(stderr, "Example: %s 1e-4\n", argv[0]); return 1; } gettime(&cpu0, &wall0); res = integration(a, F(a), b, F(b), atof(argv[1]) / (b - a), F); gettime(&cpu1, &wall1); printf("result=%0.16lf, error=%0.4le, cputime=%0.4lf, wtime=%0.4lf\n", res, res - RESULT, cpu1 - cpu0, wall1 - wall0); printf("%u function evaluations.\n", evaluation_count); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?