Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Why are C++ trigonometric functions fast, but not that fast ?
Why are C++ trigonometric functions fast, but not that fast ? [message #1840940] Thu, 29 April 2021 10:03 Go to next message
BronxCruz BronxCruz is currently offline BronxCruz BronxCruzFriend
Messages: 1
Registered: April 2021
Junior Member
When people try to optimize numerical algorithms, there is a point when the profiler says a significant part of time is spent computing sin, cos, tan, sqrt, etc.

Re-implementing custom versions is often beneficial in term of CPU time (with tremendous gain sometimes !)essay writer

In videogames too, people like to implement faster (but less accurate version alas) of these functions.

So why is std::sin not the fastest possible version ? Is it a matter of branch vs branchless like for std::floor (managing temporary value overflowing has a cost) ? Something else ?

[Updated on: Wed, 05 May 2021 10:40]

Report message to a moderator

Re: Why are C++ trigonometric functions fast, but not that fast ? [message #1840958 is a reply to message #1840940] Thu, 29 April 2021 13:07 Go to previous message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 742
Registered: August 2014
Senior Member
The functions you mentioned are basic transcendental functions, which have a trade-off between accuracy and speed. The library functions aim to as accurate answer as possible within the limits of the floating-point representation.

The games can usually do without more than 3 digits of accuracy, and there are many ways to create fast but not-so-accurate versions instead.


--

Tauno Voipio
Previous Topic:Bug with java on ssh remote debugging in last cdt version on debian buster
Next Topic:Please delete this post. I don't know why is twice
Goto Forum:
  


Current Time: Fri Apr 26 01:11:08 GMT 2024

Powered by FUDForum. Page generated in 0.02633 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top