3 /* Table of constant values */
5 static doublereal c_b4 = -1.;
6 static doublereal c_b5 = 1.;
7 static integer c__1 = 1;
8 static doublereal c_b16 = 0.;
10 /* Subroutine */ int dlabrd_(integer *m, integer *n, integer *nb, doublereal *
11 a, integer *lda, doublereal *d__, doublereal *e, doublereal *tauq,
12 doublereal *taup, doublereal *x, integer *ldx, doublereal *y, integer
15 /* System generated locals */
16 integer a_dim1, a_offset, x_dim1, x_offset, y_dim1, y_offset, i__1, i__2,
21 extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *,
22 integer *), dgemv_(char *, integer *, integer *, doublereal *,
23 doublereal *, integer *, doublereal *, integer *, doublereal *,
24 doublereal *, integer *), dlarfg_(integer *, doublereal *,
25 doublereal *, integer *, doublereal *);
28 /* -- LAPACK auxiliary routine (version 3.1) -- */
29 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
32 /* .. Scalar Arguments .. */
34 /* .. Array Arguments .. */
40 /* DLABRD reduces the first NB rows and columns of a real general */
41 /* m by n matrix A to upper or lower bidiagonal form by an orthogonal */
42 /* transformation Q' * A * P, and returns the matrices X and Y which */
43 /* are needed to apply the transformation to the unreduced part of A. */
45 /* If m >= n, A is reduced to upper bidiagonal form; if m < n, to lower */
46 /* bidiagonal form. */
48 /* This is an auxiliary routine called by DGEBRD */
53 /* M (input) INTEGER */
54 /* The number of rows in the matrix A. */
56 /* N (input) INTEGER */
57 /* The number of columns in the matrix A. */
59 /* NB (input) INTEGER */
60 /* The number of leading rows and columns of A to be reduced. */
62 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
63 /* On entry, the m by n general matrix to be reduced. */
64 /* On exit, the first NB rows and columns of the matrix are */
65 /* overwritten; the rest of the array is unchanged. */
66 /* If m >= n, elements on and below the diagonal in the first NB */
67 /* columns, with the array TAUQ, represent the orthogonal */
68 /* matrix Q as a product of elementary reflectors; and */
69 /* elements above the diagonal in the first NB rows, with the */
70 /* array TAUP, represent the orthogonal matrix P as a product */
71 /* of elementary reflectors. */
72 /* If m < n, elements below the diagonal in the first NB */
73 /* columns, with the array TAUQ, represent the orthogonal */
74 /* matrix Q as a product of elementary reflectors, and */
75 /* elements on and above the diagonal in the first NB rows, */
76 /* with the array TAUP, represent the orthogonal matrix P as */
77 /* a product of elementary reflectors. */
78 /* See Further Details. */
80 /* LDA (input) INTEGER */
81 /* The leading dimension of the array A. LDA >= max(1,M). */
83 /* D (output) DOUBLE PRECISION array, dimension (NB) */
84 /* The diagonal elements of the first NB rows and columns of */
85 /* the reduced matrix. D(i) = A(i,i). */
87 /* E (output) DOUBLE PRECISION array, dimension (NB) */
88 /* The off-diagonal elements of the first NB rows and columns of */
89 /* the reduced matrix. */
91 /* TAUQ (output) DOUBLE PRECISION array dimension (NB) */
92 /* The scalar factors of the elementary reflectors which */
93 /* represent the orthogonal matrix Q. See Further Details. */
95 /* TAUP (output) DOUBLE PRECISION array, dimension (NB) */
96 /* The scalar factors of the elementary reflectors which */
97 /* represent the orthogonal matrix P. See Further Details. */
99 /* X (output) DOUBLE PRECISION array, dimension (LDX,NB) */
100 /* The m-by-nb matrix X required to update the unreduced part */
103 /* LDX (input) INTEGER */
104 /* The leading dimension of the array X. LDX >= M. */
106 /* Y (output) DOUBLE PRECISION array, dimension (LDY,NB) */
107 /* The n-by-nb matrix Y required to update the unreduced part */
110 /* LDY (input) INTEGER */
111 /* The leading dimension of the array Y. LDY >= N. */
113 /* Further Details */
114 /* =============== */
116 /* The matrices Q and P are represented as products of elementary */
119 /* Q = H(1) H(2) . . . H(nb) and P = G(1) G(2) . . . G(nb) */
121 /* Each H(i) and G(i) has the form: */
123 /* H(i) = I - tauq * v * v' and G(i) = I - taup * u * u' */
125 /* where tauq and taup are real scalars, and v and u are real vectors. */
127 /* If m >= n, v(1:i-1) = 0, v(i) = 1, and v(i:m) is stored on exit in */
128 /* A(i:m,i); u(1:i) = 0, u(i+1) = 1, and u(i+1:n) is stored on exit in */
129 /* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
131 /* If m < n, v(1:i) = 0, v(i+1) = 1, and v(i+1:m) is stored on exit in */
132 /* A(i+2:m,i); u(1:i-1) = 0, u(i) = 1, and u(i:n) is stored on exit in */
133 /* A(i,i+1:n); tauq is stored in TAUQ(i) and taup in TAUP(i). */
135 /* The elements of the vectors v and u together form the m-by-nb matrix */
136 /* V and the nb-by-n matrix U' which are needed, with X and Y, to apply */
137 /* the transformation to the unreduced part of the matrix, using a block */
138 /* update of the form: A := A - V*Y' - X*U'. */
140 /* The contents of A on exit are illustrated by the following examples */
143 /* m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n): */
145 /* ( 1 1 u1 u1 u1 ) ( 1 u1 u1 u1 u1 u1 ) */
146 /* ( v1 1 1 u2 u2 ) ( 1 1 u2 u2 u2 u2 ) */
147 /* ( v1 v2 a a a ) ( v1 1 a a a a ) */
148 /* ( v1 v2 a a a ) ( v1 v2 a a a a ) */
149 /* ( v1 v2 a a a ) ( v1 v2 a a a a ) */
150 /* ( v1 v2 a a a ) */
152 /* where a denotes an element of the original matrix which is unchanged, */
153 /* vi denotes an element of the vector defining H(i), and ui an element */
154 /* of the vector defining G(i). */
156 /* ===================================================================== */
158 /* .. Parameters .. */
160 /* .. Local Scalars .. */
162 /* .. External Subroutines .. */
164 /* .. Intrinsic Functions .. */
166 /* .. Executable Statements .. */
168 /* Quick return if possible */
170 /* Parameter adjustments */
172 a_offset = 1 + a_dim1;
179 x_offset = 1 + x_dim1;
182 y_offset = 1 + y_dim1;
186 if (*m <= 0 || *n <= 0) {
192 /* Reduce to upper bidiagonal form */
195 for (i__ = 1; i__ <= i__1; ++i__) {
197 /* Update A(i:m,i) */
201 dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + a_dim1], lda,
202 &y[i__ + y_dim1], ldy, &c_b5, &a[i__ + i__ * a_dim1], &
206 dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + x_dim1], ldx,
207 &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[i__ + i__ *
210 /* Generate reflection Q(i) to annihilate A(i+1:m,i) */
215 dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ *
216 a_dim1], &c__1, &tauq[i__]);
217 d__[i__] = a[i__ + i__ * a_dim1];
219 a[i__ + i__ * a_dim1] = 1.;
221 /* Compute Y(i+1:n,i) */
225 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + (i__ + 1) *
226 a_dim1], lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &
227 y[i__ + 1 + i__ * y_dim1], &c__1);
230 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + a_dim1],
231 lda, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ *
235 dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 +
236 y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
237 i__ + 1 + i__ * y_dim1], &c__1);
240 dgemv_("Transpose", &i__2, &i__3, &c_b5, &x[i__ + x_dim1],
241 ldx, &a[i__ + i__ * a_dim1], &c__1, &c_b16, &y[i__ *
245 dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) *
246 a_dim1 + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5,
247 &y[i__ + 1 + i__ * y_dim1], &c__1);
249 dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);
251 /* Update A(i,i+1:n) */
254 dgemv_("No transpose", &i__2, &i__, &c_b4, &y[i__ + 1 +
255 y_dim1], ldy, &a[i__ + a_dim1], lda, &c_b5, &a[i__ + (
256 i__ + 1) * a_dim1], lda);
259 dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[(i__ + 1) *
260 a_dim1 + 1], lda, &x[i__ + x_dim1], ldx, &c_b5, &a[
261 i__ + (i__ + 1) * a_dim1], lda);
263 /* Generate reflection P(i) to annihilate A(i,i+2:n) */
268 dlarfg_(&i__2, &a[i__ + (i__ + 1) * a_dim1], &a[i__ + min(
269 i__3, *n)* a_dim1], lda, &taup[i__]);
270 e[i__] = a[i__ + (i__ + 1) * a_dim1];
271 a[i__ + (i__ + 1) * a_dim1] = 1.;
273 /* Compute X(i+1:m,i) */
277 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__
278 + 1) * a_dim1], lda, &a[i__ + (i__ + 1) * a_dim1],
279 lda, &c_b16, &x[i__ + 1 + i__ * x_dim1], &c__1);
281 dgemv_("Transpose", &i__2, &i__, &c_b5, &y[i__ + 1 + y_dim1],
282 ldy, &a[i__ + (i__ + 1) * a_dim1], lda, &c_b16, &x[
283 i__ * x_dim1 + 1], &c__1);
285 dgemv_("No transpose", &i__2, &i__, &c_b4, &a[i__ + 1 +
286 a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
287 i__ + 1 + i__ * x_dim1], &c__1);
290 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[(i__ + 1) *
291 a_dim1 + 1], lda, &a[i__ + (i__ + 1) * a_dim1], lda, &
292 c_b16, &x[i__ * x_dim1 + 1], &c__1);
295 dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 +
296 x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
297 i__ + 1 + i__ * x_dim1], &c__1);
299 dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
305 /* Reduce to lower bidiagonal form */
308 for (i__ = 1; i__ <= i__1; ++i__) {
310 /* Update A(i,i:n) */
314 dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + y_dim1], ldy,
315 &a[i__ + a_dim1], lda, &c_b5, &a[i__ + i__ * a_dim1],
319 dgemv_("Transpose", &i__2, &i__3, &c_b4, &a[i__ * a_dim1 + 1],
320 lda, &x[i__ + x_dim1], ldx, &c_b5, &a[i__ + i__ * a_dim1],
323 /* Generate reflection P(i) to annihilate A(i,i+1:n) */
328 dlarfg_(&i__2, &a[i__ + i__ * a_dim1], &a[i__ + min(i__3, *n)*
329 a_dim1], lda, &taup[i__]);
330 d__[i__] = a[i__ + i__ * a_dim1];
332 a[i__ + i__ * a_dim1] = 1.;
334 /* Compute X(i+1:m,i) */
338 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + i__ *
339 a_dim1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &
340 x[i__ + 1 + i__ * x_dim1], &c__1);
343 dgemv_("Transpose", &i__2, &i__3, &c_b5, &y[i__ + y_dim1],
344 ldy, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ *
348 dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 +
349 a_dim1], lda, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
350 i__ + 1 + i__ * x_dim1], &c__1);
353 dgemv_("No transpose", &i__2, &i__3, &c_b5, &a[i__ * a_dim1 +
354 1], lda, &a[i__ + i__ * a_dim1], lda, &c_b16, &x[i__ *
358 dgemv_("No transpose", &i__2, &i__3, &c_b4, &x[i__ + 1 +
359 x_dim1], ldx, &x[i__ * x_dim1 + 1], &c__1, &c_b5, &x[
360 i__ + 1 + i__ * x_dim1], &c__1);
362 dscal_(&i__2, &taup[i__], &x[i__ + 1 + i__ * x_dim1], &c__1);
364 /* Update A(i+1:m,i) */
368 dgemv_("No transpose", &i__2, &i__3, &c_b4, &a[i__ + 1 +
369 a_dim1], lda, &y[i__ + y_dim1], ldy, &c_b5, &a[i__ +
370 1 + i__ * a_dim1], &c__1);
372 dgemv_("No transpose", &i__2, &i__, &c_b4, &x[i__ + 1 +
373 x_dim1], ldx, &a[i__ * a_dim1 + 1], &c__1, &c_b5, &a[
374 i__ + 1 + i__ * a_dim1], &c__1);
376 /* Generate reflection Q(i) to annihilate A(i+2:m,i) */
381 dlarfg_(&i__2, &a[i__ + 1 + i__ * a_dim1], &a[min(i__3, *m)+
382 i__ * a_dim1], &c__1, &tauq[i__]);
383 e[i__] = a[i__ + 1 + i__ * a_dim1];
384 a[i__ + 1 + i__ * a_dim1] = 1.;
386 /* Compute Y(i+1:n,i) */
390 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + (i__ +
391 1) * a_dim1], lda, &a[i__ + 1 + i__ * a_dim1], &c__1,
392 &c_b16, &y[i__ + 1 + i__ * y_dim1], &c__1);
395 dgemv_("Transpose", &i__2, &i__3, &c_b5, &a[i__ + 1 + a_dim1],
396 lda, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
397 i__ * y_dim1 + 1], &c__1);
400 dgemv_("No transpose", &i__2, &i__3, &c_b4, &y[i__ + 1 +
401 y_dim1], ldy, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[
402 i__ + 1 + i__ * y_dim1], &c__1);
404 dgemv_("Transpose", &i__2, &i__, &c_b5, &x[i__ + 1 + x_dim1],
405 ldx, &a[i__ + 1 + i__ * a_dim1], &c__1, &c_b16, &y[
406 i__ * y_dim1 + 1], &c__1);
408 dgemv_("Transpose", &i__, &i__2, &c_b4, &a[(i__ + 1) * a_dim1
409 + 1], lda, &y[i__ * y_dim1 + 1], &c__1, &c_b5, &y[i__
410 + 1 + i__ * y_dim1], &c__1);
412 dscal_(&i__2, &tauq[i__], &y[i__ + 1 + i__ * y_dim1], &c__1);