Skip to main content
gamedev.net
🔒 Locked

Fast Vector Class

Started by Numsgil Oct 22, 2005 at 11:36 PM 5 replies 700+ views
Original Post
Numsgil
Numsgil
I took the time to write my own vector class. After making a small demo that used it, the demo ran like someone had shot it in the foot. After profiling the code, I find that it's my vector class that's limping along. I found a few classes in teh articles section, now I'm wondering if anyone has their own vector classes they'd be willing to share that they know are fast.
[size=2]Darwinbots - [size=2]Artificial life simulation
stylin
stylin
I haven't used it myself, but the MTL is said to be uber fast.

Programmer's Reference
Performance Tests

Open source, too.
:stylin: "Make games, not war." "...if you're doing this to learn then just study a modern C++ compiler's implementation." -snk_kid
kevmo
kevmo
I have never had the need to implement my own vector class, but perhaps if you post some more details about your own implementation and profiling results, I can help you optimize it.

First I guess, what operations are giving you trouble, and how do you use the vector? That is, are you seeing something like deletion taking up most of the clock cycles, or resizing, or (insert operation here)?

Second, how are you implementing your vector? Is it backed by a plain array? How do you handle resizing, deleting, and the other non-trivial operations?
trevaaar
trevaaar
Are we talking about vector as in std::vector or as in 3D vector?
Numsgil
Numsgil
I'm talking about 3D vector, I guess I should have made that clear at the start...
[size=2]Darwinbots - [size=2]Artificial life simulation
Rob Loach
Rob Loach
The MTL that stylin posted sounds pretty interesting. You can use a matrix to control the implementation of vectors. The vector class I wrote up is currently being used in the SDL.NET project. The vector class itself can be found here in C#. Enjoy!
Rob Loach [Website] [Projects] [
stylin
stylin
Quote:
Original post by Rob Loach
The MTL that stylin posted sounds pretty interesting. You can use a matrix to control the implementation of vectors.

They also have an Iterative Template Library that handles solving linear systems. What's interesting is their claim of equal or surpassing performance levels with that of some Fortran implementations.
:stylin: "Make games, not war." "...if you're doing this to learn then just study a modern C++ compiler's implementation." -snk_kid

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.