# Solving overdetemined (non-square) linear system using the GPU.

15 views (last 30 days)
Jesper on 8 Jun 2011
I need help big time. I have large overdetermined linear system and I want to use the computation advantages of the GPU to do this faster. I have the parallel computing toolbox (v5.1) and a Nvidia GTX 580. The mldivide or ("\") work with x=A\b on the cpu for non square dimension of A but for the gpu function this matrix needs to be square. Does anyone know of a solution to solve the non-square matrix on the GPU? I am a bit reluctant to start looking to much into CUDA programming at this point.

Jill Reese on 13 Jun 2011
Hi Jesper. If your MATLAB license is up to date you might like to have a look at the pre-release of R2011b which has just become available. This includes a number of updates to the GPU features which you might find useful.
It can be downloaded by logging in to the main www.mathworks.com page. After logging in, click on "My Account" at the top right of the page, then "Download R2011b Prerelease" from the "Account services" section.

Teja Muppirala on 13 Jun 2011
The pseudoinverse can be found by inv(A'*A)*A'
Thus you can solve your problem like this:
A = rand(4000,1000);
b = rand(4000,1);
tic
gA = gpuArray(A);
gb = gpuArray(b);
gx = (gA'*gA)\(gA'*gb);
x = gather(gx);
toc
Compare that with these:
tic
x_cpu1 = A\b;
toc
tic
x_cpu2 = (A'*A)\(A'*b);
toc

John Melonakos on 24 Jul 2011
Jacket is the only way to get this done directly in MATLAB, since PCT doesn't support very much. Download a free trial here: http://accelereyes.com/jacket_tour