How to solve linear equation for 3 unkowns using SOR in GPU

1 Ansicht (letzte 30 Tage)
Seereen
Seereen am 18 Sep. 2019
Beantwortet: Matt J am 19 Sep. 2019
I am trying to find the motion (u,v,w) for each pixel in my frame by solving the linear system Ax=b
A is a 3 by 3 ... each element for example A (1,1) is equivalent to the frame size ... let's say ( 512 X 512)
A = [ A B C ; D E F ; G H I]
x is unknown need to be estimated ( u,v,w) ... u , v and w should be ( 512 X 512)
b is a 3 by 1 matrix and each element is equivalent to the frame size as well
b= [ J K L]
I am trying to solve this system using the SOR iteration method so I have this provided function
problems:
-In this code I have to use omega = 1 otherwise I got the wrong answer totaly !
-How can I solve this system using the SOR iteration method?
-How can I improve it to use GPU to speed up?
Any assistance will be so appreciated
function [u,v,w,error]=SORstep(A,B,C,D,E,F,G,H,I,J,K,L,omega,du_temp,dv_temp,dw_temp) % du_temp, dv_temp, dw_temp previouse estimation
u=((1.0-omega).*du_temp)+(omega./A).*(J-(B.*dv_temp+C.*dw_temp));
v=((1.0-omega).*dv_temp)+(omega./E).*(K-(D.*u+F.*dw_temp));
w=((1.0-omega).*dw_temp)+(omega./I).*(L-(G.*u+H.*v));
error = norm([u;v;w]-[du_temp;dv_temp;dw_temp])./norm([u;v;w]);
end

Antworten (2)

Matt J
Matt J am 18 Sep. 2019
Not sure why you would be using an iterative method when an analytical solution is available.
A=gpuArray.rand(3,3,512^2);
b=gpuArray.rand(3,1,512^2);
x=pagefun(@mldivide, A,b);
u=reshape(x(1,:),512,512);
v=reshape(x(2,:),512,512);
w=reshape(x(3,:),512,512);
  2 Kommentare
Seereen
Seereen am 18 Sep. 2019
I need iteration because it is very big system! ... I have to solve 262144 equations .. right?
so I think iterative method help in this case
Matt J
Matt J am 18 Sep. 2019
The language of your post is confusing. You should not say your A matrix is 3x3 when it is in fact 262144 x 262144...

Melden Sie sich an, um zu kommentieren.


Matt J
Matt J am 19 Sep. 2019
If you have the Parallel Computing Toolbox, you can make all the variables in your SORstep function
A,B,C,D,E,F,G,H,I,J,K,L,omega,du_temp,dv_temp,dw_temp
into gpuArrays. Then, all the matrix arithmetic done in your SORstep function will be done on the GPU.

Kategorien

Mehr zu Graph and Network Algorithms finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by