/
dgebrd_example.f90
executable file
·53 lines (43 loc) · 1.46 KB
/
dgebrd_example.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Program dgebrd_example
! DGEBRD Example Program Text
! Copyright (c) 2018, Numerical Algorithms Group (NAG Ltd.)
! For licence see
! https://github.com/numericalalgorithmsgroup/LAPACK_Examples/blob/master/LICENCE.md
! .. Use Statements ..
Use lapack_interfaces, Only: dgebrd
Use lapack_precision, Only: dp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Integer :: i, info, lda, lwork, m, n
! .. Local Arrays ..
Real (Kind=dp), Allocatable :: a(:, :), d(:), e(:), taup(:), tauq(:), &
work(:)
! .. Intrinsic Procedures ..
Intrinsic :: min
! .. Executable Statements ..
Write (nout, *) 'DGEBRD Example Program Results'
! Skip heading in data file
Read (nin, *)
Read (nin, *) m, n
lda = m
lwork = 64*(m+n)
Allocate (a(lda,n), d(n), e(n-1), taup(n), tauq(n), work(lwork))
! Read A from data file
Read (nin, *)(a(i,1:n), i=1, m)
! Reduce A to bidiagonal form
Call dgebrd(m, n, a, lda, d, e, tauq, taup, work, lwork, info)
! Print bidiagonal form
Write (nout, *)
Write (nout, *) 'Diagonal'
Write (nout, 100) d(1:min(m,n))
If (m>=n) Then
Write (nout, *) 'Superdiagonal'
Else
Write (nout, *) 'Subdiagonal'
End If
Write (nout, 100) e(1:min(m,n)-1)
100 Format (1X, 8F9.4)
End Program