計算ルーチン: 複素行列の逆行列 : ( ZGETRF により既に分解された行列)

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

概要

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

入力データ

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

このデータをダウンロード
ZGETRI Example Program Data
  4                                                       :Value of N
 (-1.34, 2.55) ( 0.28, 3.17) (-6.39,-2.20) ( 0.72,-0.92)
 (-0.17,-1.41) ( 3.31,-0.15) (-0.15, 1.34) ( 1.29, 1.38)
 (-3.29,-2.39) (-1.91, 4.42) (-0.14,-1.35) ( 1.72, 1.35)
 ( 2.41, 0.39) (-0.56, 1.47) (-0.83,-0.69) (-1.96, 0.67)  :End of matrix A

出力結果

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

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

 Inverse
                    1                 2                 3                 4
 1  ( 0.0757,-0.4324) ( 1.6512,-3.1342) ( 1.2663, 0.0418) ( 3.8181, 1.1195)
 2  (-0.1942, 0.0798) (-1.1900,-0.1426) (-0.2401,-0.5889) (-0.0101,-1.4969)
 3  (-0.0957,-0.0491) ( 0.7371,-0.4290) ( 0.3224, 0.0776) ( 0.6887, 0.7891)
 4  ( 0.3702,-0.5040) ( 3.7253,-3.1813) ( 1.7014, 0.7267) ( 3.9367, 3.3255)

ソースコード

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

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


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

!     ZGETRI 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_gen_comp
      Use lapack_interfaces, Only: zgetrf, zgetri
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer :: i, ifail, info, lda, lwork, n
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: a(:, :), work(:)
      Integer, Allocatable :: ipiv(:)
      Character (1) :: clabs(1), rlabs(1)
!     .. Executable Statements ..
      Write (nout, *) 'ZGETRI Example Program Results'
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n
      lda = n
      lwork = 64*n
      Allocate (a(lda,n), work(lwork), ipiv(n))

!     Read A from data file

      Read (nin, *)(a(i,1:n), i=1, n)

!     Factorize A
      Call zgetrf(n, n, a, lda, ipiv, info)

      Write (nout, *)
      Flush (nout)
      If (info==0) Then

!       Compute inverse of A
        Call zgetri(n, a, lda, ipiv, work, lwork, info)

!       Print inverse

!       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_gen_comp('General', ' ', n, n, a, &
          lda, 'Bracketed', 'F7.4', 'Inverse', 'Integer', rlabs, 'Integer', &
          clabs, 80, 0, ifail)

      Else
        Write (nout, *) 'The factor U is singular'
      End If

    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks