Linear Algebra on different platforms


In a recent project which required to be cross-platform I had the fun experience of seeing how different each platform is at doing basic (and not so basic) matrix operations. The current project had been originally written in Matlab and I have since then rewritten the project in C++ so that it could be enjoyed on Mac, Linux and iPhone. Clearly all three machines (MacBook Pro, Dell, and iPhone) have different processing speeds, however,  what I discovered is that for some things speed alone is not the issue.

Note: These values were generated on different processors and no attempt was made to see which one was ultimately faster. The idea was to see how, independently, each environment performed under complex matrix operations. All values are in seconds and averaged over 100 iterations.





Off the bat, many things can be seen. First Matlab on a Mac is far slower than on Linux. This is because Matlab basically operates inside an emulator under OSX. Although I do not have a Windows machine, I have strong doubts that Matlab runs even fastest there. Second is the good news that one can technically outperform Matlab using C++. Using the library basic addition is actually not only faster than Matlab, but the iPhone outperforms Matlab running on OSX! Matlab should be ashamed that its product is slower on a Core 2 Duo than on a 500Mhz Arm chip.



There are some clear shortcomings of Eigen as can be seen with the 351sec processing time on the iPhone. Having implemented QR by hand once I can attest that it is not the easiest thing to do, even if doing the text book method. There is clearly something fishy about Eigen’s implementation for it should technically be as fast Matlab (addition and multiplication times being proof of that).

It was in this last part that my project become unfeasible to be done on the iPhone. Although most of the math I needed was lightening fast, QR and those functions that depend on it became too torturous to be run and waited upon. Stay tuned to how the same platforms perform when doing quadrangulations!