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

入力データ
(本ルーチンの詳細はZPTSV のマニュアルページを参照)| このデータをダウンロード |
ZPTSV Example Program Data
4 :Value of N
16.0 41.0 46.0 21.0 :End of diagonal D
( 16.0, 16.0) ( 18.0, -9.0) ( 1.0, -4.0) :End of sub-diagonal E
( 64.0, 16.0) ( 93.0, 62.0) ( 78.0,-80.0) ( 14.0,-27.0) :End of vector b
出力結果
(本ルーチンの詳細はZPTSV のマニュアルページを参照)| この出力例をダウンロード |
ZPTSV Example Program Results Solution ( 2.0000, 1.0000) ( 1.0000, 1.0000) ( 1.0000, -2.0000) ( 1.0000, -1.0000) Diagonal elements of the diagonal matrix D 16.0000 9.0000 1.0000 4.0000 Subdiagonal elements of the Cholesky factor L ( 1.0000, 1.0000) ( 2.0000, -1.0000) ( 1.0000, -4.0000)
ソースコード
(本ルーチンの詳細はZPTSV のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program zptsv_example
! ZPTSV Example Program Text
! Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com
! .. Use Statements ..
Use lapack_interfaces, Only: zptsv
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(:), e(:)
Real (Kind=dp), Allocatable :: d(:)
! .. Executable Statements ..
Write (nout, *) 'ZPTSV Example Program Results'
Write (nout, *)
! Skip heading in data file
Read (nin, *)
Read (nin, *) n
Allocate (b(n), e(n-1), d(n))
! Read the lower bidiagonal part of the tridiagonal matrix A and
! the right hand side b from data file
Read (nin, *) d(1:n)
Read (nin, *) e(1:n-1)
Read (nin, *) b(1:n)
! Solve the equations Ax = b for x
Call zptsv(n, 1, d, e, b, n, info)
If (info==0) Then
! Print solution
Write (nout, *) 'Solution'
Write (nout, 100) b(1:n)
! Print details of factorization
Write (nout, *)
Write (nout, *) 'Diagonal elements of the diagonal matrix D'
Write (nout, 110) d(1:n)
Write (nout, *)
Write (nout, *) 'Subdiagonal elements of the Cholesky factor L'
Write (nout, 100) e(1:n-1)
Else
Write (nout, 120) 'The leading minor of order ', info, &
' is not positive definite'
End If
100 Format (4(' (',F8.4,',',F8.4,')',:))
110 Format ((2X,F7.4,3(11X,F7.4)))
120 Format (1X, A, I3, A)
End Program
