我有这样一段代码:
#include <gsl/gsl_integration.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
double func1(double x, void* params) {
return 1/(x-1);
}
int main() {
int num = 100;
gsl_integration_workspace *workspace = gsl_integration_workspace_alloc(num);
double result, error;
double alpha;
alpha = 1;
gsl_function F;
F.function = &func1;
F.params = α
double a, b;
a=0;
b=2;
double err1= 0;
double err2 = 1e-7;
gsl_integration_qawc (&F, a, b, 1.0, err1, err2, num, workspace,&result, &error);
printf("Function QAWC - Cauchy Principal value\n");
printf("Result: %f\n", result);
printf("Error: %f\n", error);
result = 0;
gsl_integration_workspace_free(workspace); //zwolnienie pamięci dla całkowania
return 0;
}
我以为它会处理这种功能,但我得到“无法集成功能”错误。为什么?