Re: OT : Approximate / fast math libraries ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 2007-09-01 at 11:23 +0100, Chris Jones wrote:
> On Saturday 1 September 2007 9:36:02 am Mogens Kjaer wrote:
> > Chris Jones wrote:
> > ...
> >
> > > for the profiler output. atan2 is taking 50% of the time of this method.
> > > Not here I don't need that much precision on the result - say +-
> > > O(2*pi/100).
> >
> > Can't you use a Taylor expansion of arctan?
> 
> Talyor expansions are valid when your argument is 'small' i.e.
> 
> sin(x) ~ x
> tan(x) ~ x
> cos(x) ~ (1-(x)*(x)/2)
> 
> etc. only work when x is small, and the error increases as x does (since the 
> size of the truncated terms become more important). Yes you can include more 
> terms but that only allows you to go to large x before the errors explode.
> 
> I'm well aware of these series, and already use them when appropriate. In this 
> case, I need tan(x) with fixed errors, between 0 and 2pi, the whole range.
> 
> for instance, a really course estimate for atan2(x,y) can be made, by just 
> comparing the signs of x and y, i.e. if x>0 and y>0, atan2(x,y) is between 0 
> and pi/2 ...
> 
> Chris
> 
Hi, Chris,
	When I need limited precision for such a value (fixed, some limited
resolution), I generally implement it with a lookup table.  If
implemented in assembly, it is about 6 to 10 instructions to retrieve
the value, and add a multiply and truncate to get the resolution you
need from a floating point result, and an add if you have negative
results.  This is often faster than even hardware processing for complex
values.

Regards,
Les H

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux