Jump to content
  • Advertisement
Sign in to follow this  
Asuralm

vector operation and loop, which is quicker?

This topic is 3875 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all: Say in C++, I have a vector of data say: vector<int> array(10000); If I do some calculation on the array, is for loop quicker or some vector/matrix routine defined in libraries like numerical recipes quicker? Thanks

Share this post


Link to post
Share on other sites
Advertisement
it really depends on your implementation and theirs. Using theirs is most likely the fastest way to get working code unless you have to do a lot of hacking and chopping to get your data in the right format for theirs.

as an example, say you are writing a function to find which of a few objects is closer. If you used a library function to calculate the distance it computes the whole distance. Since you only need the relative order of the objects you could write it yourself and use distance squared and save yourself the calculation of multiple square roots. The library writer can't do this since he has promised you distance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!