乘以大向量和内存不足。输入 HELP MEMORY 作为您的选项

发布于 2024-12-11 03:53:28 字数 1329 浏览 0 评论 0原文

实际上这就是我想做的 Ad=<100820x20164 double>且 b=<100820x1 双> Ad 也是稀疏矩阵,b 是非稀疏矩阵。下面是原始问题,我尝试更改语句 A=V'*V + y_0*y_0';正如您告诉我的那样使用块处理技术,现在问题出在下面提到的赋值语句上。

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;

%%%%%%%%%使用下面的块处理进行修改%%%%%%

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 ;

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 ;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

国际总奸 2024-12-18 03:53:28

虽然 V'*V 是稀疏的,但 y_0*y_0' 却不是。当然,除非 V' 有许多空行。
您可以逐块计算 y_0*y_0'

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...

在“Process”部分,您可以将其与 V'*V 的适当部分结合起来。我还建议重构我的代码片段以避免冗余。

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...

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文