How to optimize matrix multiplication speed?

13 ビュー (過去 30 日間)
Djabba
Djabba 2020 年 8 月 3 日
編集済み: James Tursa 2020 年 8 月 3 日
Hi all,
I'd like to increase computation speed of a matrix multiplication that occures many times in my code.
P = PHI*(P + Q)*PHI' + Q;
% P and Q are symetric positive 50x50 matrices
% PHI is a 50x50 matrix
Is there a way to optimize this code?
thanks!

採用された回答

John D'Errico
John D'Errico 2020 年 8 月 3 日
Do this:
P = PHI*(P + Q)*PHI' + Q;
While it may look exactly like the line of code you wrote, in fact, it is the same. Matrix multiplies are already pretty well optimized in MATLAB.
Do you have the parallel processing toolbox, as well as GPU that is accessible to it? If so, then I believe you will get some gain by using gpuArray, as then the array multiplies can be done using your GPU.

その他の回答 (1 件)

James Tursa
James Tursa 2020 年 8 月 3 日
編集済み: James Tursa 2020 年 8 月 3 日
This looks like a covariance matrix update to me. The matrix multiplies are already done by highly optimized multi-threaded compiled BLAS library code, so you will not be able to improve on that. The only thing that might help you is the symmetry part, but unfortunately there are no symmetric BLAS routines to do your specific multiply. Also, since the multiplies will be done with generic matrix multiply routines, the result will likely not be exactly symmetric. If this makes a difference to you, you will have to manually correct the result. E.g., P = (P + P')/2

カテゴリ

Help Center および File ExchangeSurrogate Optimization についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by