fortranlinear-algebralapackblas

LAPACK different outputs when using solvers for banded matricies


I've been stuck at this for hours and hoping someone can figure out what I am missing. I am solving Ax=B firstly using DGESV which I am 99% sure is correct. Then I am puting A into a banded form and using DGBSV and getting a different output.

Here is my expected inputs and outputs where A is the first 9x9 matrix B is -r 1x9 and x is sk 1x9. Inputs and Ouputs using DGESV

And this is what my usage of DGBSV looks like A=JBtemp,B=-r,x=SK: [Inputs and Ouputs using DGBSV(https://i.sstatic.net/hiVTJ.png)

We can see that the x values dont match and here is my code usage of the two functions.

call dgesv(n,1,J0,n,ipiv,r,n,info)

call dgbsv(n,KL,KU,1,JBtemp,KU+1+KL+KL,ipiv,r,n,info)

Solution

  • This is a non-problem.

    Both results are correct - yes, really! - for the data that you have given them. I checked that with Gaussian elimination.

    In your B vector (what you label -r) in the first example it ends

    50.1899...
    70.9...
    50.19...
    

    but in the second example it ends

    50.1899...
    -70.9...
    -50.19...
    

    Note the change from positive to negative for the last two entries of B.