概要
本サンプルはFortran言語によりLAPACKルーチンZGTSVを利用するサンプルプログラムです。
以下の式を解きます。
及び

入力データ
(本ルーチンの詳細はZGTSV のマニュアルページを参照)| このデータをダウンロード |
ZGTSV Example Program Data 5 :Value of N ( 2.0, -1.0) ( 2.0, 1.0) ( -1.0, 1.0) ( 1.0, -1.0) :End of DU ( -1.3, 1.3) ( -1.3, 1.3) ( -1.3, 3.3) ( -0.3, 4.3) ( -3.3, 1.3) :End of D ( 1.0, -2.0) ( 1.0 , 1.0) ( 2.0, -3.0) ( 1.0, 1.0) :End of DL ( 2.4, -5.0) ( 3.4, 18.2) (-14.7, 9.7) ( 31.9, -7.7) ( -1.0, 1.6) :End of B
出力結果
(本ルーチンの詳細はZGTSV のマニュアルページを参照)| この出力例をダウンロード |
ZGTSV Example Program Results Solution ( 1.0000, 1.0000) ( 3.0000, -1.0000) ( 4.0000, 5.0000) ( -1.0000, -2.0000) ( 1.0000, -1.0000)
ソースコード
(本ルーチンの詳細はZGTSV のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program zgtsv_example
! ZGTSV Example Program Text
! Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com
! .. Use Statements ..
Use lapack_interfaces, Only: zgtsv
Use lapack_precision, Only: dp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: info, n
! .. Local Arrays ..
Complex (Kind=dp), Allocatable :: b(:), d(:), dl(:), du(:)
! .. Executable Statements ..
Write (nout, *) 'ZGTSV Example Program Results'
Write (nout, *)
! Skip heading in data file
Read (nin, *)
Read (nin, *) n
Allocate (b(n), d(n), dl(n-1), du(n-1))
! Read the tridiagonal matrix A and the right hand side B from
! data file
Read (nin, *) du(1:n-1)
Read (nin, *) d(1:n)
Read (nin, *) dl(1:n-1)
Read (nin, *) b(1:n)
! Solve the equations Ax = b for x
Call zgtsv(n, 1, dl, d, du, b, n, info)
If (info==0) Then
! Print solution
Write (nout, *) 'Solution'
Write (nout, 100) b(1:n)
Else
Write (nout, 110) 'The (', info, ',', info, ')', &
' element of the factor U is zero'
End If
100 Format (4(' (',F8.4,',',F8.4,')',:))
110 Format (1X, A, I3, A, I3, A, A)
End Program
