Jump to content
  • Advertisement
Sign in to follow this  
Asuralm

vector operation and loop, which is quicker?

This topic is 3956 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!