How to solve linear equation for 3 unkowns using SOR in GPU
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Matt J
on 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 Comments
Matt J
on 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...
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!