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

2 visualizaciones (últimos 30 días)
Seereen
Seereen el 18 de Sept. de 2019
Respondida: Matt J el 19 de Sept. de 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

Respuestas (2)

Matt J
Matt J el 18 de Sept. de 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 comentarios
Seereen
Seereen el 18 de Sept. de 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 el 18 de Sept. de 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...

Iniciar sesión para comentar.


Matt J
Matt J el 19 de Sept. de 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.

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by