Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

## Using mkl functions for solving system of linear equations with UPDATED RHS vector

New Contributor I
457 Views

Hello,

I am interested in using mkl for a code that involves solution of a system of linear equations: {x} = {b}, where , {b} are given and we want to find vector {x}. My code has to solve this system of equations repeatedly (for many iterations), for THE SAME MATRIX , but for different values of {b}.  The value of {b} at each iteration depends on the value of {x} from the previous iteration, so the algorithm is something like this:

Initialize {x}

do i = 1,Niter

[Find {b}, given {x}]

end do !i

I need to mention that I have previously used DGESV and PARDISO, but have not figured out how to employ them for "back-substitution only".

Thanks in advance!!

1 Reply
Black Belt
457 Views

Instead of using a "driver routine" such as Dgesv, use "computational routines" such as dgetrf+dgetrs. The first, Dgetrf, needs only to be called once, to factor A into its upper and lower triangular factors, an operation that takes O(N3) operations. Subsequently, Whenever you have a new value of b available, call Dgetrs to obtain the solution x, an operation that takes O(N2) operations.

You can organize your work similarly in the sparse matrix case. Pardiso organizes its work into "phases". The first two phases need only be performed once, and Pardiso will have stored the factors at that point. The third phase can be called as often as needed with different R.H.S. vectors to obtain the corresponding solutions.