大矩阵的分块乘法及matlab实现
笔记来自参考文献:MATLAB程序对分块矩阵在矩阵乘法中算法的实现
http://download.csdn.net/detail/caoenze/8855485
1 . 将左乘矩阵分块
function z=product(x ,y)
sizex1=size(x ,1);
sizex2=size(x ,2);
sizey1=size(y,1);
sizey2=size(y,2);
if (sizex2 ~ = sizey1)
disp('error ! ') ;
else
for j = 1:1:sizey2
z(:,j )=zeros(sizex1,1) ;
for k = 1:1:sizex2
z(:,j)=z(:,j)+ x( :,k)*y(k ,j) ;
end
end
end
end
2、将右乘矩阵分块
function z=product(x,y)
sizex1=size(x,1);
sizex2=size(x,2);
sizey1=size(y,1);
sizey2=size(y,2);
if(sizex2~=sizey1)
disp('erro!');
else
z=zeros(sizex1,sizey2);
for j=1:sizex2
z=z+x(:,j)*y(j,:);
end
end
end
3、两个矩阵都分块
funtion z=product(x,y)
sizex1 = size(x,1);
sizex2 = size(x,2);
sizey1 = size(y,1);
sizey2 = size(y,2);
if sizex2 ~= sizey1
disp('error!');
else
z=zeros(sizex1,sizey2);
for j=1:sizex2
z = z + x(:,k) * y(j,:);
end
end
end