計算ルーチン: 実一般長方行列の LQ 分解

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

ホーム > LAPACKサンプルプログラム目次 > 計算ルーチン > 実一般長方行列の LQ 分解

概要

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

入力データ

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

このデータをダウンロード
DGELQF Example Program Data
  4  6  2                                   :Values of M, N and NRHS
 -5.42   3.28  -3.68   0.27   2.06   0.46
 -1.65  -3.40  -3.20  -1.03  -4.06  -0.01
 -0.37   2.35   1.90   4.31  -1.76   1.13
 -3.15  -0.11   1.99  -2.70   0.26   4.50   :End of matrix A
 -2.87  -5.23
  1.63   0.29
 -3.52   4.76
  0.45  -8.41                               :End of matrix B

出力結果

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

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

 Minimum-norm solution(s)
             1          2
 1      0.2371     0.7383
 2     -0.4575     0.0158
 3     -0.0085    -0.0161
 4     -0.5192     1.0768
 5      0.0239    -0.6436
 6     -0.0543    -0.6613

ソースコード

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

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


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

!     DGELQF Example Program Text

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

!     .. Use Statements ..
      Use blas_interfaces, Only: dtrsm
      Use lapack_example_aux, Only: nagf_file_print_matrix_real_gen
      Use lapack_interfaces, Only: dgelqf, dormlq
      Use lapack_precision, Only: dp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Real (Kind=dp), Parameter :: one = 1.0E0_dp
      Real (Kind=dp), Parameter :: zero = 0.0E0_dp
      Integer, Parameter :: nin = 5, nout = 6
!     .. Local Scalars ..
      Integer :: i, ifail, info, lda, ldb, lwork, m, n, nrhs
!     .. Local Arrays ..
      Real (Kind=dp), Allocatable :: a(:, :), b(:, :), tau(:), work(:)
!     .. Executable Statements ..
      Write (nout, *) 'DGELQF Example Program Results'
!     Skip heading in data file
      Read (nin, *)
      Read (nin, *) m, n, nrhs
      lda = m
      ldb = n
      lwork = 64*n
      Allocate (a(lda,n), b(ldb,nrhs), tau(n), work(lwork))

!     Read A and B from data file

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

!     Compute the LQ factorization of A
      Call dgelqf(m, n, a, lda, tau, work, lwork, info)

!     Solve L*Y = B, storing the result in B
      Call dtrsm('Left', 'Lower', 'No transpose', 'Non-Unit', m, nrhs, one, a, &
        lda, b, ldb)

!     Set rows (M+1) to N of B to zero

      If (m<n) Then
        b(m+1:n, 1:nrhs) = zero
      End If

!     Compute minimum-norm solution X = (Q**T)*B in B
      Call dormlq('Left', 'Transpose', n, nrhs, m, a, lda, tau, b, ldb, work, &
        lwork, info)

!     Print minimum-norm solution(s)

      Write (nout, *)
      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_real_gen('General', ' ', n, nrhs, b, ldb, &
        'Minimum-norm solution(s)', ifail)

    End Program


ご案内
関連情報
Privacy Policy  /  Trademarks