[Kstars-devel] Fwd: Plans for threading in KStars

Daniel-Marian Baboiu daniel.baboiu at shaw.ca
Mon Nov 14 18:13:48 UTC 2011


On Mon, 2011-11-14 at 12:32 -0500, Henry de Valence wrote:
> On 11-11-14 01:27 AM, Aleksey Khudyakov wrote:
> > asin/acos are slower than sin/cos, I beleive they solve equation, but we may
> > take advantage of the fact that we don't need of full 15 digit precision as long
> > as deviation of projections from true location are less than say 0.1
> > pixel it's OK
> 
> Perhaps instead of calling these functions we can just compute the first 
> few terms of the power series expansion?

There are several methods to compute these functions. One approach is to
use Chebyshev polynomial expansion. In glibc 2.14 (at least some of the
architectures), cos is a sin with offset, while sin() is calculated by
dividing the angle range into small portions (length pi/16); ends of the
interval are stored as a table, while the remaining portion is
calculated with polynomial expansion. Much of the code for trigs in
glibc is written in assembly; I don't think we should go into that.

I did once a benchmarching of various functions, and all trig/inverse
and square root functions had roughly similar times (roughly 20-30x the
time for multiplications)

There is no option for precision; at least some implementations for
"float" version simply convert it to double, call the double version of
the function, and convert the result back to float. 

Some of the transcedental functions (as well as square roots) use
polynomial expansion with degrees around 20. If we want a
quick-and-dirty version of the trig functions, for the purpose of
graphical display only, we could use a spline approach - subdivide the
angular range into subintervals, then in each of these we have only a
third degree polynomial.




More information about the Kstars-devel mailing list