本文介绍了乘以大向量和内存不足.输入HELP MEMORY作为您的选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上这是我要做的事情Ad = 和b = 也是Ad是稀疏矩阵,b是非稀疏.下面是原始问题,我尝试更改陈述A = V'* V + y_0 * y_0';使用您告诉我的块处理技术,现在问题出在下面提到的赋值语句上.

Actually this is what i am trying to do Ad=<100820x20164 double> and b= <100820x1 double> also Ad is sparse matrix and b is non-sparse .Below is the original Problem and i try to change the statement A=V'*V + y_0*y_0'; using the block processing technique as you told me , now the problem is on the assignment statement mentioned below.

V=Ad;     
b_1=b;
x_0=ones(size(V ,1) ,1);
y_0=V'*x_0;
A=V'*V + y_0*y_0';
b=V'*b_1 + dot(x_0,b_1)*y_0;

%%%%%%%%%%使用低于%%%%%%%的块处理进行了修改

%%%%%%%%% Modified using block processing below %%%%%%

V=Ad;     
b_1=b;
x_0=ones(size(V ,1) ,1);
y_0=V'*x_0;

v=V'*V ;   %%% v is updated here which is left hand side of equation 

 %%% Block Processing code %% For right hand side of equation
 y_01 = y_0(1:size(y_0)/2);
 y_02 = y_0(size(y_0)/2 + 1:end);


 res =( y_01 * y_01'); % Upper left 
 Temp=v(1:size(v ,1)/2 , 1:size(v ,1)/2)  + res  ;
 v(1:size(v ,1)/2 , 1:size(v ,1)/2)  = Temp;       %%%% Problem here gets hang
 clear Temp; clear res ;


 res = y_02 * y_02'; % Bottom right
 Temp=v(size(v ,1)/2 + 1 :end , size(v ,1)/2 + 1 :end)  + res  ;  
 v(size(v ,1)/2 + 1:end , size(v ,1)/2 + 1:end)  = Temp; 
 clear Temp; clear res ;


 res = y_01 * y_02'; % Upper right
 Temp=v(1:size(v ,1)/2 , size(v ,1)/2 + 1:end)  + res  ;
 v(1:size(v ,1)/2 , size(v ,1)/2 + 1:end)  = Temp; 
 clear Temp; clear res ;


 res = y_02 * y_01'; % Bottom left   
 Temp=v(size(v ,1)/2 + 1:end, 1:size(v ,1)/2 )   + res  ;
 v(size(v ,1)/2 + 1:end, 1:size(v ,1)/2 )  = Temp; 
 clear Temp; clear res ;

推荐答案

虽然V'*V是稀疏的,而y_0*y_0'不是.除非V'当然有很多空行.您可以按块计算y_0*y_0':

While V'*V is sparse, y_0*y_0' is not. Unless of course V' has many empty rows. You could calculate y_0*y_0' block-wise:

y_01 = y_0(1:10000);
y_02 = y_0(10001:end);

res = y_01 * y_01' % Upper left 
% Process...
res = y_02 * y_02' % Bottom right
% Process...
res = y_01 * y_02' % Upper right
% Process...
res = y_02 * y_01' % Bottom left  
% Process...

在处理"部分,您可以将其与V'*V的相应部分组合.我还建议重新分解代码段,以避免冗余.

In the 'Process' section you can combine it with the appropriate portion of V'*V. I would also suggest re-factoring my code snippet to avoid redundancy.

这篇关于乘以大向量和内存不足.输入HELP MEMORY作为您的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:56