在golang中的Psi函数(”digamma”)

huangapple go评论85阅读模式
英文:

Psi Function ("digamma") in golang

问题

我一直在寻找一个用于golang的科学计算库,它实现了digamma函数,即伽玛函数的对数导数。

我尝试自己实现这个函数,但我只能找到针对整数的digamma函数的显式公式,而我需要能够在非整数的数值上进行评估。

是否有人知道一个适用于go的科学计算包,或者知道digamma的精确公式?

英文:

I've been searching for a scientific computing library for golang that implements the digamma function, which is the logarithmic derivative of the gamma function.

I've attempted to implement the function myself, but I can only find explicit formulas for the digamma function evaluated at integers, but I need to be able to evaluate it at non-integer numbers.

Is anyone aware of a scientific computing package for go or of a precise formula for digamma?

答案1

得分: 1

我已经在 GitHub、GitBucket 和 Godoc 上搜索了一个多小时,但没有找到关于 Digamma 函数的 Go 实现。我可以几乎百分之百确定,目前没有 Go 的 Digamma 函数实现。

你最好的选择是将 GSL C 代码(在这里找到:http://fossies.org/dox/gsl-1.16/psi_8c_source.html)移植到 Go。

英文:

I have looked through github, gitbucket & godoc with no avail for over 1 hour, I can assert with almost 100% certainty there is no go implementation for the Digamma function.

Your best bet would be to port the GSL C Code found here.

答案2

得分: 1

好的,我会为你翻译以下内容:

好的,我从这里移植了一些其他简单的C代码。可能有点投机取巧,但我不想处理Marc建议的GSL代码中的所有依赖项,而且我对C的经验不多,那将是一场苦难。不过,这段代码在与Wolfram Alpha的测试中表现良好,所以可能不会有太多的折衷。

我将这个小文件放在了GitHub上,虽然它不是一个Go包,只是一个实现该函数并具有一个测试它的主程序的简单文件。

这是链接。感谢Brett Beutell的帮助。

英文:

Okay, I ported some other simpler C Code from here. Might have been a slight copout, but I didn't want to deal with all the dependencies in the GSL code suggested by Marc, and I don't have much experience with C so it would have been an ordeal. This code tests successfully against wolfram alpha, though, so it may not be too much of a tradeoff.

I put the little file on github, though it's not a go package. Just a simple file that implements the function and has a main routine that tests it.

Here's the link to that. Thanks to Brett Beutell for the help.

答案3

得分: 0

这是另一个从C++/Boost移植的实现:Digamma

英文:

Here is another implementation ported from C++/Boost: Digamma

huangapple
  • 本文由 发表于 2014年7月31日 08:14:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/25049002.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定