計算ルーチン: DGTTRFで LU 分解済みの結果を用いて実三重対角行列相反条件数を推定

LAPACKサンプルソースコード : 使用ルーチン名:DGTCON

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > DGTTRFで LU 分解済みの結果を用いて実三重対角行列相反条件数を推定

概要

本サンプルはFortran言語によりLAPACKルーチンDGTCONを利用するサンプルプログラムです。

入力データ

(本ルーチンの詳細はDGTCON のマニュアルページを参照)

このデータをダウンロード
DGTCON Example Program Data
   5                           :Value of N
        2.1  -1.0   1.9   8.0
  3.0   2.3  -5.0  -0.9   7.1
  3.4   3.6   7.0  -6.0        :End of matrix A

出力結果

(本ルーチンの詳細はDGTCON のマニュアルページを参照)

この出力例をダウンロード
 DGTCON Example Program Results

 Estimate of condition number =   9.27E+01

ソースコード

(本ルーチンの詳細はDGTCON のマニュアルページを参照)

※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。


このソースコードをダウンロード
    Program dgtcon_example

!     DGTCON Example Program Text

!     Copyright 2017, Numerical Algorithms Group Ltd. http://www.nag.com

!     .. Use Statements ..
      Use lapack_interfaces, Only: dgtcon, dgttrf, dlangt
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=dp) :: anorm, rcond
      Integer :: info, n
!     .. Local Arrays ..
      Real (Kind=dp), Allocatable :: d(:), dl(:), du(:), du2(:), work(:)
      Integer, Allocatable :: ipiv(:), iwork(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: epsilon
!     .. Executable Statements ..
      Write (nout, *) 'DGTCON Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n

      Allocate (d(n), dl(n-1), du(n-1), du2(n-2), work(2*n), ipiv(n), &
        iwork(n))

!     Read the tridiagonal matrix A from data file

      Read (nin, *) du(1:n-1)
      Read (nin, *) d(1:n)
      Read (nin, *) dl(1:n-1)

!     Compute the 1-norm of A
      anorm = dlangt('1-norm', n, dl, d, du)

!     Factorize the tridiagonal matrix A
      Call dgttrf(n, dl, d, du, du2, ipiv, info)

      If (info==0) Then

!       Estimate the condition number of A
        Call dgtcon('1-norm', n, dl, d, du, du2, ipiv, anorm, rcond, work, &
          iwork, info)

!       Print the estimated condition number

        If (rcond>=epsilon(1.0E0_dp)) Then
          Write (nout, 100) 'Estimate of condition number = ', 1.0_dp/rcond
        Else
          Write (nout, 100) 'A is singular to working precision. RCOND = ', &
            rcond
        End If

      Else
        Write (nout, 110) 'The (', info, ',', info, ')', &
          ' element of the factor U is zero'
      End If

100   Format (1X, A, 1P, E10.2)
110   Format (1X, A, I3, A, I3, A, A)
    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks