概要
本サンプルはFortran言語によりLAPACKルーチンZUNGQRを利用するサンプルプログラムです。
入力データ
(本ルーチンの詳細はZUNGQR のマニュアルページを参照)| このデータをダウンロード |
ZUNGQR Example Program Data 6 4 :Values of M and N ( 0.96,-0.81) (-0.03, 0.96) (-0.91, 2.06) (-0.05, 0.41) (-0.98, 1.98) (-1.20, 0.19) (-0.66, 0.42) (-0.81, 0.56) ( 0.62,-0.46) ( 1.01, 0.02) ( 0.63,-0.17) (-1.11, 0.60) (-0.37, 0.38) ( 0.19,-0.54) (-0.98,-0.36) ( 0.22,-0.20) ( 0.83, 0.51) ( 0.20, 0.01) (-0.17,-0.46) ( 1.47, 1.59) ( 1.08,-0.28) ( 0.20,-0.12) (-0.07, 1.23) ( 0.26, 0.26) :End of matrix A
出力結果
(本ルーチンの詳細はZUNGQR のマニュアルページを参照)| この出力例をダウンロード |
ZUNGQR Example Program Results
The leading 4 columns of Q
1 2 3 4
1 (-0.3110, 0.2624) (-0.3175, 0.4835) ( 0.4966,-0.2997) (-0.0072,-0.3718)
2 ( 0.3175,-0.6414) (-0.2062, 0.1577) (-0.0793,-0.3094) (-0.0282,-0.1491)
3 (-0.2008, 0.1490) ( 0.4892,-0.0900) ( 0.0357,-0.0219) ( 0.5625,-0.0710)
4 ( 0.1199,-0.1231) ( 0.2566,-0.3055) ( 0.4489,-0.2141) (-0.1651, 0.1800)
5 (-0.2689,-0.1652) ( 0.1697,-0.2491) (-0.0496, 0.1158) (-0.4885,-0.4540)
6 (-0.3499, 0.0907) (-0.0491,-0.3133) (-0.1256,-0.5300) ( 0.1039, 0.0450)
ソースコード
(本ルーチンの詳細はZUNGQR のマニュアルページを参照)※本サンプルソースコードのご利用手順は「サンプルのコンパイル及び実行方法」をご参照下さい。
| このソースコードをダウンロード |
Program zungqr_example
! ZUNGQR 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: zgeqrf, zungqr
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, m, n
Character (30) :: title
! .. Local Arrays ..
Complex (Kind=dp), Allocatable :: a(:, :), tau(:), work(:)
Character (1) :: clabs(1), rlabs(1)
! .. Executable Statements ..
Write (nout, *) 'ZUNGQR Example Program Results'
! Skip heading in data file
Read (nin, *)
Read (nin, *) m, n
lda = m
lwork = 64*n
Allocate (a(lda,n), tau(n), work(lwork))
! Read A from data file
Read (nin, *)(a(i,1:n), i=1, m)
! Compute the QR factorization of A
Call zgeqrf(m, n, a, lda, tau, work, lwork, info)
! Form the leading N columns of Q explicitly
Call zungqr(m, n, n, a, lda, tau, work, lwork, info)
! Print the leading N columns of Q only
Write (nout, *)
Write (title, 100) n
Flush (nout)
! 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', ' ', m, n, a, &
lda, 'Bracketed', 'F7.4', title, 'Integer', rlabs, 'Integer', clabs, &
80, 0, ifail)
100 Format ('The leading ', I2, ' columns of Q')
End Program
