GNU gfortran 的 expm1
expm1 for GNU gfortran
有什么方法可以从 GNU Fortran 调用 expm1 的快速实现吗?
理想情况下,最好有一个函数来直接计算 (exp(x)-1)/x 以避免对零参数进行额外检查。
expm1 的基本版本会特别有用。
这是从 libm 中调用它的方式:
use, intrinsic :: iso_c_binding, only: c_double
implicit none
interface
real(c_double) function expm1(x) bind(c, name='expm1')
import c_double
real(c_double), intent(in), value :: x
end function expm1
end interface
print*, expm1(3.4d0)
end program
如果函数的 glibc 源代码看起来不太令人沮丧,那么您可能希望将其翻译成 Fortran 以使其成为元素(如果元素是指 Fortran 关键字)。
有什么方法可以从 GNU Fortran 调用 expm1 的快速实现吗? 理想情况下,最好有一个函数来直接计算 (exp(x)-1)/x 以避免对零参数进行额外检查。 expm1 的基本版本会特别有用。
这是从 libm 中调用它的方式:
use, intrinsic :: iso_c_binding, only: c_double
implicit none
interface
real(c_double) function expm1(x) bind(c, name='expm1')
import c_double
real(c_double), intent(in), value :: x
end function expm1
end interface
print*, expm1(3.4d0)
end program
如果函数的 glibc 源代码看起来不太令人沮丧,那么您可能希望将其翻译成 Fortran 以使其成为元素(如果元素是指 Fortran 关键字)。