| 1 |
SUBROUTINE DORG2R( M, N, K, A, LDA, TAU, WORK, 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 |
* February 29, 1992 |
| 7 |
* |
| 8 |
* .. Scalar Arguments .. |
| 9 |
INTEGER INFO, K, LDA, M, N |
| 10 |
* .. |
| 11 |
* .. Array Arguments .. |
| 12 |
DOUBLE PRECISION A( LDA, * ), TAU( * ), WORK( * ) |
| 13 |
* .. |
| 14 |
* |
| 15 |
* Purpose |
| 16 |
* ======= |
| 17 |
* |
| 18 |
* DORG2R generates an m by n real matrix Q with orthonormal columns, |
| 19 |
* which is defined as the first n columns of a product of k elementary |
| 20 |
* reflectors of order m |
| 21 |
* |
| 22 |
* Q = H(1) H(2) . . . H(k) |
| 23 |
* |
| 24 |
* as returned by DGEQRF. |
| 25 |
* |
| 26 |
* Arguments |
| 27 |
* ========= |
| 28 |
* |
| 29 |
* M (input) INTEGER |
| 30 |
* The number of rows of the matrix Q. M >= 0. |
| 31 |
* |
| 32 |
* N (input) INTEGER |
| 33 |
* The number of columns of the matrix Q. M >= N >= 0. |
| 34 |
* |
| 35 |
* K (input) INTEGER |
| 36 |
* The number of elementary reflectors whose product defines the |
| 37 |
* matrix Q. N >= K >= 0. |
| 38 |
* |
| 39 |
* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) |
| 40 |
* On entry, the i-th column must contain the vector which |
| 41 |
* defines the elementary reflector H(i), for i = 1,2,...,k, as |
| 42 |
* returned by DGEQRF in the first k columns of its array |
| 43 |
* argument A. |
| 44 |
* On exit, the m-by-n matrix Q. |
| 45 |
* |
| 46 |
* LDA (input) INTEGER |
| 47 |
* The first dimension of the array A. LDA >= max(1,M). |
| 48 |
* |
| 49 |
* TAU (input) DOUBLE PRECISION array, dimension (K) |
| 50 |
* TAU(i) must contain the scalar factor of the elementary |
| 51 |
* reflector H(i), as returned by DGEQRF. |
| 52 |
* |
| 53 |
* WORK (workspace) DOUBLE PRECISION array, dimension (N) |
| 54 |
* |
| 55 |
* INFO (output) INTEGER |
| 56 |
* = 0: successful exit |
| 57 |
* < 0: if INFO = -i, the i-th argument has an illegal value |
| 58 |
* |
| 59 |
* ===================================================================== |
| 60 |
* |
| 61 |
* .. Parameters .. |
| 62 |
DOUBLE PRECISION ONE, ZERO |
| 63 |
PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) |
| 64 |
* .. |
| 65 |
* .. Local Scalars .. |
| 66 |
INTEGER I, J, L |
| 67 |
* .. |
| 68 |
* .. External Subroutines .. |
| 69 |
EXTERNAL DLARF, DSCAL, XERBLA |
| 70 |
* .. |
| 71 |
* .. Intrinsic Functions .. |
| 72 |
INTRINSIC MAX |
| 73 |
* .. |
| 74 |
* .. Executable Statements .. |
| 75 |
* |
| 76 |
* Test the input arguments |
| 77 |
* |
| 78 |
INFO = 0 |
| 79 |
IF( M.LT.0 ) THEN |
| 80 |
INFO = -1 |
| 81 |
ELSE IF( N.LT.0 .OR. N.GT.M ) THEN |
| 82 |
INFO = -2 |
| 83 |
ELSE IF( K.LT.0 .OR. K.GT.N ) THEN |
| 84 |
INFO = -3 |
| 85 |
ELSE IF( LDA.LT.MAX( 1, M ) ) THEN |
| 86 |
INFO = -5 |
| 87 |
END IF |
| 88 |
IF( INFO.NE.0 ) THEN |
| 89 |
CALL XERBLA( 'DORG2R', -INFO ) |
| 90 |
RETURN |
| 91 |
END IF |
| 92 |
* |
| 93 |
* Quick return if possible |
| 94 |
* |
| 95 |
IF( N.LE.0 ) |
| 96 |
$ RETURN |
| 97 |
* |
| 98 |
* Initialise columns k+1:n to columns of the unit matrix |
| 99 |
* |
| 100 |
DO 20 J = K + 1, N |
| 101 |
DO 10 L = 1, M |
| 102 |
A( L, J ) = ZERO |
| 103 |
10 CONTINUE |
| 104 |
A( J, J ) = ONE |
| 105 |
20 CONTINUE |
| 106 |
* |
| 107 |
DO 40 I = K, 1, -1 |
| 108 |
* |
| 109 |
* Apply H(i) to A(i:m,i:n) from the left |
| 110 |
* |
| 111 |
IF( I.LT.N ) THEN |
| 112 |
A( I, I ) = ONE |
| 113 |
CALL DLARF( 'Left', M-I+1, N-I, A( I, I ), 1, TAU( I ), |
| 114 |
$ A( I, I+1 ), LDA, WORK ) |
| 115 |
END IF |
| 116 |
IF( I.LT.M ) |
| 117 |
$ CALL DSCAL( M-I, -TAU( I ), A( I+1, I ), 1 ) |
| 118 |
A( I, I ) = ONE - TAU( I ) |
| 119 |
* |
| 120 |
* Set A(1:i-1,i) to zero |
| 121 |
* |
| 122 |
DO 30 L = 1, I - 1 |
| 123 |
A( L, I ) = ZERO |
| 124 |
30 CONTINUE |
| 125 |
40 CONTINUE |
| 126 |
RETURN |
| 127 |
* |
| 128 |
* End of DORG2R |
| 129 |
* |
| 130 |
END |