Skip to main content



      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 06:03 Go to next message
Eclipse UserFriend
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 06:40] by Moderator

Re: Why are C++ trigonometric functions fast, but not that fast ? [message #1840958 is a reply to message #1840940] Thu, 29 April 2021 09:07 Go to previous message
Eclipse UserFriend
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.
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: Tue Jul 08 13:25:05 EDT 2025

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

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

Back to the top