計算ルーチン: 複素エルミート行列の対称三重対角形へのユニタリ縮約 : (圧縮格納形式)

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

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > 複素エルミート行列の対称三重対角形へのユニタリ縮約

概要

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

入力データ

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

このデータをダウンロード
ZHPTRD Example Program Data
  4                                                        :Value of N
  'L'                                                      :Value of UPLO
 (-2.28, 0.00)
 ( 1.78, 2.03) (-1.12, 0.00)
 ( 2.26,-0.10) ( 0.01,-0.43) (-0.37, 0.00)
 (-0.12,-2.53) (-1.07,-0.86) ( 2.31, 0.92) (-0.73, 0.00)   :End of matrix A

出力結果

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

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

 Diagonal and off-diagonal elements of tridiagonal form

     i         D            E
     1     -2.28000      4.33846
     2     -0.12846      2.02259
     3     -0.16659      1.80232
     4     -1.92495

ソースコード

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

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


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

!     ZHPTRD Example Program Text

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

!     .. Use Statements ..
      Use lapack_interfaces, Only: zhptrd
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer :: i, info, j, n
      Character (1) :: uplo
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: ap(:), tau(:)
      Real (Kind=dp), Allocatable :: d(:), e(:)
!     .. Intrinsic Procedures ..
      Intrinsic :: abs
!     .. Executable Statements ..
      Write (nout, *) 'ZHPTRD Example Program Results'
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n

      Allocate (ap(n*(n+1)/2), tau(n-1), d(n), e(n-1))

!     Read A from data file and copy a into AW

      Read (nin, *) uplo
      If (uplo=='U') Then
        Read (nin, *)((ap(i+j*(j-1)/2),j=i,n), i=1, n)
      Else If (uplo=='L') Then
        Read (nin, *)((ap(i+(2*n-j)*(j-1)/2),j=1,i), i=1, n)
      End If

!     Reduce A to tridiagonal form
      Call zhptrd(uplo, n, ap, d, e, tau, info)

      If (info==0) Then
!       Print the diagonal and off-diagonal of tridiagonal T.
!       The absolute value of E is printed since this can vary by a change of
!       sign (corresponding to multiplying through a column of Q by -1).

        Write (nout, *)
        Write (nout, *) &
          'Diagonal and off-diagonal elements of tridiagonal form'
        Write (nout, *)
        Write (nout, 100) 'i', 'D', 'E'
        Do i = 1, n - 1
          Write (nout, 110) i, d(i), abs(e(i))
        End Do
        Write (nout, 110) n, d(n)

      Else
        Write (nout, 120) info
      End If

100   Format (5X, A, 9X, A, 12X, A)
110   Format (1X, I5, 2(1X,F12.5))
120   Format (1X, '** ZHPTRD retuned with INFO = ', I10)

    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks