go Lgamma()

Lgamma()方法语法

func Lgamma(x float64) (lgamma float64, sign int)

go源码对Lgamma()方法的介绍:

Lgamma returns the natural logarithm and sign (-1 or +1) of Gamma(x).

Special cases are:

Lgamma(+Inf) = +Inf
Lgamma(0) = +Inf
Lgamma(-integer) = +Inf
Lgamma(-Inf) = -Inf
Lgamma(NaN) = NaN

golang标准库math模块中的Lgamma()方法,返回值有两个,分别为Gamma(x)的自然对数和正负号(-1 or +1)。除此之外,Lgamma(+Inf) = +Inf;Lgamma(0) = +Inf;Lgamma(-integer) = +Inf;Lgamma(-Inf) = -Inf;Lgamma(NaN) = NaN。


math.Lgamma()方法实例代码

func main() {
	lgamma_v, sign := math.Lgamma(3)
	fmt.Println(lgamma_v)
	fmt.Println(sign)
}

运行go文件,得到输出:

0.6931471805599453
1

全栈后端 / go语法 :













Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.