SheetJS
73ee33e402
- eliminated array reduce (performance improvement) - explicit treatment of divergent values - better handling of non-integral order (fixes #3, h/t @vron) - reorganized source, removed voc dependency (fixes #2, h/t @hmalphettes) - new browser demo - more detailed test suite and coverage tests - updated travis versions for test - miscellaneous adjustments to tooling
20 lines
924 B
JavaScript
20 lines
924 B
JavaScript
var besselk/*:BesselF*/ = (function() {
|
|
var b0_a = [-0.57721566, 0.42278420, 0.23069756, 0.3488590e-1, 0.262698e-2, 0.10750e-3, 0.74e-5].reverse();
|
|
var b0_b = [1.25331414, -0.7832358e-1, 0.2189568e-1, -0.1062446e-1, 0.587872e-2, -0.251540e-2, 0.53208e-3].reverse();
|
|
|
|
function bessel0(x/*:number*/)/*:number*/ {
|
|
if(x <= 2) return -M.log(x/2) * besseli(x,0) + _horner(b0_a, x*x/4);
|
|
return M.exp(-x) / M.sqrt(x) * _horner(b0_b, 2/x);
|
|
}
|
|
|
|
var b1_a = [1.0, 0.15443144, -0.67278579, -0.18156897, -0.1919402e-1, -0.110404e-2, -0.4686e-4].reverse();
|
|
var b1_b = [1.25331414, 0.23498619, -0.3655620e-1, 0.1504268e-1, -0.780353e-2, 0.325614e-2, -0.68245e-3].reverse();
|
|
|
|
function bessel1(x/*:number*/)/*:number*/ {
|
|
if(x <= 2) return M.log(x/2) * besseli(x,1) + (1/x) * _horner(b1_a, x*x/4);
|
|
return M.exp(-x)/M.sqrt(x)*_horner(b1_b, 2/x);
|
|
}
|
|
|
|
return _bessel_wrap(bessel0, bessel1, 'BESSELK', 2, 1);
|
|
})();
|