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

Solve band matrix with GBTRS

cyfeng
Beginner
977 Views

I try to solve a simple case AX=B with subroutine GBTRS.

The matrix B is 6x1: BT=(3, 1, 11, -3, -5, -1)

The matrix A 6x6 containing 2 subdiagonals and 1 superdiagonal is:

A=2 -1
-3 1 -2
0 -1 2
2 1 1
1 -1 -2 0
-3 -3 1

Doesthe matrix A in band matrixbe arranged right?

Is the following codecorrect?I can't get the correct answer...:(

REAL::A(6,6),B(6)
INTEGER::IPIV(6), INFO

DATA A/0.,0.,0.,2.,-3.,0., 0.,0.,-1.,1.,0.,0., 0.,0.,-2.,-1.,2.,1., &
& 0.,0.,2.,1.,-1.,-3., 0.,0.,1.,-2.,-3.,0., 0.,0.,0.,1.,0.,0. /
DATA B/3., 1., 11., -3., -5., -1./

CALL GBTRF(A,2,6,IPIV)
CALL GBTRS(A, B, IPIV)

0 Kudos
1 Solution
Vladimir_Koldakov__I
New Contributor III
977 Views

Sorry, I was wrong. It is really KL=2. In such a case you should put KL into the second interface:

CALL GBTRS(A, B, IPIV, 2)

Otherwise it is assumed KL=KU=5/3

-Vladimir


View solution in original post

0 Kudos
4 Replies
Vladimir_Koldakov__I
New Contributor III
977 Views
Quoting - cyfeng

I try to solve a simple case AX=B with subroutine GBTRS.

The matrix B is 6x1: BT=(3, 1, 11, -3, -5, -1)

The matrix A 6x6 containing 2 subdiagonals and 1 superdiagonal is:

A=2 -1
-3 1 -2
0 -1 2
2 1 1
1 -1 -2 0
-3 -3 1

Doesthe matrix A in band matrixbe arranged right?

Is the following codecorrect?I can't get the correct answer...:(

REAL::A(6,6),B(6)
INTEGER::IPIV(6), INFO

DATA A/0.,0.,0.,2.,-3.,0., 0.,0.,-1.,1.,0.,0., 0.,0.,-2.,-1.,2.,1., &
& 0.,0.,2.,1.,-1.,-3., 0.,0.,1.,-2.,-3.,0., 0.,0.,0.,1.,0.,0. /
DATA B/3., 1., 11., -3., -5., -1./

CALL GBTRF(A,2,6,IPIV)
CALL GBTRS(A, B, IPIV)

0 Kudos
Vladimir_Koldakov__I
New Contributor III
977 Views
Hi, cyfeng,
As I see the matrix has 1 upper and one lower subdiagonals.
In this case the correct call isGBTRF(A,1,6,IPIV) as the second argument is KL.
-Vladimir

0 Kudos
Vladimir_Koldakov__I
New Contributor III
978 Views

Sorry, I was wrong. It is really KL=2. In such a case you should put KL into the second interface:

CALL GBTRS(A, B, IPIV, 2)

Otherwise it is assumed KL=KU=5/3

-Vladimir


0 Kudos
cyfeng
Beginner
977 Views

Sorry, I was wrong. It is really KL=2. In such a case you should put KL into the second interface:

CALL GBTRS(A, B, IPIV, 2)

Otherwise it is assumed KL=KU=5/3

-Vladimir


Hi, Vladimir.

I paid too much attention to the GBTRF to make such a stupid question.

I should read the document more carefully.

Thank you very much :)

0 Kudos
Reply