MATLAB: How to accelerate multiple Backslash Operations

backslashMATLABmultiprodparallel computingvectorization

Hi there,
I need to solve 500000 Linear Systems, so 500000 times A/b and I wonder whats the fastest way to do this as I have to do this quite a few times.
The Dimensions are A: 15*15*500000 and b: 15*1*500000, so rather small. A is dense.
is the fastest option really just a for-Loop like this one?:
for i=1:50000
C(:,i) = A(:,:,i) \ b(:,i)
end
What have I tried so far:
Because i have to run the calculations with different b's so its not such a big issue to calculate the Inverses (Ainv) of A once, I used the multiprod-Package, which vectorizes Matrix-Vector Multiplications, so
C = multiprod(Ainv, b)
is around 6xfaster than
for i=1:50000
C(:,i) = Ainv(:,:,i) * b(:,i)
end
I think the mmx Package works in a similar way.
But it is very often said that the BackslashOperator should be preferred over the calculation with the Inverse, so Im not very comfortable to use that solution.
Maybe multithreading is a solution, but I dont have any experience with that.
Does somebody know, whether it is also possible to vectorize the Backslash operator, or whether there is another way to speed things up?
I hope, I expressed myself properly and didnt foget or overlook something major 🙂
Any help would be much appreciated.
Julian

Best Answer

If you have the Parallel Computing Toolbox, this is readily done on the GPU
C=pagefun(@mldivide,gpuArray(A), gpuArray(b));