@@ -92,8 +92,8 @@ pow3_4(x) = (y = @fastmath(sqrt(x)); y*@fastmath(sqrt(y))) # x^(3/4)
92
92
93
93
# `pow5_12` is called from `srgb_compand`.
94
94
pow5_12 (x) = pow3_4 (x) / cbrt (x) # 5/12 == 1/2 + 1/4 - 1/3 == 3/4 - 1/3
95
- pow5_12 (x:: Float32 ) = Float32 (pow5_12 (Float64 (x)))
96
95
@inline function pow5_12 (x:: Float64 )
96
+ @noinline _cbrt (x) = cbrt01 (x)
97
97
p3_4 = pow3_4 (x)
98
98
# x^(-1/6)
99
99
if x < 0.02
@@ -106,7 +106,7 @@ pow5_12(x::Float32) = Float32(pow5_12(Float64(x)))
106
106
t0 = @evalpoly (x, 1.7047813285940905 , - 3.1261253501167308 ,
107
107
7.498744828350077 , - 10.100319516746419 , 6.820601476522508 , - 1.7978894213531524 )
108
108
else
109
- return p3_4 / cbrt (x)
109
+ return p3_4 / _cbrt (x)
110
110
end
111
111
# x^(-1/3)
112
112
t1 = t0 * t0
@@ -117,6 +117,20 @@ pow5_12(x::Float32) = Float32(pow5_12(Float64(x)))
117
117
# x^(3/4) * x^(-1/3)
118
118
muladd (p3_4, t2, p3_4 * t2h)
119
119
end
120
+ @inline function pow5_12 (x:: Float32 )
121
+ # x^(-1/3)
122
+ rc = rcbrt (x)
123
+ rcx = - rc * x
124
+ rch = muladd (muladd (rc, x, rcx), - rc^ 2 , muladd (rc^ 2 , rcx, 1.0f0 )) # 1 - x * rc^3
125
+ rce = muladd (2 / 9f0 , rch, 1 / 3f0 ) * rch * rc
126
+ # x^(3/4)
127
+ p3_4_f64 = pow3_4 (Float64 (x))
128
+ p3_4r = reinterpret (Float64, reinterpret (UInt64, p3_4_f64) & 0xffffffff_e0000000 )
129
+ p3_4 = Float32 (p3_4r)
130
+ p3_4e = Float32 (p3_4_f64 - p3_4r)
131
+ # x^(3/4) * x^(-1/3)
132
+ muladd (p3_4, rc, muladd (p3_4, rce, p3_4e * rc))
133
+ end
120
134
121
135
# `pow12_5` is called from `invert_srgb_compand`.
122
136
pow12_5 (x) = pow12_5 (Float64 (x))
0 commit comments