ztrexc.c
Go to the documentation of this file.
00001 /* ztrexc.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 integer c__1 = 1;
00019 
00020 /* Subroutine */ int ztrexc_(char *compq, integer *n, doublecomplex *t, 
00021         integer *ldt, doublecomplex *q, integer *ldq, integer *ifst, integer *
00022         ilst, integer *info)
00023 {
00024     /* System generated locals */
00025     integer q_dim1, q_offset, t_dim1, t_offset, i__1, i__2, i__3;
00026     doublecomplex z__1;
00027 
00028     /* Builtin functions */
00029     void d_cnjg(doublecomplex *, doublecomplex *);
00030 
00031     /* Local variables */
00032     integer k, m1, m2, m3;
00033     doublereal cs;
00034     doublecomplex t11, t22, sn, temp;
00035     extern /* Subroutine */ int zrot_(integer *, doublecomplex *, integer *, 
00036             doublecomplex *, integer *, doublereal *, doublecomplex *);
00037     extern logical lsame_(char *, char *);
00038     logical wantq;
00039     extern /* Subroutine */ int xerbla_(char *, integer *), zlartg_(
00040             doublecomplex *, doublecomplex *, doublereal *, doublecomplex *, 
00041             doublecomplex *);
00042 
00043 
00044 /*  -- LAPACK routine (version 3.2) -- */
00045 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00046 /*     November 2006 */
00047 
00048 /*     .. Scalar Arguments .. */
00049 /*     .. */
00050 /*     .. Array Arguments .. */
00051 /*     .. */
00052 
00053 /*  Purpose */
00054 /*  ======= */
00055 
00056 /*  ZTREXC reorders the Schur factorization of a complex matrix */
00057 /*  A = Q*T*Q**H, so that the diagonal element of T with row index IFST */
00058 /*  is moved to row ILST. */
00059 
00060 /*  The Schur form T is reordered by a unitary similarity transformation */
00061 /*  Z**H*T*Z, and optionally the matrix Q of Schur vectors is updated by */
00062 /*  postmultplying it with Z. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  COMPQ   (input) CHARACTER*1 */
00068 /*          = 'V':  update the matrix Q of Schur vectors; */
00069 /*          = 'N':  do not update Q. */
00070 
00071 /*  N       (input) INTEGER */
00072 /*          The order of the matrix T. N >= 0. */
00073 
00074 /*  T       (input/output) COMPLEX*16 array, dimension (LDT,N) */
00075 /*          On entry, the upper triangular matrix T. */
00076 /*          On exit, the reordered upper triangular matrix. */
00077 
00078 /*  LDT     (input) INTEGER */
00079 /*          The leading dimension of the array T. LDT >= max(1,N). */
00080 
00081 /*  Q       (input/output) COMPLEX*16 array, dimension (LDQ,N) */
00082 /*          On entry, if COMPQ = 'V', the matrix Q of Schur vectors. */
00083 /*          On exit, if COMPQ = 'V', Q has been postmultiplied by the */
00084 /*          unitary transformation matrix Z which reorders T. */
00085 /*          If COMPQ = 'N', Q is not referenced. */
00086 
00087 /*  LDQ     (input) INTEGER */
00088 /*          The leading dimension of the array Q.  LDQ >= max(1,N). */
00089 
00090 /*  IFST    (input) INTEGER */
00091 /*  ILST    (input) INTEGER */
00092 /*          Specify the reordering of the diagonal elements of T: */
00093 /*          The element with row index IFST is moved to row ILST by a */
00094 /*          sequence of transpositions between adjacent elements. */
00095 /*          1 <= IFST <= N; 1 <= ILST <= N. */
00096 
00097 /*  INFO    (output) INTEGER */
00098 /*          = 0:  successful exit */
00099 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00100 
00101 /*  ===================================================================== */
00102 
00103 /*     .. Local Scalars .. */
00104 /*     .. */
00105 /*     .. External Functions .. */
00106 /*     .. */
00107 /*     .. External Subroutines .. */
00108 /*     .. */
00109 /*     .. Intrinsic Functions .. */
00110 /*     .. */
00111 /*     .. Executable Statements .. */
00112 
00113 /*     Decode and test the input parameters. */
00114 
00115     /* Parameter adjustments */
00116     t_dim1 = *ldt;
00117     t_offset = 1 + t_dim1;
00118     t -= t_offset;
00119     q_dim1 = *ldq;
00120     q_offset = 1 + q_dim1;
00121     q -= q_offset;
00122 
00123     /* Function Body */
00124     *info = 0;
00125     wantq = lsame_(compq, "V");
00126     if (! lsame_(compq, "N") && ! wantq) {
00127         *info = -1;
00128     } else if (*n < 0) {
00129         *info = -2;
00130     } else if (*ldt < max(1,*n)) {
00131         *info = -4;
00132     } else if (*ldq < 1 || wantq && *ldq < max(1,*n)) {
00133         *info = -6;
00134     } else if (*ifst < 1 || *ifst > *n) {
00135         *info = -7;
00136     } else if (*ilst < 1 || *ilst > *n) {
00137         *info = -8;
00138     }
00139     if (*info != 0) {
00140         i__1 = -(*info);
00141         xerbla_("ZTREXC", &i__1);
00142         return 0;
00143     }
00144 
00145 /*     Quick return if possible */
00146 
00147     if (*n == 1 || *ifst == *ilst) {
00148         return 0;
00149     }
00150 
00151     if (*ifst < *ilst) {
00152 
00153 /*        Move the IFST-th diagonal element forward down the diagonal. */
00154 
00155         m1 = 0;
00156         m2 = -1;
00157         m3 = 1;
00158     } else {
00159 
00160 /*        Move the IFST-th diagonal element backward up the diagonal. */
00161 
00162         m1 = -1;
00163         m2 = 0;
00164         m3 = -1;
00165     }
00166 
00167     i__1 = *ilst + m2;
00168     i__2 = m3;
00169     for (k = *ifst + m1; i__2 < 0 ? k >= i__1 : k <= i__1; k += i__2) {
00170 
00171 /*        Interchange the k-th and (k+1)-th diagonal elements. */
00172 
00173         i__3 = k + k * t_dim1;
00174         t11.r = t[i__3].r, t11.i = t[i__3].i;
00175         i__3 = k + 1 + (k + 1) * t_dim1;
00176         t22.r = t[i__3].r, t22.i = t[i__3].i;
00177 
00178 /*        Determine the transformation to perform the interchange. */
00179 
00180         z__1.r = t22.r - t11.r, z__1.i = t22.i - t11.i;
00181         zlartg_(&t[k + (k + 1) * t_dim1], &z__1, &cs, &sn, &temp);
00182 
00183 /*        Apply transformation to the matrix T. */
00184 
00185         if (k + 2 <= *n) {
00186             i__3 = *n - k - 1;
00187             zrot_(&i__3, &t[k + (k + 2) * t_dim1], ldt, &t[k + 1 + (k + 2) * 
00188                     t_dim1], ldt, &cs, &sn);
00189         }
00190         i__3 = k - 1;
00191         d_cnjg(&z__1, &sn);
00192         zrot_(&i__3, &t[k * t_dim1 + 1], &c__1, &t[(k + 1) * t_dim1 + 1], &
00193                 c__1, &cs, &z__1);
00194 
00195         i__3 = k + k * t_dim1;
00196         t[i__3].r = t22.r, t[i__3].i = t22.i;
00197         i__3 = k + 1 + (k + 1) * t_dim1;
00198         t[i__3].r = t11.r, t[i__3].i = t11.i;
00199 
00200         if (wantq) {
00201 
00202 /*           Accumulate transformation in the matrix Q. */
00203 
00204             d_cnjg(&z__1, &sn);
00205             zrot_(n, &q[k * q_dim1 + 1], &c__1, &q[(k + 1) * q_dim1 + 1], &
00206                     c__1, &cs, &z__1);
00207         }
00208 
00209 /* L10: */
00210     }
00211 
00212     return 0;
00213 
00214 /*     End of ZTREXC */
00215 
00216 } /* ztrexc_ */


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