複素線形方程式: 混合精度演算を用いた複素エルミート正定値連立一次方程式の解

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

ホーム > LAPACKサンプルプログラム目次 > 複素線形方程式 > 混合精度演算を用いた複素エルミート正定値連立一次方程式の解

概要

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

入力データ

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

このデータをダウンロード
ZCPOSV Example Program Data
   4           1                                             :Values of N, R
 ( 3.23,  0.00) ( 1.51, -1.92) ( 1.90,  0.84) ( 0.42,  2.50)
                ( 3.58,  0.00) (-0.23,  1.11) (-1.18,  1.37)
                               ( 4.09,  0.00) ( 2.33, -0.14)
                                              ( 4.29,  0.00) :End of matrix A
 ( 3.93, -6.14) ( 6.17,  9.42) (-7.17,-21.83) ( 1.99,-14.38) :End of vector b

出力結果

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

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

 Solution
    ( 1.0000,-1.0000) (-0.0000, 3.0000) (-4.0000,-5.0000) ( 2.0000, 1.0000)

ソースコード

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

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


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

!     ZCPOSV Example Program Text

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

!     .. Use Statements ..
      Use lapack_interfaces, Only: zcposv
      Use lapack_precision, Only: sp, dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer :: i, info, iter, lda, ldb, ldx, n, r
!     .. Local Arrays ..
      Complex (Kind=dp), Allocatable :: a(:, :), b(:, :), work(:, :), x(:, :)
      Complex (Kind=sp), Allocatable :: swork(:)
      Real (Kind=dp), Allocatable :: rwork(:)
!     .. Executable Statements ..
      Write (nout, *) 'ZCPOSV Example Program Results'
      Write (nout, *)
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) n, r
      lda = n
      ldb = n
      ldx = n
      Allocate (a(lda,n), b(ldb,r), work(n,r), x(ldx,r), swork(n*(n+ &
        r)), rwork(n))

!     Read A and B from data file

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

!     Solve the equations Ax = b for x
      Call zcposv('U', n, r, a, lda, b, ldb, x, ldx, work, swork, rwork, iter, &
        info)

      If (info==0) Then

!       Print solution

        Write (nout, *) 'Solution'
        Write (nout, 100)(x(i,1:r), i=1, n)

      Else
        Write (nout, 110) 'The leading minor of order ', info, &
          ' is not positive definite'
      End If

100   Format ((3X,4(' (',F7.4,',',F7.4,')',:)))
110   Format (1X, A, I3, A)
    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks