3 /* Table of constant values */
5 static integer c__1 = 1;
7 /* Subroutine */ int dgebd2_(integer *m, integer *n, doublereal *a, integer *
8 lda, doublereal *d__, doublereal *e, doublereal *tauq, doublereal *
9 taup, doublereal *work, integer *info)
11 /* System generated locals */
12 integer a_dim1, a_offset, i__1, i__2, i__3;
16 extern /* Subroutine */ int dlarf_(char *, integer *, integer *,
17 doublereal *, integer *, doublereal *, doublereal *, integer *,
18 doublereal *), dlarfg_(integer *, doublereal *,
19 doublereal *, integer *, doublereal *), xerbla_(char *, integer *);
22 /* -- LAPACK routine (version 3.1) -- */
23 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
26 /* .. Scalar Arguments .. */
28 /* .. Array Arguments .. */
34 /* DGEBD2 reduces a real general m by n matrix A to upper or lower */
35 /* bidiagonal form B by an orthogonal transformation: Q' * A * P = B. */
37 /* If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. */
42 /* M (input) INTEGER */
43 /* The number of rows in the matrix A. M >= 0. */
45 /* N (input) INTEGER */
46 /* The number of columns in the matrix A. N >= 0. */
48 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
49 /* On entry, the m by n general matrix to be reduced. */
51 /* if m >= n, the diagonal and the first superdiagonal are */
52 /* overwritten with the upper bidiagonal matrix B; the */
53 /* elements below the diagonal, with the array TAUQ, represent */
54 /* the orthogonal matrix Q as a product of elementary */
55 /* reflectors, and the elements above the first superdiagonal, */
56 /* with the array TAUP, represent the orthogonal matrix P as */
57 /* a product of elementary reflectors; */
58 /* if m < n, the diagonal and the first subdiagonal are */
59 /* overwritten with the lower bidiagonal matrix B; the */
60 /* elements below the first subdiagonal, with the array TAUQ, */
61 /* represent the orthogonal matrix Q as a product of */
62 /* elementary reflectors, and the elements above the diagonal, */
63 /* with the array TAUP, represent the orthogonal matrix P as */
64 /* a product of elementary reflectors. */
65 /* See Further Details. */
67 /* LDA (input) INTEGER */
68 /* The leading dimension of the array A. LDA >= max(1,M). */
70 /* D (output) DOUBLE PRECISION array, dimension (min(M,N)) */
71 /* The diagonal elements of the bidiagonal matrix B: */
74 /* E (output) DOUBLE PRECISION array, dimension (min(M,N)-1) */
75 /* The off-diagonal elements of the bidiagonal matrix B: */
76 /* if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1; */
77 /* if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1. */
79 /* TAUQ (output) DOUBLE PRECISION array dimension (min(M,N)) */
80 /* The scalar factors of the elementary reflectors which */
81 /* represent the orthogonal matrix Q. See Further Details. */
83 /* TAUP (output) DOUBLE PRECISION array, dimension (min(M,N)) */
84 /* The scalar factors of the elementary reflectors which */
85 /* represent the orthogonal matrix P. See Further Details. */
87 /* WORK (workspace) DOUBLE PRECISION array, dimension (max(M,N)) */
89 /* INFO (output) INTEGER */
90 /* = 0: successful exit. */
91 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
96 /* The matrices Q and P are represented as products of elementary */
101 /* Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1) */
103 /* Each H(i) and G(i) has the form: */
105 /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */
107 /* where tauq and taup are real scalars, and v and u are real vectors; */
108 /* v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i); */
109 /* u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n); */
110 /* tauq is stored in TAUQ(i) and taup in TAUP(i). */
114 /* Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m) */
116 /* Each H(i) and G(i) has the form: */
118 /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */
120 /* where tauq and taup are real scalars, and v and u are real vectors; */
121 /* v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i); */
122 /* u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n); */
123 /* tauq is stored in TAUQ(i) and taup in TAUP(i). */
125 /* The contents of A on exit are illustrated by the following examples: */
127 /* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */
129 /* ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 ) */
130 /* ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 ) */
131 /* ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 ) */
132 /* ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 ) */
133 /* ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 ) */
134 /* ( v1 v2 v3 v4 v5 ) */
136 /* where d and e denote diagonal and off-diagonal elements of B, vi */
137 /* denotes an element of the vector defining H(i), and ui an element of */
138 /* the vector defining G(i). */
140 /* ===================================================================== */
142 /* .. Parameters .. */
144 /* .. Local Scalars .. */
146 /* .. External Subroutines .. */
148 /* .. Intrinsic Functions .. */
150 /* .. Executable Statements .. */
152 /* Test the input parameters */
154 /* Parameter adjustments */
156 a_offset = 1 + a_dim1;
170 } else if (*lda < max(1,*m)) {
175 xerbla_("DGEBD2", &i__1);
181 /* Reduce to upper bidiagonal form */
184 for (i__ = 1; i__ <= i__1; ++i__) {
186 /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */
191 dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ *
192 a_dim1], &c__1, &tauq[i__]);
193 d__[i__] = a[i__ + i__ * a_dim1];
194 a[i__ + i__ * a_dim1] = 1.;
196 /* Apply H(i) to A(i:m,i+1:n) from the left */
201 dlarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &
202 tauq[i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]
205 a[i__ + i__ * a_dim1] = d__[i__];
209 /* Generate elementary reflector G(i) to annihilate */
215 dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + min(
216 i__3, *n)* a_dim1], lda, &taup[i__]);
217 e[i__] = a[i__ + (i__ + 1) * a_dim1];
218 a[i__ + (i__ + 1) * a_dim1] = 1.;
220 /* Apply G(i) to A(i+1:m,i+1:n) from the right */
224 dlarf_("Right", &i__2, &i__3, &a[i__ + (i__ + 1) * a_dim1],
225 lda, &taup[i__], &a[i__ + 1 + (i__ + 1) * a_dim1],
227 a[i__ + (i__ + 1) * a_dim1] = e[i__];
235 /* Reduce to lower bidiagonal form */
238 for (i__ = 1; i__ <= i__1; ++i__) {
240 /* Generate elementary reflector G(i) to annihilate A(i,i+1:n) */
245 dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)*
246 a_dim1], lda, &taup[i__]);
247 d__[i__] = a[i__ + i__ * a_dim1];
248 a[i__ + i__ * a_dim1] = 1.;
250 /* Apply G(i) to A(i+1:m,i:n) from the right */
255 dlarf_("Right", &i__2, &i__3, &a[i__ + i__ * a_dim1], lda, &
256 taup[i__], &a[i__ + 1 + i__ * a_dim1], lda, &work[1]);
258 a[i__ + i__ * a_dim1] = d__[i__];
262 /* Generate elementary reflector H(i) to annihilate */
268 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *m)+
269 i__ * a_dim1], &c__1, &tauq[i__]);
270 e[i__] = a[i__ + 1 + i__ * a_dim1];
271 a[i__ + 1 + i__ * a_dim1] = 1.;
273 /* Apply H(i) to A(i+1:m,i+1:n) from the left */
277 dlarf_("Left", &i__2, &i__3, &a[i__ + 1 + i__ * a_dim1], &
278 c__1, &tauq[i__], &a[i__ + 1 + (i__ + 1) * a_dim1],
280 a[i__ + 1 + i__ * a_dim1] = e[i__];