How to optimize the multiplication of large matrices in Matlab?
13 次查看(过去 30 天)
显示 更早的评论
I have 2 matrices A, B, and vector C that I need to multiply. They are fairly large.
Matrix A = 10000x10000
Matrix B = 10000x10000
Vector C = 10000x1
If I perform A*B*C, this takes a long time so I used sparse function which collapses the matrices/vectors by removing large number of zeros then I convert it back to a full matrix.
full(sparse(A)*sparse(B)*sparse(C))
It's faster but I was wondering if there are more efficient techniques for multiplying them together. Would it be better to write for loops?
Secondly, some of the elements in my matrix have values close to zero so I can replace these with zeroes before converting them to sparse matrices. What's the best way to do this?
0 个评论
采纳的回答
更多回答(2 个)
Sean de Wolski
2013-3-8
I doubt you'll be able to get anything faster than the highly optimized BLAS libraries that MATLAB uses to perform matrix arithmetic. The only thing I've heard of that might be faster is mtimesx on the FEX and even that, I've never reproduced.
0 个评论
per isakson
2013-3-8
编辑:per isakson
2013-3-8
Your second question:
A( A < small_number ) = 0;
or better
A( abs(A) < small_number ) = 0;
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!