LAPACK在使用带状矩阵求解器时产生不同的输出

huangapple go评论59阅读模式
英文:

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 putting 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.
LAPACK在使用带状矩阵求解器时产生不同的输出

And this is what my usage of DGBSV looks like A=JBtemp, B=-r, x=SK:
[LAPACK在使用带状矩阵求解器时产生不同的输出](https://i.stack.imgur.com/hiVTJ.png)

We can see that the x values don't 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)
英文:

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.
LAPACK在使用带状矩阵求解器时产生不同的输出

And this is what my usage of DGBSV looks like A=JBtemp,B=-r,x=SK:
[LAPACK在使用带状矩阵求解器时产生不同的输出(https://i.stack.imgur.com/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)

答案1

得分: 2

这是一个无需担忧的问题。

两个结果都是正确的 - 是的,真的! - 对于你提供的数据。 我用高斯消元法来验证了这一点。

在你的B向量(你标记为 -r)的第一个示例中,它以

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

但在第二个示例中,它以

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

请注意B的最后两个条目从正变为负。

英文:

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.

huangapple
  • 本文由 发表于 2023年3月21日 02:55:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/75794234.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定