Tutorial :What's the fastest vector/matrix math library in C for iPhone game?


As the title, I'm finding vector/matrix library in C optimized for iPhone/iPod processors. Or just generally fast.


I'm sorry for unclear question. I'm looking for fast lib for commercial games for iPhone/iPod. So GPL lib cannot be used.

However, I'll stop finding fastest lib, it maybe meaningless.


Now(2010.06.26) Accelerate framework included on iOS4, so vDSP/BLAS functions are available.

This utilizes hardware feature (CPU or SIMD) to accelerate floating point operations, so superior speed (2~4.5x average, 8x maximum) and less energy(0.25x maximum) consuming can be gained by using this.

Thanks people for other answers.


Depends very much on your needs, if you're just using straight floating point math you will probably find that the compiler will use software floating point, which will be very slow. So step one is making sure that youuse the hardware floating point unit that is available in the iPhone processor.

Step two is using an already well established library, there are several, Hassan already provided you with a link to the GNU GSL which is nice.

The next step would be to take advantage of the VFP SIMD like abilities. The VFP is not actually SIMD, but does provide SIMD like instructions for which the individual operations are perform consequtively. The advantage of still using these instructions is that your program text will be shorter, allowing better use of the instruction cache and less problems when missing branch predictions and so forth. I am however not aware of any vector library taking advantage of the VFP, you'd have to do a good search and possible write your own if it's not available.

Finally, if you still need more speed, you'll want to use the true SIMD unit in the iPhone processor. However this unit is not a floating point unit, but an integer unit. So, assuming you do want real numbers, you'll be stuck with fixed point, it depends on your application whether you can get away with that. Again I am not aware of any vector library providing fixed point arithmetic using the SIMD unit provided by the iPhone processor, so again you'd need a thorough search and possibly get your hands dirty yourself.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »