GSL

GSL基于C的数学库,包含1000+功能,涉及随机数生成、特殊函数和最小二乘法等。在linux环境下安装,

./configure --prefix=/backup/home/misaraty/soft/gsl&&make -j 16&&make install

并在.bashrc中添加,

#gsl
export C_INCLUDE_PATH=/home/misaraty/soft/gsl/include:$C_INCLUDE_PATH
export LD_LIBRARY_PATH=/home/misaraty/soft/gsl/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/home/misaraty/soft/gsl/lib:$LIBRARY_PATH

测试文件test.c代码如下,

#include <stdio.h>
#include <gsl/gsl_sf_bessel.h>
int main (void)
{
double x = 5.0;
double y = gsl_sf_bessel_J0 (x);
printf ("J0(%g) = %.18e\n", x, y);
return 0;
}

编译+运行,

gcc test.c -lgsl -lgslcblas -O2 -Wall -o test.out && ./test.out

我们也可以在windows环境下安装。下载gsl-1.15-dev-win64.zip,然后运行,

gcc test.c -Wall -I"C:\gsl-1.15-dev-win64\include" -L"C:\gsl-1.15-dev-win64\bin" -lgslcblas-0 -lgsl-0 -lm -o test

也可以修改Notepad++配置,

cmd /k chcp 65001 >nul && gcc -Wall -I"C:\gsl-1.15-dev-win64\include" -L"C:\gsl-1.15-dev-win64\bin" -lgslcblas-0 -lgsl-0 -lm -o "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" "$(FULL_CURRENT_PATH)" && CLS && "$(CURRENT_DIRECTORY)\$(NAME_PART).exe" & PAUSE & EXIT