~ubuntu-branches/debian/sid/octave3.0/sid

« back to all changes in this revision

Viewing changes to libcruft/lapack/dorg2r.f

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2007-12-23 16:04:15 UTC
  • Revision ID: james.westby@ubuntu.com-20071223160415-n4gk468dihy22e9v
Tags: upstream-3.0.0
ImportĀ upstreamĀ versionĀ 3.0.0

Show diffs side-by-side

added added

removed removed

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