Why is MATLAB so fast in matrix multiplication?

前端 未结 12 1108
無奈伤痛
無奈伤痛 2020-11-22 00:29

I am making some benchmarks with CUDA, C++, C#, Java, and using MATLAB for verification and matrix generation. When I perform matrix multiplication with MATLAB, 2048x

12条回答
  •  爱一瞬间的悲伤
    2020-11-22 01:00

    When doing matrix multiplying, you use naive multiplication method which takes time of O(n^3).

    There exist matrix multiplication algorithm which takes O(n^2.4). Which means that at n=2000 your algorithm requires ~100 times as much computation as the best algorithm.
    You should really check the wikipedia page for matrix multiplication for further information on the efficient ways to implement it.

提交回复
热议问题