Fast matrix multiplication in Matlab?

Matlab's raison d'etre is doing matrix computations. I would be fairly surprised if you could significantly outperform its built-in matrix multiplication with hand-crafted tools. First of all, you should make sure your multiplication can actually be performed significantly faster.

You could do this by implementing a similar multiplication in C++ with Eigen.

1. This is exactly what MATLAB is good at. – Nzbuu Oct 4 at 9:17.

I have had good results with matlab matrix multiplication using the GPU.

The parallel computational power seems have been integrated in the new Matlab release with some function like "gpuArray". – Cowboy Oct 4 at 16:28.

In order to avoid the transpose operation, you could try: sum(bsxfun(@times, A, B), 2) But I would be astonished it was faster than the direct version. See @thiton's answer. Also look at mathworks.co.uk/company/newsletters/news... to see why the column-vector-based version is faster than the row-vector-based version.

Thanks. Indeed it is very difficult to beat the native Matlab matrix multiplication. It requires more time if I use the bsxffun together with sum – Cowboy Oct 4 at 9:54 I expected as much.

– Nzbuu Oct 4 at 10:59.

Your #1 option, if this is your bottleneck, is to re-examine your algorithm. See this question Optimizing Matlab Code for a great example of how choosing a different algorithm reduced runtime by three orders of magnitude.

Matlab is built using fairly optimized libraries (BLAS, etc. ), so you can't easily improve upon it from within Matlab. Where you can improve is to get a better BLAS, such as one optimized for your processor - this will enable better use of the caches by getting appropriately sized blocks of data from main memory. Take a look into creating your own compiled versions of ATLAS, ACML, MKL, and Goto BLAS.

I wouldn't try to solve this one particular multiplication unless it's really killing you. Changing up the BLAS is likely to lead to a happier solution, especially if you're not currently making use of multicore processors.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions