インストール
sudo apt install libgsl-dev
ソースコード・コンパイル
program bessel
use iso_c_binding
implicit none
interface
function gsl_sf_bessel_J0(x) bind (c, name="gsl_sf_bessel_J0")
import :: c_double
real(c_double) :: gsl_sf_bessel_J0
real(c_double), value, intent(in) :: x
end function gsl_sf_bessel_J0
end interface
print*, gsl_sf_bessel_J0(5.d0)
end program bessel
gfortran test.f90 -lgsl #-lgslcblas
./a.out
-0.17759677131433826 (ベッセル関数 J0(5.0)の値)
ベッセル関数は大文字の J と小文字の j で異なるから注意。
使える関数はマニュアルを見るとわかる。
ベクトル (配列) を扱う関数についてはテスト中 (うまくいってない)。
0 件のコメント:
コメントを投稿