Matlab is 3.8 - 5.8 times faster in total time. But the interesting thing is that Matlab outperforms C++ the larger the N gets. The results are compiled for a matrix size NxN where N varies from 10,000 to 40,000. The table below shows the comparison of time it takes to assemble the kernel matrix and the time it takes to multiply the matrix with the vector. Overall the code in C++ is much much faster than Matlab (because function calling in Matlab has an overhead etc.), but Matlab seems to be outperforming C++ in the matrix-vector multiplication (code snippet at the bottom). The larger code performs such multiplications at multiple instances. While doing that, I was surprised once again to find that Matlab is faster than C++ in matrix assembly and computation.I have a slightly larger code, from which I am investigating a segment of matrix-vector multiplication. I have the same code in C++, Matlab and Python. In the discussion of that question, it was pointed to me that I should use a wrapper in Python to call my C++ code because C++ code is also available to me. I was surprised that Matlab is faster than Python, especially in meshgrid. Some time ago I asked a question about performance of Matlab vs Python ( Performance: Matlab vs Python).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |