Commit 2a2cab29 authored by Ilya Tocar's avatar Ilya Tocar

math: speed up bessel functions on AMD64

J0-4            71.9ns ± 1%  54.6ns ± 0%  -24.08%  (p=0.000 n=20+18)
J1-4            71.6ns ± 0%  55.4ns ± 0%  -22.60%  (p=0.000 n=19+20)
Jn-4             153ns ± 0%   118ns ± 1%  -22.71%  (p=0.000 n=20+20)
Y0-4            70.8ns ± 0%  53.9ns ± 0%  -23.87%  (p=0.000 n=19+19)
Y1-4            70.8ns ± 0%  54.1ns ± 0%  -23.54%  (p=0.000 n=20+20)
Yn-4             149ns ± 0%   116ns ± 0%  -22.15%  (p=0.000 n=19+20)

Fixes #16889

Change-Id: Ie88496407b42f6acb918ffae1226b1b4c0500cb9
Reviewed-on: https://go-review.googlesource.com/28086
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent dfbbe06a
......@@ -305,20 +305,20 @@ var p0S2 = [5]float64{
}
func pzero(x float64) float64 {
var p [6]float64
var q [5]float64
var p *[6]float64
var q *[5]float64
if x >= 8 {
p = p0R8
q = p0S8
p = &p0R8
q = &p0S8
} else if x >= 4.5454 {
p = p0R5
q = p0S5
p = &p0R5
q = &p0S5
} else if x >= 2.8571 {
p = p0R3
q = p0S3
p = &p0R3
q = &p0S3
} else if x >= 2 {
p = p0R2
q = p0S2
p = &p0R2
q = &p0S2
}
z := 1 / (x * x)
r := p[0] + z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))))
......@@ -408,19 +408,19 @@ var q0S2 = [6]float64{
}
func qzero(x float64) float64 {
var p, q [6]float64
var p, q *[6]float64
if x >= 8 {
p = q0R8
q = q0S8
p = &q0R8
q = &q0S8
} else if x >= 4.5454 {
p = q0R5
q = q0S5
p = &q0R5
q = &q0S5
} else if x >= 2.8571 {
p = q0R3
q = q0S3
p = &q0R3
q = &q0S3
} else if x >= 2 {
p = q0R2
q = q0S2
p = &q0R2
q = &q0S2
}
z := 1 / (x * x)
r := p[0] + z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))))
......
......@@ -298,20 +298,20 @@ var p1S2 = [5]float64{
}
func pone(x float64) float64 {
var p [6]float64
var q [5]float64
var p *[6]float64
var q *[5]float64
if x >= 8 {
p = p1R8
q = p1S8
p = &p1R8
q = &p1S8
} else if x >= 4.5454 {
p = p1R5
q = p1S5
p = &p1R5
q = &p1S5
} else if x >= 2.8571 {
p = p1R3
q = p1S3
p = &p1R3
q = &p1S3
} else if x >= 2 {
p = p1R2
q = p1S2
p = &p1R2
q = &p1S2
}
z := 1 / (x * x)
r := p[0] + z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))))
......@@ -401,19 +401,19 @@ var q1S2 = [6]float64{
}
func qone(x float64) float64 {
var p, q [6]float64
var p, q *[6]float64
if x >= 8 {
p = q1R8
q = q1S8
p = &q1R8
q = &q1S8
} else if x >= 4.5454 {
p = q1R5
q = q1S5
p = &q1R5
q = &q1S5
} else if x >= 2.8571 {
p = q1R3
q = q1S3
p = &q1R3
q = &q1S3
} else if x >= 2 {
p = q1R2
q = q1S2
p = &q1R2
q = &q1S2
}
z := 1 / (x * x)
r := p[0] + z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment