[Mesa-dev] [PATCH] glsl: improve accuracy of atan()
Timothy Arceri
t_arceri at yahoo.com.au
Fri Oct 10 03:22:21 PDT 2014
On Mon, 2014-10-06 at 17:03 +0200, Erik Faye-Lund wrote:
> On Fri, Sep 26, 2014 at 6:11 PM, Erik Faye-Lund <kusmabite at gmail.com> wrote:
> > Our current atan()-approximation is pretty inaccurate at 1.0, so
> > let's try to improve the situation by doing a direct approximation
> > without going through atan.
> >
> > This new implementation uses an 11th degree polynomial to approximate
> > atan in the [-1..1] range, and the following identitiy to reduce the
> > entire range to [-1..1]:
> >
> > atan(x) = 0.5 * pi * sign(x) - atan(1.0 / x)
> >
> > This range-reduction idea is taken from the paper "Fast computation
> > of Arctangent Functions for Embedded Applications: A Comparative
> > Analysis" (Ukil et al. 2011).
> >
> > The polynomial that approximates atan(x) is:
> >
> > x * 0.9999793128310355 - x^3 * 0.3326756418091246 +
> > x^5 * 0.1938924977115610 - x^7 * 0.1173503194786851 +
> > x^9 * 0.0536813784310406 - x^11 * 0.0121323213173444
> >
> > This polynomial was found with the following GNU Octave script:
> >
> > x = linspace(0, 1);
> > y = atan(x);
> > n = [1, 3, 5, 7, 9, 11];
> > format long;
> > polyfitc(x, y, n)
> >
> > The polyfitc function is not built-in, but too long to include here.
> > It can be downloaded from the following URL:
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/47851-constraint-polynomial-fit/content/polyfitc.m
> >
> > This fixes the following piglit test:
> > shaders/glsl-const-folding-01
> >
> > Signed-off-by: Erik Faye-Lund <kusmabite at gmail.com>
> > Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
> Ping?
Are you just looking for someone to commit this?
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list