Home » Community » Forums » » Performance Programming Applied to C++
  Intel sponsors gamedev.net search:   
[Control Panel] [Register] [Bookmarks] [Who's Online] [Active Topics] [Stats] [FAQ] [Search]

Add Forum to Favorites |  Send Topic To a Friend | View Forum FAQ | Track this topic


 Last Thread Next Thread 
 Performance Programming Applied to C++
Post Reply 
I've created a site that describes lots of performance problems and some solutions, along with a few related links and references. Enjoy! http://members.optusnet.com.au/speedup

 User Rating: 1015    Report this Post to a Moderator | Link

>> b/a + c/a = (1/a)*(b+c) << It would probably be more efficient to use b/a + c/a = (b+c)/a as we don't get the multiplication at all... :-)

 User Rating: 1015    Report this Post to a Moderator | Link

Anonymous Poster II: My thoughts exactly; (b + c)/a seems best. But, the idea that multiplication is faster than division is important to establish. (That's why I looked the article up in the first place.) Here's a common enough example of that -- finding a unit vector:

Vector3f to_uvector() {
float magnitude_mult = 1.0 / sqrt(x*x + y*y + z*z);
return Vector3f(x * magnitude_mult, y * magnitude_mult, z * magnitude_mult);
}

Something I didn't see in the article -- passing struct/class arguments by reference/pointer. For example, if you write a function to find the dot product of two vectors, it's my impression that passing the second by reference (as in, float Vector3f::dot(Vector3f &vectorB)) will eliminate an extra call to the copy constructor.

 User Rating: 1015   |  Rate This User  Send Private MessageView Profile Report this Post to a Moderator | Link

All times are ET (US)

Post Reply
 Last Thread Next Thread 
Forum Rules:
You may not post new threads
You may post replies
You may not edit your posts
You may not use HTML in your posts
Jump To:
Administrative Options: