BESSELK function calculates the modified Bessel functions, Kn(x), which are also known as the hyperbolic Bessel Functions. These are the equivalent of the Bessel functions, evaluated for purely imaginary arguments. The syntax of the function is: BESSELK(x,n)
(argsList *list.List)
| 1960 | // |
| 1961 | // BESSELK(x,n) |
| 1962 | func (fn *formulaFuncs) BESSELK(argsList *list.List) formulaArg { |
| 1963 | if argsList.Len() != 2 { |
| 1964 | return newErrorFormulaArg(formulaErrorVALUE, "BESSELK requires 2 numeric arguments") |
| 1965 | } |
| 1966 | x, n := argsList.Front().Value.(formulaArg).ToNumber(), argsList.Back().Value.(formulaArg).ToNumber() |
| 1967 | if x.Type != ArgNumber { |
| 1968 | return x |
| 1969 | } |
| 1970 | if n.Type != ArgNumber { |
| 1971 | return n |
| 1972 | } |
| 1973 | if x.Number <= 0 || n.Number < 0 { |
| 1974 | return newErrorFormulaArg(formulaErrorNUM, formulaErrorNUM) |
| 1975 | } |
| 1976 | var result float64 |
| 1977 | switch math.Floor(n.Number) { |
| 1978 | case 0: |
| 1979 | result = fn.besselK0(x) |
| 1980 | case 1: |
| 1981 | result = fn.besselK1(x) |
| 1982 | default: |
| 1983 | result = fn.besselK2(x, n) |
| 1984 | } |
| 1985 | return newNumberFormulaArg(result) |
| 1986 | } |
| 1987 | |
| 1988 | // besselK0 is an implementation of the formula function BESSELK. |
| 1989 | func (fn *formulaFuncs) besselK0(x formulaArg) float64 { |
nothing calls this directly
no test coverage detected