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


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:34