slatm6.c
Go to the documentation of this file.
00001 /* slatm6.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 static integer c__4 = 4;
00020 static integer c__12 = 12;
00021 static integer c__8 = 8;
00022 static integer c__40 = 40;
00023 static integer c__2 = 2;
00024 static integer c__3 = 3;
00025 static integer c__60 = 60;
00026 
00027 /* Subroutine */ int slatm6_(integer *type__, integer *n, real *a, integer *
00028         lda, real *b, real *x, integer *ldx, real *y, integer *ldy, real *
00029         alpha, real *beta, real *wx, real *wy, real *s, real *dif)
00030 {
00031     /* System generated locals */
00032     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, y_dim1, 
00033             y_offset, i__1, i__2;
00034 
00035     /* Builtin functions */
00036     double sqrt(doublereal);
00037 
00038     /* Local variables */
00039     integer i__, j;
00040     real z__[144]       /* was [12][12] */;
00041     integer info;
00042     real work[100];
00043     extern /* Subroutine */ int slakf2_(integer *, integer *, real *, integer 
00044             *, real *, real *, real *, real *, integer *), sgesvd_(char *, 
00045             char *, integer *, integer *, real *, integer *, real *, real *, 
00046             integer *, real *, integer *, real *, integer *, integer *), slacpy_(char *, integer *, integer *, real *, 
00047             integer *, real *, integer *);
00048 
00049 
00050 /*  -- LAPACK test routine (version 3.1) -- */
00051 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00052 /*     November 2006 */
00053 
00054 /*     .. Scalar Arguments .. */
00055 /*     .. */
00056 /*     .. Array Arguments .. */
00057 /*     .. */
00058 
00059 /*  Purpose */
00060 /*  ======= */
00061 
00062 /*  SLATM6 generates test matrices for the generalized eigenvalue */
00063 /*  problem, their corresponding right and left eigenvector matrices, */
00064 /*  and also reciprocal condition numbers for all eigenvalues and */
00065 /*  the reciprocal condition numbers of eigenvectors corresponding to */
00066 /*  the 1th and 5th eigenvalues. */
00067 
00068 /*  Test Matrices */
00069 /*  ============= */
00070 
00071 /*  Two kinds of test matrix pairs */
00072 
00073 /*        (A, B) = inverse(YH) * (Da, Db) * inverse(X) */
00074 
00075 /*  are used in the tests: */
00076 
00077 /*  Type 1: */
00078 /*     Da = 1+a   0    0    0    0    Db = 1   0   0   0   0 */
00079 /*           0   2+a   0    0    0         0   1   0   0   0 */
00080 /*           0    0   3+a   0    0         0   0   1   0   0 */
00081 /*           0    0    0   4+a   0         0   0   0   1   0 */
00082 /*           0    0    0    0   5+a ,      0   0   0   0   1 , and */
00083 
00084 /*  Type 2: */
00085 /*     Da =  1   -1    0    0    0    Db = 1   0   0   0   0 */
00086 /*           1    1    0    0    0         0   1   0   0   0 */
00087 /*           0    0    1    0    0         0   0   1   0   0 */
00088 /*           0    0    0   1+a  1+b        0   0   0   1   0 */
00089 /*           0    0    0  -1-b  1+a ,      0   0   0   0   1 . */
00090 
00091 /*  In both cases the same inverse(YH) and inverse(X) are used to compute */
00092 /*  (A, B), giving the exact eigenvectors to (A,B) as (YH, X): */
00093 
00094 /*  YH:  =  1    0   -y    y   -y    X =  1   0  -x  -x   x */
00095 /*          0    1   -y    y   -y         0   1   x  -x  -x */
00096 /*          0    0    1    0    0         0   0   1   0   0 */
00097 /*          0    0    0    1    0         0   0   0   1   0 */
00098 /*          0    0    0    0    1,        0   0   0   0   1 , */
00099 
00100 /* where a, b, x and y will have all values independently of each other. */
00101 
00102 /*  Arguments */
00103 /*  ========= */
00104 
00105 /*  TYPE    (input) INTEGER */
00106 /*          Specifies the problem type (see futher details). */
00107 
00108 /*  N       (input) INTEGER */
00109 /*          Size of the matrices A and B. */
00110 
00111 /*  A       (output) REAL array, dimension (LDA, N). */
00112 /*          On exit A N-by-N is initialized according to TYPE. */
00113 
00114 /*  LDA     (input) INTEGER */
00115 /*          The leading dimension of A and of B. */
00116 
00117 /*  B       (output) REAL array, dimension (LDA, N). */
00118 /*          On exit B N-by-N is initialized according to TYPE. */
00119 
00120 /*  X       (output) REAL array, dimension (LDX, N). */
00121 /*          On exit X is the N-by-N matrix of right eigenvectors. */
00122 
00123 /*  LDX     (input) INTEGER */
00124 /*          The leading dimension of X. */
00125 
00126 /*  Y       (output) REAL array, dimension (LDY, N). */
00127 /*          On exit Y is the N-by-N matrix of left eigenvectors. */
00128 
00129 /*  LDY     (input) INTEGER */
00130 /*          The leading dimension of Y. */
00131 
00132 /*  ALPHA   (input) REAL */
00133 /*  BETA    (input) REAL */
00134 /*          Weighting constants for matrix A. */
00135 
00136 /*  WX      (input) REAL */
00137 /*          Constant for right eigenvector matrix. */
00138 
00139 /*  WY      (input) REAL */
00140 /*          Constant for left eigenvector matrix. */
00141 
00142 /*  S       (output) REAL array, dimension (N) */
00143 /*          S(i) is the reciprocal condition number for eigenvalue i. */
00144 
00145 /*  DIF     (output) REAL array, dimension (N) */
00146 /*          DIF(i) is the reciprocal condition number for eigenvector i. */
00147 
00148 /*  ===================================================================== */
00149 
00150 /*     .. Parameters .. */
00151 /*     .. */
00152 /*     .. Local Scalars .. */
00153 /*     .. */
00154 /*     .. Local Arrays .. */
00155 /*     .. */
00156 /*     .. Intrinsic Functions .. */
00157 /*     .. */
00158 /*     .. External Subroutines .. */
00159 /*     .. */
00160 /*     .. Executable Statements .. */
00161 
00162 /*     Generate test problem ... */
00163 /*     (Da, Db) ... */
00164 
00165     /* Parameter adjustments */
00166     b_dim1 = *lda;
00167     b_offset = 1 + b_dim1;
00168     b -= b_offset;
00169     a_dim1 = *lda;
00170     a_offset = 1 + a_dim1;
00171     a -= a_offset;
00172     x_dim1 = *ldx;
00173     x_offset = 1 + x_dim1;
00174     x -= x_offset;
00175     y_dim1 = *ldy;
00176     y_offset = 1 + y_dim1;
00177     y -= y_offset;
00178     --s;
00179     --dif;
00180 
00181     /* Function Body */
00182     i__1 = *n;
00183     for (i__ = 1; i__ <= i__1; ++i__) {
00184         i__2 = *n;
00185         for (j = 1; j <= i__2; ++j) {
00186 
00187             if (i__ == j) {
00188                 a[i__ + i__ * a_dim1] = (real) i__ + *alpha;
00189                 b[i__ + i__ * b_dim1] = 1.f;
00190             } else {
00191                 a[i__ + j * a_dim1] = 0.f;
00192                 b[i__ + j * b_dim1] = 0.f;
00193             }
00194 
00195 /* L10: */
00196         }
00197 /* L20: */
00198     }
00199 
00200 /*     Form X and Y */
00201 
00202     slacpy_("F", n, n, &b[b_offset], lda, &y[y_offset], ldy);
00203     y[y_dim1 + 3] = -(*wy);
00204     y[y_dim1 + 4] = *wy;
00205     y[y_dim1 + 5] = -(*wy);
00206     y[(y_dim1 << 1) + 3] = -(*wy);
00207     y[(y_dim1 << 1) + 4] = *wy;
00208     y[(y_dim1 << 1) + 5] = -(*wy);
00209 
00210     slacpy_("F", n, n, &b[b_offset], lda, &x[x_offset], ldx);
00211     x[x_dim1 * 3 + 1] = -(*wx);
00212     x[(x_dim1 << 2) + 1] = -(*wx);
00213     x[x_dim1 * 5 + 1] = *wx;
00214     x[x_dim1 * 3 + 2] = *wx;
00215     x[(x_dim1 << 2) + 2] = -(*wx);
00216     x[x_dim1 * 5 + 2] = -(*wx);
00217 
00218 /*     Form (A, B) */
00219 
00220     b[b_dim1 * 3 + 1] = *wx + *wy;
00221     b[b_dim1 * 3 + 2] = -(*wx) + *wy;
00222     b[(b_dim1 << 2) + 1] = *wx - *wy;
00223     b[(b_dim1 << 2) + 2] = *wx - *wy;
00224     b[b_dim1 * 5 + 1] = -(*wx) + *wy;
00225     b[b_dim1 * 5 + 2] = *wx + *wy;
00226     if (*type__ == 1) {
00227         a[a_dim1 * 3 + 1] = *wx * a[a_dim1 + 1] + *wy * a[a_dim1 * 3 + 3];
00228         a[a_dim1 * 3 + 2] = -(*wx) * a[(a_dim1 << 1) + 2] + *wy * a[a_dim1 * 
00229                 3 + 3];
00230         a[(a_dim1 << 2) + 1] = *wx * a[a_dim1 + 1] - *wy * a[(a_dim1 << 2) + 
00231                 4];
00232         a[(a_dim1 << 2) + 2] = *wx * a[(a_dim1 << 1) + 2] - *wy * a[(a_dim1 <<
00233                  2) + 4];
00234         a[a_dim1 * 5 + 1] = -(*wx) * a[a_dim1 + 1] + *wy * a[a_dim1 * 5 + 5];
00235         a[a_dim1 * 5 + 2] = *wx * a[(a_dim1 << 1) + 2] + *wy * a[a_dim1 * 5 + 
00236                 5];
00237     } else if (*type__ == 2) {
00238         a[a_dim1 * 3 + 1] = *wx * 2.f + *wy;
00239         a[a_dim1 * 3 + 2] = *wy;
00240         a[(a_dim1 << 2) + 1] = -(*wy) * (*alpha + 2.f + *beta);
00241         a[(a_dim1 << 2) + 2] = *wx * 2.f - *wy * (*alpha + 2.f + *beta);
00242         a[a_dim1 * 5 + 1] = *wx * -2.f + *wy * (*alpha - *beta);
00243         a[a_dim1 * 5 + 2] = *wy * (*alpha - *beta);
00244         a[a_dim1 + 1] = 1.f;
00245         a[(a_dim1 << 1) + 1] = -1.f;
00246         a[a_dim1 + 2] = 1.f;
00247         a[(a_dim1 << 1) + 2] = a[a_dim1 + 1];
00248         a[a_dim1 * 3 + 3] = 1.f;
00249         a[(a_dim1 << 2) + 4] = *alpha + 1.f;
00250         a[a_dim1 * 5 + 4] = *beta + 1.f;
00251         a[(a_dim1 << 2) + 5] = -a[a_dim1 * 5 + 4];
00252         a[a_dim1 * 5 + 5] = a[(a_dim1 << 2) + 4];
00253     }
00254 
00255 /*     Compute condition numbers */
00256 
00257     if (*type__ == 1) {
00258 
00259         s[1] = 1.f / sqrt((*wy * 3.f * *wy + 1.f) / (a[a_dim1 + 1] * a[a_dim1 
00260                 + 1] + 1.f));
00261         s[2] = 1.f / sqrt((*wy * 3.f * *wy + 1.f) / (a[(a_dim1 << 1) + 2] * a[
00262                 (a_dim1 << 1) + 2] + 1.f));
00263         s[3] = 1.f / sqrt((*wx * 2.f * *wx + 1.f) / (a[a_dim1 * 3 + 3] * a[
00264                 a_dim1 * 3 + 3] + 1.f));
00265         s[4] = 1.f / sqrt((*wx * 2.f * *wx + 1.f) / (a[(a_dim1 << 2) + 4] * a[
00266                 (a_dim1 << 2) + 4] + 1.f));
00267         s[5] = 1.f / sqrt((*wx * 2.f * *wx + 1.f) / (a[a_dim1 * 5 + 5] * a[
00268                 a_dim1 * 5 + 5] + 1.f));
00269 
00270         slakf2_(&c__1, &c__4, &a[a_offset], lda, &a[(a_dim1 << 1) + 2], &b[
00271                 b_offset], &b[(b_dim1 << 1) + 2], z__, &c__12);
00272         sgesvd_("N", "N", &c__8, &c__8, z__, &c__12, work, &work[8], &c__1, &
00273                 work[9], &c__1, &work[10], &c__40, &info);
00274         dif[1] = work[7];
00275 
00276         slakf2_(&c__4, &c__1, &a[a_offset], lda, &a[a_dim1 * 5 + 5], &b[
00277                 b_offset], &b[b_dim1 * 5 + 5], z__, &c__12);
00278         sgesvd_("N", "N", &c__8, &c__8, z__, &c__12, work, &work[8], &c__1, &
00279                 work[9], &c__1, &work[10], &c__40, &info);
00280         dif[5] = work[7];
00281 
00282     } else if (*type__ == 2) {
00283 
00284         s[1] = 1.f / sqrt(*wy * *wy + .33333333333333331f);
00285         s[2] = s[1];
00286         s[3] = 1.f / sqrt(*wx * *wx + .5f);
00287         s[4] = 1.f / sqrt((*wx * 2.f * *wx + 1.f) / ((*alpha + 1.f) * (*alpha 
00288                 + 1.f) + 1.f + (*beta + 1.f) * (*beta + 1.f)));
00289         s[5] = s[4];
00290 
00291         slakf2_(&c__2, &c__3, &a[a_offset], lda, &a[a_dim1 * 3 + 3], &b[
00292                 b_offset], &b[b_dim1 * 3 + 3], z__, &c__12);
00293         sgesvd_("N", "N", &c__12, &c__12, z__, &c__12, work, &work[12], &c__1, 
00294                  &work[13], &c__1, &work[14], &c__60, &info);
00295         dif[1] = work[11];
00296 
00297         slakf2_(&c__3, &c__2, &a[a_offset], lda, &a[(a_dim1 << 2) + 4], &b[
00298                 b_offset], &b[(b_dim1 << 2) + 4], z__, &c__12);
00299         sgesvd_("N", "N", &c__12, &c__12, z__, &c__12, work, &work[12], &c__1, 
00300                  &work[13], &c__1, &work[14], &c__60, &info);
00301         dif[5] = work[11];
00302 
00303     }
00304 
00305     return 0;
00306 
00307 /*     End of SLATM6 */
00308 
00309 } /* slatm6_ */


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