GNU gfortran的expm1 [英] expm1 for GNU gfortran

查看:79
本文介绍了GNU gfortran的expm1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以从GNU Fortran调用expm1的快速实现吗? 理想情况下,最好有一个直接计算(exp(x)-1)/x的函数,以避免对零参数进行额外检查. 元素版本的expm1尤其有用.

Is there any way to call a fast implementation of expm1 from GNU Fortran? Ideally, it would be great to have a function to calculate (exp(x)-1)/x directly to avoid extra check for zero argument. Elemental version of expm1 would be especially helpful.

推荐答案

这是从libm调用的方式:

This is how it's called from 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关键字).

If the glibc source code for the function does not look too discouraging then you might wish to translate it into Fortran in order to make it elemental (if by elemental you meant the Fortran keyword).

这篇关于GNU gfortran的expm1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆