stgsja.c
Go to the documentation of this file.
00001 /* stgsja.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Table of constant values */
00017 
00018 static real c_b13 = 0.f;
00019 static real c_b14 = 1.f;
00020 static integer c__1 = 1;
00021 static real c_b43 = -1.f;
00022 
00023 /* Subroutine */ int stgsja_(char *jobu, char *jobv, char *jobq, integer *m, 
00024         integer *p, integer *n, integer *k, integer *l, real *a, integer *lda, 
00025          real *b, integer *ldb, real *tola, real *tolb, real *alpha, real *
00026         beta, real *u, integer *ldu, real *v, integer *ldv, real *q, integer *
00027         ldq, real *work, integer *ncycle, integer *info)
00028 {
00029     /* System generated locals */
00030     integer a_dim1, a_offset, b_dim1, b_offset, q_dim1, q_offset, u_dim1, 
00031             u_offset, v_dim1, v_offset, i__1, i__2, i__3, i__4;
00032     real r__1;
00033 
00034     /* Local variables */
00035     integer i__, j;
00036     real a1, a2, a3, b1, b2, b3, csq, csu, csv, snq, rwk, snu, snv;
00037     extern /* Subroutine */ int srot_(integer *, real *, integer *, real *, 
00038             integer *, real *, real *);
00039     real gamma;
00040     extern logical lsame_(char *, char *);
00041     extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *);
00042     logical initq, initu, initv, wantq, upper;
00043     real error, ssmin;
00044     logical wantu, wantv;
00045     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00046             integer *), slags2_(logical *, real *, real *, real *, real *, 
00047             real *, real *, real *, real *, real *, real *, real *, real *);
00048     integer kcycle;
00049     extern /* Subroutine */ int xerbla_(char *, integer *), slapll_(
00050             integer *, real *, integer *, real *, integer *, real *), slartg_(
00051             real *, real *, real *, real *, real *), slaset_(char *, integer *
00052 , integer *, real *, real *, real *, integer *);
00053 
00054 
00055 /*  -- LAPACK routine (version 3.2) -- */
00056 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00057 /*     November 2006 */
00058 
00059 /*     .. Scalar Arguments .. */
00060 /*     .. */
00061 /*     .. Array Arguments .. */
00062 /*     .. */
00063 
00064 /*  Purpose */
00065 /*  ======= */
00066 
00067 /*  STGSJA computes the generalized singular value decomposition (GSVD) */
00068 /*  of two real upper triangular (or trapezoidal) matrices A and B. */
00069 
00070 /*  On entry, it is assumed that matrices A and B have the following */
00071 /*  forms, which may be obtained by the preprocessing subroutine SGGSVP */
00072 /*  from a general M-by-N matrix A and P-by-N matrix B: */
00073 
00074 /*               N-K-L  K    L */
00075 /*     A =    K ( 0    A12  A13 ) if M-K-L >= 0; */
00076 /*            L ( 0     0   A23 ) */
00077 /*        M-K-L ( 0     0    0  ) */
00078 
00079 /*             N-K-L  K    L */
00080 /*     A =  K ( 0    A12  A13 ) if M-K-L < 0; */
00081 /*        M-K ( 0     0   A23 ) */
00082 
00083 /*             N-K-L  K    L */
00084 /*     B =  L ( 0     0   B13 ) */
00085 /*        P-L ( 0     0    0  ) */
00086 
00087 /*  where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular */
00088 /*  upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0, */
00089 /*  otherwise A23 is (M-K)-by-L upper trapezoidal. */
00090 
00091 /*  On exit, */
00092 
00093 /*              U'*A*Q = D1*( 0 R ),    V'*B*Q = D2*( 0 R ), */
00094 
00095 /*  where U, V and Q are orthogonal matrices, Z' denotes the transpose */
00096 /*  of Z, R is a nonsingular upper triangular matrix, and D1 and D2 are */
00097 /*  ``diagonal'' matrices, which are of the following structures: */
00098 
00099 /*  If M-K-L >= 0, */
00100 
00101 /*                      K  L */
00102 /*         D1 =     K ( I  0 ) */
00103 /*                  L ( 0  C ) */
00104 /*              M-K-L ( 0  0 ) */
00105 
00106 /*                    K  L */
00107 /*         D2 = L   ( 0  S ) */
00108 /*              P-L ( 0  0 ) */
00109 
00110 /*                 N-K-L  K    L */
00111 /*    ( 0 R ) = K (  0   R11  R12 ) K */
00112 /*              L (  0    0   R22 ) L */
00113 
00114 /*  where */
00115 
00116 /*    C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */
00117 /*    S = diag( BETA(K+1),  ... , BETA(K+L) ), */
00118 /*    C**2 + S**2 = I. */
00119 
00120 /*    R is stored in A(1:K+L,N-K-L+1:N) on exit. */
00121 
00122 /*  If M-K-L < 0, */
00123 
00124 /*                 K M-K K+L-M */
00125 /*      D1 =   K ( I  0    0   ) */
00126 /*           M-K ( 0  C    0   ) */
00127 
00128 /*                   K M-K K+L-M */
00129 /*      D2 =   M-K ( 0  S    0   ) */
00130 /*           K+L-M ( 0  0    I   ) */
00131 /*             P-L ( 0  0    0   ) */
00132 
00133 /*                 N-K-L  K   M-K  K+L-M */
00134 /* ( 0 R ) =    K ( 0    R11  R12  R13  ) */
00135 /*            M-K ( 0     0   R22  R23  ) */
00136 /*          K+L-M ( 0     0    0   R33  ) */
00137 
00138 /*  where */
00139 /*  C = diag( ALPHA(K+1), ... , ALPHA(M) ), */
00140 /*  S = diag( BETA(K+1),  ... , BETA(M) ), */
00141 /*  C**2 + S**2 = I. */
00142 
00143 /*  R = ( R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N) and R33 is stored */
00144 /*      (  0  R22 R23 ) */
00145 /*  in B(M-K+1:L,N+M-K-L+1:N) on exit. */
00146 
00147 /*  The computation of the orthogonal transformation matrices U, V or Q */
00148 /*  is optional.  These matrices may either be formed explicitly, or they */
00149 /*  may be postmultiplied into input matrices U1, V1, or Q1. */
00150 
00151 /*  Arguments */
00152 /*  ========= */
00153 
00154 /*  JOBU    (input) CHARACTER*1 */
00155 /*          = 'U':  U must contain an orthogonal matrix U1 on entry, and */
00156 /*                  the product U1*U is returned; */
00157 /*          = 'I':  U is initialized to the unit matrix, and the */
00158 /*                  orthogonal matrix U is returned; */
00159 /*          = 'N':  U is not computed. */
00160 
00161 /*  JOBV    (input) CHARACTER*1 */
00162 /*          = 'V':  V must contain an orthogonal matrix V1 on entry, and */
00163 /*                  the product V1*V is returned; */
00164 /*          = 'I':  V is initialized to the unit matrix, and the */
00165 /*                  orthogonal matrix V is returned; */
00166 /*          = 'N':  V is not computed. */
00167 
00168 /*  JOBQ    (input) CHARACTER*1 */
00169 /*          = 'Q':  Q must contain an orthogonal matrix Q1 on entry, and */
00170 /*                  the product Q1*Q is returned; */
00171 /*          = 'I':  Q is initialized to the unit matrix, and the */
00172 /*                  orthogonal matrix Q is returned; */
00173 /*          = 'N':  Q is not computed. */
00174 
00175 /*  M       (input) INTEGER */
00176 /*          The number of rows of the matrix A.  M >= 0. */
00177 
00178 /*  P       (input) INTEGER */
00179 /*          The number of rows of the matrix B.  P >= 0. */
00180 
00181 /*  N       (input) INTEGER */
00182 /*          The number of columns of the matrices A and B.  N >= 0. */
00183 
00184 /*  K       (input) INTEGER */
00185 /*  L       (input) INTEGER */
00186 /*          K and L specify the subblocks in the input matrices A and B: */
00187 /*          A23 = A(K+1:MIN(K+L,M),N-L+1:N) and B13 = B(1:L,N-L+1:N) */
00188 /*          of A and B, whose GSVD is going to be computed by STGSJA. */
00189 /*          See Further details. */
00190 
00191 /*  A       (input/output) REAL array, dimension (LDA,N) */
00192 /*          On entry, the M-by-N matrix A. */
00193 /*          On exit, A(N-K+1:N,1:MIN(K+L,M) ) contains the triangular */
00194 /*          matrix R or part of R.  See Purpose for details. */
00195 
00196 /*  LDA     (input) INTEGER */
00197 /*          The leading dimension of the array A. LDA >= max(1,M). */
00198 
00199 /*  B       (input/output) REAL array, dimension (LDB,N) */
00200 /*          On entry, the P-by-N matrix B. */
00201 /*          On exit, if necessary, B(M-K+1:L,N+M-K-L+1:N) contains */
00202 /*          a part of R.  See Purpose for details. */
00203 
00204 /*  LDB     (input) INTEGER */
00205 /*          The leading dimension of the array B. LDB >= max(1,P). */
00206 
00207 /*  TOLA    (input) REAL */
00208 /*  TOLB    (input) REAL */
00209 /*          TOLA and TOLB are the convergence criteria for the Jacobi- */
00210 /*          Kogbetliantz iteration procedure. Generally, they are the */
00211 /*          same as used in the preprocessing step, say */
00212 /*              TOLA = max(M,N)*norm(A)*MACHEPS, */
00213 /*              TOLB = max(P,N)*norm(B)*MACHEPS. */
00214 
00215 /*  ALPHA   (output) REAL array, dimension (N) */
00216 /*  BETA    (output) REAL array, dimension (N) */
00217 /*          On exit, ALPHA and BETA contain the generalized singular */
00218 /*          value pairs of A and B; */
00219 /*            ALPHA(1:K) = 1, */
00220 /*            BETA(1:K)  = 0, */
00221 /*          and if M-K-L >= 0, */
00222 /*            ALPHA(K+1:K+L) = diag(C), */
00223 /*            BETA(K+1:K+L)  = diag(S), */
00224 /*          or if M-K-L < 0, */
00225 /*            ALPHA(K+1:M)= C, ALPHA(M+1:K+L)= 0 */
00226 /*            BETA(K+1:M) = S, BETA(M+1:K+L) = 1. */
00227 /*          Furthermore, if K+L < N, */
00228 /*            ALPHA(K+L+1:N) = 0 and */
00229 /*            BETA(K+L+1:N)  = 0. */
00230 
00231 /*  U       (input/output) REAL array, dimension (LDU,M) */
00232 /*          On entry, if JOBU = 'U', U must contain a matrix U1 (usually */
00233 /*          the orthogonal matrix returned by SGGSVP). */
00234 /*          On exit, */
00235 /*          if JOBU = 'I', U contains the orthogonal matrix U; */
00236 /*          if JOBU = 'U', U contains the product U1*U. */
00237 /*          If JOBU = 'N', U is not referenced. */
00238 
00239 /*  LDU     (input) INTEGER */
00240 /*          The leading dimension of the array U. LDU >= max(1,M) if */
00241 /*          JOBU = 'U'; LDU >= 1 otherwise. */
00242 
00243 /*  V       (input/output) REAL array, dimension (LDV,P) */
00244 /*          On entry, if JOBV = 'V', V must contain a matrix V1 (usually */
00245 /*          the orthogonal matrix returned by SGGSVP). */
00246 /*          On exit, */
00247 /*          if JOBV = 'I', V contains the orthogonal matrix V; */
00248 /*          if JOBV = 'V', V contains the product V1*V. */
00249 /*          If JOBV = 'N', V is not referenced. */
00250 
00251 /*  LDV     (input) INTEGER */
00252 /*          The leading dimension of the array V. LDV >= max(1,P) if */
00253 /*          JOBV = 'V'; LDV >= 1 otherwise. */
00254 
00255 /*  Q       (input/output) REAL array, dimension (LDQ,N) */
00256 /*          On entry, if JOBQ = 'Q', Q must contain a matrix Q1 (usually */
00257 /*          the orthogonal matrix returned by SGGSVP). */
00258 /*          On exit, */
00259 /*          if JOBQ = 'I', Q contains the orthogonal matrix Q; */
00260 /*          if JOBQ = 'Q', Q contains the product Q1*Q. */
00261 /*          If JOBQ = 'N', Q is not referenced. */
00262 
00263 /*  LDQ     (input) INTEGER */
00264 /*          The leading dimension of the array Q. LDQ >= max(1,N) if */
00265 /*          JOBQ = 'Q'; LDQ >= 1 otherwise. */
00266 
00267 /*  WORK    (workspace) REAL array, dimension (2*N) */
00268 
00269 /*  NCYCLE  (output) INTEGER */
00270 /*          The number of cycles required for convergence. */
00271 
00272 /*  INFO    (output) INTEGER */
00273 /*          = 0:  successful exit */
00274 /*          < 0:  if INFO = -i, the i-th argument had an illegal value. */
00275 /*          = 1:  the procedure does not converge after MAXIT cycles. */
00276 
00277 /*  Internal Parameters */
00278 /*  =================== */
00279 
00280 /*  MAXIT   INTEGER */
00281 /*          MAXIT specifies the total loops that the iterative procedure */
00282 /*          may take. If after MAXIT cycles, the routine fails to */
00283 /*          converge, we return INFO = 1. */
00284 
00285 /*  Further Details */
00286 /*  =============== */
00287 
00288 /*  STGSJA essentially uses a variant of Kogbetliantz algorithm to reduce */
00289 /*  min(L,M-K)-by-L triangular (or trapezoidal) matrix A23 and L-by-L */
00290 /*  matrix B13 to the form: */
00291 
00292 /*           U1'*A13*Q1 = C1*R1; V1'*B13*Q1 = S1*R1, */
00293 
00294 /*  where U1, V1 and Q1 are orthogonal matrix, and Z' is the transpose */
00295 /*  of Z.  C1 and S1 are diagonal matrices satisfying */
00296 
00297 /*                C1**2 + S1**2 = I, */
00298 
00299 /*  and R1 is an L-by-L nonsingular upper triangular matrix. */
00300 
00301 /*  ===================================================================== */
00302 
00303 /*     .. Parameters .. */
00304 /*     .. */
00305 /*     .. Local Scalars .. */
00306 
00307 /*     .. */
00308 /*     .. External Functions .. */
00309 /*     .. */
00310 /*     .. External Subroutines .. */
00311 /*     .. */
00312 /*     .. Intrinsic Functions .. */
00313 /*     .. */
00314 /*     .. Executable Statements .. */
00315 
00316 /*     Decode and test the input parameters */
00317 
00318     /* Parameter adjustments */
00319     a_dim1 = *lda;
00320     a_offset = 1 + a_dim1;
00321     a -= a_offset;
00322     b_dim1 = *ldb;
00323     b_offset = 1 + b_dim1;
00324     b -= b_offset;
00325     --alpha;
00326     --beta;
00327     u_dim1 = *ldu;
00328     u_offset = 1 + u_dim1;
00329     u -= u_offset;
00330     v_dim1 = *ldv;
00331     v_offset = 1 + v_dim1;
00332     v -= v_offset;
00333     q_dim1 = *ldq;
00334     q_offset = 1 + q_dim1;
00335     q -= q_offset;
00336     --work;
00337 
00338     /* Function Body */
00339     initu = lsame_(jobu, "I");
00340     wantu = initu || lsame_(jobu, "U");
00341 
00342     initv = lsame_(jobv, "I");
00343     wantv = initv || lsame_(jobv, "V");
00344 
00345     initq = lsame_(jobq, "I");
00346     wantq = initq || lsame_(jobq, "Q");
00347 
00348     *info = 0;
00349     if (! (initu || wantu || lsame_(jobu, "N"))) {
00350         *info = -1;
00351     } else if (! (initv || wantv || lsame_(jobv, "N"))) 
00352             {
00353         *info = -2;
00354     } else if (! (initq || wantq || lsame_(jobq, "N"))) 
00355             {
00356         *info = -3;
00357     } else if (*m < 0) {
00358         *info = -4;
00359     } else if (*p < 0) {
00360         *info = -5;
00361     } else if (*n < 0) {
00362         *info = -6;
00363     } else if (*lda < max(1,*m)) {
00364         *info = -10;
00365     } else if (*ldb < max(1,*p)) {
00366         *info = -12;
00367     } else if (*ldu < 1 || wantu && *ldu < *m) {
00368         *info = -18;
00369     } else if (*ldv < 1 || wantv && *ldv < *p) {
00370         *info = -20;
00371     } else if (*ldq < 1 || wantq && *ldq < *n) {
00372         *info = -22;
00373     }
00374     if (*info != 0) {
00375         i__1 = -(*info);
00376         xerbla_("STGSJA", &i__1);
00377         return 0;
00378     }
00379 
00380 /*     Initialize U, V and Q, if necessary */
00381 
00382     if (initu) {
00383         slaset_("Full", m, m, &c_b13, &c_b14, &u[u_offset], ldu);
00384     }
00385     if (initv) {
00386         slaset_("Full", p, p, &c_b13, &c_b14, &v[v_offset], ldv);
00387     }
00388     if (initq) {
00389         slaset_("Full", n, n, &c_b13, &c_b14, &q[q_offset], ldq);
00390     }
00391 
00392 /*     Loop until convergence */
00393 
00394     upper = FALSE_;
00395     for (kcycle = 1; kcycle <= 40; ++kcycle) {
00396 
00397         upper = ! upper;
00398 
00399         i__1 = *l - 1;
00400         for (i__ = 1; i__ <= i__1; ++i__) {
00401             i__2 = *l;
00402             for (j = i__ + 1; j <= i__2; ++j) {
00403 
00404                 a1 = 0.f;
00405                 a2 = 0.f;
00406                 a3 = 0.f;
00407                 if (*k + i__ <= *m) {
00408                     a1 = a[*k + i__ + (*n - *l + i__) * a_dim1];
00409                 }
00410                 if (*k + j <= *m) {
00411                     a3 = a[*k + j + (*n - *l + j) * a_dim1];
00412                 }
00413 
00414                 b1 = b[i__ + (*n - *l + i__) * b_dim1];
00415                 b3 = b[j + (*n - *l + j) * b_dim1];
00416 
00417                 if (upper) {
00418                     if (*k + i__ <= *m) {
00419                         a2 = a[*k + i__ + (*n - *l + j) * a_dim1];
00420                     }
00421                     b2 = b[i__ + (*n - *l + j) * b_dim1];
00422                 } else {
00423                     if (*k + j <= *m) {
00424                         a2 = a[*k + j + (*n - *l + i__) * a_dim1];
00425                     }
00426                     b2 = b[j + (*n - *l + i__) * b_dim1];
00427                 }
00428 
00429                 slags2_(&upper, &a1, &a2, &a3, &b1, &b2, &b3, &csu, &snu, &
00430                         csv, &snv, &csq, &snq);
00431 
00432 /*              Update (K+I)-th and (K+J)-th rows of matrix A: U'*A */
00433 
00434                 if (*k + j <= *m) {
00435                     srot_(l, &a[*k + j + (*n - *l + 1) * a_dim1], lda, &a[*k 
00436                             + i__ + (*n - *l + 1) * a_dim1], lda, &csu, &snu);
00437                 }
00438 
00439 /*              Update I-th and J-th rows of matrix B: V'*B */
00440 
00441                 srot_(l, &b[j + (*n - *l + 1) * b_dim1], ldb, &b[i__ + (*n - *
00442                         l + 1) * b_dim1], ldb, &csv, &snv);
00443 
00444 /*              Update (N-L+I)-th and (N-L+J)-th columns of matrices */
00445 /*              A and B: A*Q and B*Q */
00446 
00447 /* Computing MIN */
00448                 i__4 = *k + *l;
00449                 i__3 = min(i__4,*m);
00450                 srot_(&i__3, &a[(*n - *l + j) * a_dim1 + 1], &c__1, &a[(*n - *
00451                         l + i__) * a_dim1 + 1], &c__1, &csq, &snq);
00452 
00453                 srot_(l, &b[(*n - *l + j) * b_dim1 + 1], &c__1, &b[(*n - *l + 
00454                         i__) * b_dim1 + 1], &c__1, &csq, &snq);
00455 
00456                 if (upper) {
00457                     if (*k + i__ <= *m) {
00458                         a[*k + i__ + (*n - *l + j) * a_dim1] = 0.f;
00459                     }
00460                     b[i__ + (*n - *l + j) * b_dim1] = 0.f;
00461                 } else {
00462                     if (*k + j <= *m) {
00463                         a[*k + j + (*n - *l + i__) * a_dim1] = 0.f;
00464                     }
00465                     b[j + (*n - *l + i__) * b_dim1] = 0.f;
00466                 }
00467 
00468 /*              Update orthogonal matrices U, V, Q, if desired. */
00469 
00470                 if (wantu && *k + j <= *m) {
00471                     srot_(m, &u[(*k + j) * u_dim1 + 1], &c__1, &u[(*k + i__) *
00472                              u_dim1 + 1], &c__1, &csu, &snu);
00473                 }
00474 
00475                 if (wantv) {
00476                     srot_(p, &v[j * v_dim1 + 1], &c__1, &v[i__ * v_dim1 + 1], 
00477                             &c__1, &csv, &snv);
00478                 }
00479 
00480                 if (wantq) {
00481                     srot_(n, &q[(*n - *l + j) * q_dim1 + 1], &c__1, &q[(*n - *
00482                             l + i__) * q_dim1 + 1], &c__1, &csq, &snq);
00483                 }
00484 
00485 /* L10: */
00486             }
00487 /* L20: */
00488         }
00489 
00490         if (! upper) {
00491 
00492 /*           The matrices A13 and B13 were lower triangular at the start */
00493 /*           of the cycle, and are now upper triangular. */
00494 
00495 /*           Convergence test: test the parallelism of the corresponding */
00496 /*           rows of A and B. */
00497 
00498             error = 0.f;
00499 /* Computing MIN */
00500             i__2 = *l, i__3 = *m - *k;
00501             i__1 = min(i__2,i__3);
00502             for (i__ = 1; i__ <= i__1; ++i__) {
00503                 i__2 = *l - i__ + 1;
00504                 scopy_(&i__2, &a[*k + i__ + (*n - *l + i__) * a_dim1], lda, &
00505                         work[1], &c__1);
00506                 i__2 = *l - i__ + 1;
00507                 scopy_(&i__2, &b[i__ + (*n - *l + i__) * b_dim1], ldb, &work[*
00508                         l + 1], &c__1);
00509                 i__2 = *l - i__ + 1;
00510                 slapll_(&i__2, &work[1], &c__1, &work[*l + 1], &c__1, &ssmin);
00511                 error = dmax(error,ssmin);
00512 /* L30: */
00513             }
00514 
00515             if (dabs(error) <= dmin(*tola,*tolb)) {
00516                 goto L50;
00517             }
00518         }
00519 
00520 /*        End of cycle loop */
00521 
00522 /* L40: */
00523     }
00524 
00525 /*     The algorithm has not converged after MAXIT cycles. */
00526 
00527     *info = 1;
00528     goto L100;
00529 
00530 L50:
00531 
00532 /*     If ERROR <= MIN(TOLA,TOLB), then the algorithm has converged. */
00533 /*     Compute the generalized singular value pairs (ALPHA, BETA), and */
00534 /*     set the triangular matrix R to array A. */
00535 
00536     i__1 = *k;
00537     for (i__ = 1; i__ <= i__1; ++i__) {
00538         alpha[i__] = 1.f;
00539         beta[i__] = 0.f;
00540 /* L60: */
00541     }
00542 
00543 /* Computing MIN */
00544     i__2 = *l, i__3 = *m - *k;
00545     i__1 = min(i__2,i__3);
00546     for (i__ = 1; i__ <= i__1; ++i__) {
00547 
00548         a1 = a[*k + i__ + (*n - *l + i__) * a_dim1];
00549         b1 = b[i__ + (*n - *l + i__) * b_dim1];
00550 
00551         if (a1 != 0.f) {
00552             gamma = b1 / a1;
00553 
00554 /*           change sign if necessary */
00555 
00556             if (gamma < 0.f) {
00557                 i__2 = *l - i__ + 1;
00558                 sscal_(&i__2, &c_b43, &b[i__ + (*n - *l + i__) * b_dim1], ldb)
00559                         ;
00560                 if (wantv) {
00561                     sscal_(p, &c_b43, &v[i__ * v_dim1 + 1], &c__1);
00562                 }
00563             }
00564 
00565             r__1 = dabs(gamma);
00566             slartg_(&r__1, &c_b14, &beta[*k + i__], &alpha[*k + i__], &rwk);
00567 
00568             if (alpha[*k + i__] >= beta[*k + i__]) {
00569                 i__2 = *l - i__ + 1;
00570                 r__1 = 1.f / alpha[*k + i__];
00571                 sscal_(&i__2, &r__1, &a[*k + i__ + (*n - *l + i__) * a_dim1], 
00572                         lda);
00573             } else {
00574                 i__2 = *l - i__ + 1;
00575                 r__1 = 1.f / beta[*k + i__];
00576                 sscal_(&i__2, &r__1, &b[i__ + (*n - *l + i__) * b_dim1], ldb);
00577                 i__2 = *l - i__ + 1;
00578                 scopy_(&i__2, &b[i__ + (*n - *l + i__) * b_dim1], ldb, &a[*k 
00579                         + i__ + (*n - *l + i__) * a_dim1], lda);
00580             }
00581 
00582         } else {
00583 
00584             alpha[*k + i__] = 0.f;
00585             beta[*k + i__] = 1.f;
00586             i__2 = *l - i__ + 1;
00587             scopy_(&i__2, &b[i__ + (*n - *l + i__) * b_dim1], ldb, &a[*k + 
00588                     i__ + (*n - *l + i__) * a_dim1], lda);
00589 
00590         }
00591 
00592 /* L70: */
00593     }
00594 
00595 /*     Post-assignment */
00596 
00597     i__1 = *k + *l;
00598     for (i__ = *m + 1; i__ <= i__1; ++i__) {
00599         alpha[i__] = 0.f;
00600         beta[i__] = 1.f;
00601 /* L80: */
00602     }
00603 
00604     if (*k + *l < *n) {
00605         i__1 = *n;
00606         for (i__ = *k + *l + 1; i__ <= i__1; ++i__) {
00607             alpha[i__] = 0.f;
00608             beta[i__] = 0.f;
00609 /* L90: */
00610         }
00611     }
00612 
00613 L100:
00614     *ncycle = kcycle;
00615     return 0;
00616 
00617 /*     End of STGSJA */
00618 
00619 } /* stgsja_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:56:14