Skip to content

Commit a02481a

Browse files
committed
cielab_to_xyz 70% perf improvement
yay fma
1 parent e139854 commit a02481a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1329,10 +1329,11 @@ pub fn cielab_to_xyz<T: DType, const N: usize>(pixel: &mut [T; N])
13291329
where
13301330
Channels<N>: ValidChannels,
13311331
{
1332+
pixel[0] = pixel[0].fma((1.0 / 116.0).to_dt(), (16.0 / 116.0).to_dt());
13321333
[pixel[0], pixel[1], pixel[2]] = [
1333-
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt() + pixel[1] / 500.0.to_dt(),
1334-
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt(),
1335-
(pixel[0] + 16.0.to_dt()) / 116.0.to_dt() - pixel[2] / 200.0.to_dt(),
1334+
pixel[0] + pixel[1] / 500.0.to_dt(),
1335+
pixel[0],
1336+
pixel[0] - pixel[2] / 200.0.to_dt(),
13361337
];
13371338

13381339
pixel.iter_mut().take(3).for_each(|c| {

0 commit comments

Comments
 (0)