KTH framework for Nek5000 toolboxes; testing version  0.0.1
dorgtr.f
Go to the documentation of this file.
1  SUBROUTINE dorgtr( UPLO, N, A, LDA, TAU, WORK, LWORK, INFO )
2 *
3 * -- LAPACK routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * June 30, 1999
7 *
8 * .. Scalar Arguments ..
9  CHARACTER UPLO
10  INTEGER INFO, LDA, LWORK, N
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DORGTR generates a real orthogonal matrix Q which is defined as the
20 * product of n-1 elementary reflectors of order N, as returned by
21 * DSYTRD:
22 *
23 * if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
24 *
25 * if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
26 *
27 * Arguments
28 * =========
29 *
30 * UPLO (input) CHARACTER*1
31 * = 'U': Upper triangle of A contains elementary reflectors
32 * from DSYTRD;
33 * = 'L': Lower triangle of A contains elementary reflectors
34 * from DSYTRD.
35 *
36 * N (input) INTEGER
37 * The order of the matrix Q. N >= 0.
38 *
39 * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
40 * On entry, the vectors which define the elementary reflectors,
41 * as returned by DSYTRD.
42 * On exit, the N-by-N orthogonal matrix Q.
43 *
44 * LDA (input) INTEGER
45 * The leading dimension of the array A. LDA >= max(1,N).
46 *
47 * TAU (input) DOUBLE PRECISION array, dimension (N-1)
48 * TAU(i) must contain the scalar factor of the elementary
49 * reflector H(i), as returned by DSYTRD.
50 *
51 * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
52 * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
53 *
54 * LWORK (input) INTEGER
55 * The dimension of the array WORK. LWORK >= max(1,N-1).
56 * For optimum performance LWORK >= (N-1)*NB, where NB is
57 * the optimal blocksize.
58 *
59 * If LWORK = -1, then a workspace query is assumed; the routine
60 * only calculates the optimal size of the WORK array, returns
61 * this value as the first entry of the WORK array, and no error
62 * message related to LWORK is issued by XERBLA.
63 *
64 * INFO (output) INTEGER
65 * = 0: successful exit
66 * < 0: if INFO = -i, the i-th argument had an illegal value
67 *
68 * =====================================================================
69 *
70 * .. Parameters ..
71  DOUBLE PRECISION ZERO, ONE
72  parameter( zero = 0.0d+0, one = 1.0d+0 )
73 * ..
74 * .. Local Scalars ..
75  LOGICAL LQUERY, UPPER
76  INTEGER I, IINFO, J, LWKOPT, NB
77 * ..
78 * .. External Functions ..
79  LOGICAL LSAME
80  INTEGER ILAENV
81  EXTERNAL lsame, ilaenv
82 * ..
83 * .. External Subroutines ..
84  EXTERNAL dorgql, dorgqr, xerbla
85 * ..
86 * .. Intrinsic Functions ..
87  INTRINSIC max
88 * ..
89 * .. Executable Statements ..
90 *
91 * Test the input arguments
92 *
93  info = 0
94  lquery = ( lwork.EQ.-1 )
95  upper = lsame( uplo, 'U' )
96  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
97  info = -1
98  ELSE IF( n.LT.0 ) THEN
99  info = -2
100  ELSE IF( lda.LT.max( 1, n ) ) THEN
101  info = -4
102  ELSE IF( lwork.LT.max( 1, n-1 ) .AND. .NOT.lquery ) THEN
103  info = -7
104  END IF
105 *
106  IF( info.EQ.0 ) THEN
107  IF( upper ) THEN
108  nb = ilaenv( 1, 'DORGQL', ' ', n-1, n-1, n-1, -1 )
109  ELSE
110  nb = ilaenv( 1, 'DORGQR', ' ', n-1, n-1, n-1, -1 )
111  END IF
112  lwkopt = max( 1, n-1 )*nb
113  work( 1 ) = lwkopt
114  END IF
115 *
116  IF( info.NE.0 ) THEN
117  CALL xerbla( 'DORGTR', -info )
118  RETURN
119  ELSE IF( lquery ) THEN
120  RETURN
121  END IF
122 *
123 * Quick return if possible
124 *
125  IF( n.EQ.0 ) THEN
126  work( 1 ) = 1
127  RETURN
128  END IF
129 *
130  IF( upper ) THEN
131 *
132 * Q was determined by a call to DSYTRD with UPLO = 'U'
133 *
134 * Shift the vectors which define the elementary reflectors one
135 * column to the left, and set the last row and column of Q to
136 * those of the unit matrix
137 *
138  DO 20 j = 1, n - 1
139  DO 10 i = 1, j - 1
140  a( i, j ) = a( i, j+1 )
141  10 CONTINUE
142  a( n, j ) = zero
143  20 CONTINUE
144  DO 30 i = 1, n - 1
145  a( i, n ) = zero
146  30 CONTINUE
147  a( n, n ) = one
148 *
149 * Generate Q(1:n-1,1:n-1)
150 *
151  CALL dorgql( n-1, n-1, n-1, a, lda, tau, work, lwork, iinfo )
152 *
153  ELSE
154 *
155 * Q was determined by a call to DSYTRD with UPLO = 'L'.
156 *
157 * Shift the vectors which define the elementary reflectors one
158 * column to the right, and set the first row and column of Q to
159 * those of the unit matrix
160 *
161  DO 50 j = n, 2, -1
162  a( 1, j ) = zero
163  DO 40 i = j + 1, n
164  a( i, j ) = a( i, j-1 )
165  40 CONTINUE
166  50 CONTINUE
167  a( 1, 1 ) = one
168  DO 60 i = 2, n
169  a( i, 1 ) = zero
170  60 CONTINUE
171  IF( n.GT.1 ) THEN
172 *
173 * Generate Q(2:n,2:n)
174 *
175  CALL dorgqr( n-1, n-1, n-1, a( 2, 2 ), lda, tau, work,
176  $ lwork, iinfo )
177  END IF
178  END IF
179  work( 1 ) = lwkopt
180  RETURN
181 *
182 * End of DORGTR
183 *
184  END
subroutine dorgql(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorgql.f:2
subroutine dorgqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorgqr.f:2
subroutine dorgtr(UPLO, N, A, LDA, TAU, WORK, LWORK, INFO)
Definition: dorgtr.f:2
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2