Open utterances-bot opened 1 year ago
Really nice implementation. Pretty fast once vectorized...
unfortunately compilers refuse to vectorize
dst[q ] = c;
dst[q^1] = s;
so I had to change it in
dst[0] = q==0 ? s :c;
dst[1] = q==0 ? c :s;
see https://godbolt.org/z/e6fdfvTM1
I think there is no real way to convince the compiler that q can only be 0 or 1...
btw I'm under the impression that
c=fpminimax(cos(pi*x), [|0,2,4,6|], [|24...|], [0;1/4], floating, absolute);
corresponding to
f32_cospi_6_k[] = { 0x1p0, -0x1.3bd3ap2, 0x1.03b132p2, -0x1.4ea1aep0};
produces a better approximation that "relative"
@VinInn Thanks for your feedback. Yeah the return the result is not ideal. And you are also correct that optimizing for abs error does produce better cosine coefficients.
A design and implementation of sincospi in binary32
Walks through constructing faithfully rounded $\sin\left(\pi x\right)$ and $\cos\left(\pi x\right)$.
http://marc-b-reynolds.github.io/math/2020/03/11/SinCosPi.html