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

入力データ
(本ルーチンの詳細はZGBSV のマニュアルページを参照)| このデータをダウンロード |
ZGBSV Example Program Data
4 1 2 :Values of N, KL and KU
(-1.65, 2.26) ( -2.05, -0.85) ( 0.97, -2.84)
( 0.00, 6.30) ( -1.48, -1.75) ( -3.99, 4.01) ( 0.59, -0.48)
( -0.77, 2.83) ( -1.06, 1.94) ( 3.33, -1.04)
( 4.48, -1.09) ( -0.46, -1.72) :End of matrix A
(-1.06, 21.50) (-22.72,-53.90) ( 28.24,-38.60) (-34.56, 16.73) :End of vector B
出力結果
(本ルーチンの詳細はZGBSV のマニュアルページを参照)| この出力例をダウンロード |
ZGBSV Example Program Results
Solution
(-3.0000, 2.0000) ( 1.0000,-7.0000) (-5.0000, 4.0000) ( 6.0000,-8.0000)
Details of factorization
( 0.0000, 6.3000) (-1.4800,-1.7500) (-3.9900, 4.0100) ( 0.5900,-0.4800)
( 0.3587, 0.2619) (-0.7700, 2.8300) (-1.0600, 1.9400) ( 3.3300,-1.0400)
( 0.2314, 0.6358) ( 4.9303,-3.0086) (-1.7692,-1.8587)
( 0.7604, 0.2429) ( 0.4338, 0.1233)
Pivot indices
2 3 3 4
ソースコード
(本ルーチンの詳細はZGBSV のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program zgbsv_example
! ZGBSV Example Program Text
! Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com
! .. Use Statements ..
Use lapack_example_aux, Only: nagf_file_print_matrix_complex_band_comp
Use lapack_interfaces, Only: zgbsv
Use lapack_precision, Only: dp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, ifail, info, j, k, kl, ku, ldab, n
! .. Local Arrays ..
Complex (Kind=dp), Allocatable :: ab(:, :), b(:)
Integer, Allocatable :: ipiv(:)
Character (1) :: clabs(1), rlabs(1)
! .. Intrinsic Procedures ..
Intrinsic :: max, min
! .. Executable Statements ..
Write (nout, *) 'ZGBSV Example Program Results'
Write (nout, *)
! Skip heading in data file
Read (nin, *)
Read (nin, *) n, kl, ku
ldab = 2*kl + ku + 1
Allocate (ab(ldab,n), b(n), ipiv(n))
! Read the band matrix A and the right hand side b from data file
k = kl + ku + 1
Read (nin, *)((ab(k+i-j,j),j=max(i-kl,1),min(i+ku,n)), i=1, n)
Read (nin, *) b(1:n)
! Solve the equations Ax = b for x
Call zgbsv(n, kl, ku, 1, ab, ldab, ipiv, b, n, info)
If (info==0) Then
! Print solution
Write (nout, *) 'Solution'
Write (nout, 100) b(1:n)
! Print details of the factorization
Write (nout, *)
Flush (nout)
! ifail: behaviour on error exit
! =0 for hard exit, =1 for quiet-soft, =-1 for noisy-soft
ifail = 0
Call nagf_file_print_matrix_complex_band_comp(n, n, kl, kl+ku, ab, &
ldab, 'Bracketed', 'F7.4', 'Details of factorization', 'None', &
rlabs, 'None', clabs, 80, 0, ifail)
! Print pivot indices'
Write (nout, *)
Write (nout, *) 'Pivot indices'
Write (nout, 110) ipiv(1:n)
Else
Write (nout, 120) 'The (', info, ',', info, ')', &
' element of the factor U is zero'
End If
100 Format ((3X,4(' (',F7.4,',',F7.4,')',:)))
110 Format (1X, I5, 3I18)
120 Format (1X, A, I3, A, I3, A, A)
End Program
