計算ルーチン: 複素行列のシュール分解の並べ替え : (選択した固有値に対する右不変部分空間の正規直交規定を作る)

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

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > 複素行列のシュール分解の並べ替え

概要

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

入力データ

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

このデータをダウンロード
ZTRSEN Example Program Data
  4                                                     :Value of N
 (-6.0004,-6.9999) ( 0.3637,-0.3656) (-0.1880, 0.4787) ( 0.8785,-0.2539)
 ( 0.0000, 0.0000) (-5.0000, 2.0060) (-0.0307,-0.7217) (-0.2290, 0.1313)
 ( 0.0000, 0.0000) ( 0.0000, 0.0000) ( 7.9982,-0.9964) ( 0.9357, 0.5359)
 ( 0.0000, 0.0000) ( 0.0000, 0.0000) ( 0.0000, 0.0000) ( 3.0023,-3.9998)
                                                        :End of matrix T
 (-0.8347,-0.1364) (-0.0628, 0.3806) ( 0.2765,-0.0846) ( 0.0633,-0.2199)
 ( 0.0664,-0.2968) ( 0.2365, 0.5240) (-0.5877,-0.4208) ( 0.0835, 0.2183)
 (-0.0362,-0.3215) ( 0.3143,-0.5473) ( 0.0576,-0.5736) ( 0.0057,-0.4058)
 ( 0.0086, 0.2958) (-0.3416,-0.0757) (-0.1900,-0.1600) ( 0.8327,-0.1868)
                                                        :End of matrix Q
  T   F   F   T                                         :End of SELECT

出力結果

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

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

 Matrix A created from Q*T*Q^T
                    1                 2                 3                 4
 1  (-3.9702,-5.0406) (-4.1108, 3.7002) (-0.3403, 1.0098) ( 1.2899,-0.8590)
 2  ( 0.3397,-1.5006) ( 1.5201,-0.4301) ( 1.8797,-5.3804) ( 3.3606, 0.6498)
 3  ( 3.3101,-3.8506) ( 2.4996, 3.4504) ( 0.8802,-1.0802) ( 0.6401,-1.4800)
 4  (-1.0999, 0.8199) ( 1.8103,-1.5905) ( 3.2502, 1.3297) ( 1.5701,-3.4397)

 Condition number estimate of the selected cluster of eigenvalues =   1.02E+00

 Condition number estimate of the specified invariant subspace    =   1.82E-01

ソースコード

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

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


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

!     ZTRSEN Example Program Text

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

!     .. Use Statements ..
      Use blas_interfaces, Only: zgemm
      Use lapack_example_aux, Only: nagf_file_print_matrix_complex_gen_comp
      Use lapack_interfaces, Only: zlange, ztrsen
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Complex (Kind=dp) :: alpha, beta
      Real (Kind=dp) :: norm, s, sep
      Integer :: i, ifail, info, lda, ldc, ldq, ldt, lwork, m, n
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: a(:, :), c(:, :), q(:, :), t(:, :), &
        w(:), work(:)
      Real (Kind=dp) :: rwork(1)
      Logical, Allocatable :: select(:)
      Character (1) :: clabs(1), rlabs(1)
!     .. Intrinsic Procedures ..
      Intrinsic :: cmplx, epsilon
!     .. Executable Statements ..
      Write (nout, *) 'ZTRSEN Example Program Results'
      Write (nout, *)
      Flush (nout)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n
      ldc = n
      lda = n
      ldq = n
      ldt = n
      lwork = (n*n)/2
      Allocate (a(lda,n), c(ldc,n), q(ldq,n), t(ldt,n), w(n), work(lwork), &
        select(n))

!     Read T, Q and the logical array SELECT from data file

      Read (nin, *)(t(i,1:n), i=1, n)
      Read (nin, *)
      Read (nin, *)(q(i,1:n), i=1, n)
      Read (nin, *)
      Read (nin, *) select(1:n)

!     Compute Q * T * Q**T to find  A
      alpha = cmplx(1, kind=dp)
      beta = cmplx(0, kind=dp)
      Call zgemm('N', 'N', n, n, n, alpha, q, ldq, t, ldt, beta, c, ldc)
      Call zgemm('N', 'C', n, n, n, alpha, c, ldc, q, ldq, beta, a, lda)

!     Print Matrix A, as computed from Q * T * Q**T
!     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', 'Matrix A created from Q*T*Q^T', 'Integer', &
        rlabs, 'Integer', clabs, 80, 0, ifail)

      Write (nout, *)
      Flush (nout)

!     Reorder the Schur factor T and update the matrix Q to obtain TT and QT

      Call ztrsen('Both', 'Vectors', select, n, t, ldt, q, ldq, w, m, s, sep, &
        work, lwork, info)

!     Compute (Q * T * Q^H) - (QT * TT * QT^H) and store in A,
!     i.e. the difference between reconstructed A using Schur and reordered
!          Schur decompositions.
      alpha = cmplx(1, kind=dp)
      beta = cmplx(0, kind=dp)
      Call zgemm('N', 'N', n, n, n, alpha, q, ldq, t, ldt, beta, c, ldc)
      alpha = cmplx(-1, kind=dp)
      beta = cmplx(1, kind=dp)
      Call zgemm('N', 'C', n, n, n, alpha, c, ldc, q, ldq, beta, a, lda)

!     Find norm of difference matrix and print warning if it is too large
      norm = zlange('O', lda, n, a, lda, rwork)
      If (norm>epsilon(1.0E0_dp)**0.5_dp) Then
        Write (nout, *) 'Norm of A - (QT * TT * QT^H) is much greater than 0.'
        Write (nout, *) 'Schur factorization has failed.'
      Else
!       Print condition estimates
        Write (nout, 100) 'Condition number estimate', &
          ' of the selected cluster of eigenvalues = ', 1.0_dp/s
        Write (nout, *)
        Write (nout, 100) 'Condition number estimate of the specified ', &
          'invariant subspace    = ', 1.0_dp/sep
      End If

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


ご案内
関連情報
Privacy Policy  /  Trademarks