Matlab Optimize Matrix Multiply

This is my current matlab code:

a = load('m1.txt');
b = load('m2.txt');
c = a*b;
fid = fopen('Matrix.txt','wt');
for ii = 1:size(c,1)
fprintf(fid,'%gt',c(ii,:));
fprintf(fid,'n');
end
fclose(fid)

Basically read in two files and multiply the result to get the multiplied matrix, and write it to a file.

I'm suppose to find out if there is a cache friendly way to do this. But I think matrix somewhat efficient in this area opposed to other programming languages sometimes. Any hints or sample code?


Matlab matrix multiplication is really very efficient. I do not think that you can do better than what is already there.


You can use the save command to simplify the write to disk loop.

save Matrix.txt c -ascii

This will write to disk the variable 'c' in ascii format.

链接地址: http://www.djcxy.com/p/85984.html

上一篇: 乘以矩阵列

下一篇: Matlab优化矩阵乘法