zglmts.c
Go to the documentation of this file.
00001 /* zglmts.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 doublecomplex c_b13 = {-1.,-0.};
00020 static doublecomplex c_b15 = {1.,0.};
00021 
00022 /* Subroutine */ int zglmts_(integer *n, integer *m, integer *p, 
00023         doublecomplex *a, doublecomplex *af, integer *lda, doublecomplex *b, 
00024         doublecomplex *bf, integer *ldb, doublecomplex *d__, doublecomplex *
00025         df, doublecomplex *x, doublecomplex *u, doublecomplex *work, integer *
00026         lwork, doublereal *rwork, doublereal *result)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, af_dim1, af_offset, b_dim1, b_offset, bf_dim1, 
00030             bf_offset;
00031     doublereal d__1;
00032 
00033     /* Local variables */
00034     doublereal eps;
00035     integer info;
00036     doublereal unfl, anorm, bnorm, dnorm;
00037     extern /* Subroutine */ int zgemv_(char *, integer *, integer *, 
00038             doublecomplex *, doublecomplex *, integer *, doublecomplex *, 
00039             integer *, doublecomplex *, doublecomplex *, integer *);
00040     doublereal xnorm, ynorm;
00041     extern /* Subroutine */ int zcopy_(integer *, doublecomplex *, integer *, 
00042             doublecomplex *, integer *);
00043     extern doublereal dlamch_(char *), zlange_(char *, integer *, 
00044             integer *, doublecomplex *, integer *, doublereal *);
00045     extern /* Subroutine */ int zggglm_(integer *, integer *, integer *, 
00046             doublecomplex *, integer *, doublecomplex *, integer *, 
00047             doublecomplex *, doublecomplex *, doublecomplex *, doublecomplex *
00048 , integer *, integer *), zlacpy_(char *, integer *, integer *, 
00049             doublecomplex *, integer *, doublecomplex *, integer *);
00050     extern doublereal dzasum_(integer *, doublecomplex *, integer *);
00051 
00052 
00053 /*  -- LAPACK test routine (version 3.1) -- */
00054 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00055 /*     November 2006 */
00056 
00057 /*     .. Scalar Arguments .. */
00058 /*     .. */
00059 /*     .. Array Arguments .. */
00060 
00061 /*  Purpose */
00062 /*  ======= */
00063 
00064 /*  ZGLMTS tests ZGGGLM - a subroutine for solving the generalized */
00065 /*  linear model problem. */
00066 
00067 /*  Arguments */
00068 /*  ========= */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of rows of the matrices A and B.  N >= 0. */
00072 
00073 /*  M       (input) INTEGER */
00074 /*          The number of columns of the matrix A.  M >= 0. */
00075 
00076 /*  P       (input) INTEGER */
00077 /*          The number of columns of the matrix B.  P >= 0. */
00078 
00079 /*  A       (input) COMPLEX*16 array, dimension (LDA,M) */
00080 /*          The N-by-M matrix A. */
00081 
00082 /*  AF      (workspace) COMPLEX*16 array, dimension (LDA,M) */
00083 
00084 /*  LDA     (input) INTEGER */
00085 /*          The leading dimension of the arrays A, AF. LDA >= max(M,N). */
00086 
00087 /*  B       (input) COMPLEX*16 array, dimension (LDB,P) */
00088 /*          The N-by-P matrix A. */
00089 
00090 /*  BF      (workspace) COMPLEX*16 array, dimension (LDB,P) */
00091 
00092 /*  LDB     (input) INTEGER */
00093 /*          The leading dimension of the arrays B, BF. LDB >= max(P,N). */
00094 
00095 /*  D       (input) COMPLEX*16 array, dimension( N ) */
00096 /*          On input, the left hand side of the GLM. */
00097 
00098 /*  DF      (workspace) COMPLEX*16 array, dimension( N ) */
00099 
00100 /*  X       (output) COMPLEX*16 array, dimension( M ) */
00101 /*          solution vector X in the GLM problem. */
00102 
00103 /*  U       (output) COMPLEX*16 array, dimension( P ) */
00104 /*          solution vector U in the GLM problem. */
00105 
00106 /*  WORK    (workspace) COMPLEX*16 array, dimension (LWORK) */
00107 
00108 /*  LWORK   (input) INTEGER */
00109 /*          The dimension of the array WORK. */
00110 
00111 /*  RWORK   (workspace) DOUBLE PRECISION array, dimension (M) */
00112 
00113 /*  RESULT   (output) DOUBLE PRECISION */
00114 /*          The test ratio: */
00115 /*                           norm( d - A*x - B*u ) */
00116 /*            RESULT = ----------------------------------------- */
00117 /*                     (norm(A)+norm(B))*(norm(x)+norm(u))*EPS */
00118 
00119 /*  ==================================================================== */
00120 
00121 /*     .. */
00122 /*     .. Parameters .. */
00123 /*     .. */
00124 /*     .. Local Scalars .. */
00125 /*     .. */
00126 /*     .. External Functions .. */
00127 /*     .. */
00128 /*     .. External Subroutines .. */
00129 
00130 /*     .. */
00131 /*     .. Intrinsic Functions .. */
00132 /*     .. */
00133 /*     .. Executable Statements .. */
00134 
00135     /* Parameter adjustments */
00136     af_dim1 = *lda;
00137     af_offset = 1 + af_dim1;
00138     af -= af_offset;
00139     a_dim1 = *lda;
00140     a_offset = 1 + a_dim1;
00141     a -= a_offset;
00142     bf_dim1 = *ldb;
00143     bf_offset = 1 + bf_dim1;
00144     bf -= bf_offset;
00145     b_dim1 = *ldb;
00146     b_offset = 1 + b_dim1;
00147     b -= b_offset;
00148     --d__;
00149     --df;
00150     --x;
00151     --u;
00152     --work;
00153     --rwork;
00154 
00155     /* Function Body */
00156     eps = dlamch_("Epsilon");
00157     unfl = dlamch_("Safe minimum");
00158 /* Computing MAX */
00159     d__1 = zlange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00160     anorm = max(d__1,unfl);
00161 /* Computing MAX */
00162     d__1 = zlange_("1", n, p, &b[b_offset], ldb, &rwork[1]);
00163     bnorm = max(d__1,unfl);
00164 
00165 /*     Copy the matrices A and B to the arrays AF and BF, */
00166 /*     and the vector D the array DF. */
00167 
00168     zlacpy_("Full", n, m, &a[a_offset], lda, &af[af_offset], lda);
00169     zlacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00170     zcopy_(n, &d__[1], &c__1, &df[1], &c__1);
00171 
00172 /*     Solve GLM problem */
00173 
00174     zggglm_(n, m, p, &af[af_offset], lda, &bf[bf_offset], ldb, &df[1], &x[1], 
00175             &u[1], &work[1], lwork, &info);
00176 
00177 /*     Test the residual for the solution of LSE */
00178 
00179 /*                       norm( d - A*x - B*u ) */
00180 /*       RESULT = ----------------------------------------- */
00181 /*                (norm(A)+norm(B))*(norm(x)+norm(u))*EPS */
00182 
00183     zcopy_(n, &d__[1], &c__1, &df[1], &c__1);
00184     zgemv_("No transpose", n, m, &c_b13, &a[a_offset], lda, &x[1], &c__1, &
00185             c_b15, &df[1], &c__1);
00186 
00187     zgemv_("No transpose", n, p, &c_b13, &b[b_offset], ldb, &u[1], &c__1, &
00188             c_b15, &df[1], &c__1);
00189 
00190     dnorm = dzasum_(n, &df[1], &c__1);
00191     xnorm = dzasum_(m, &x[1], &c__1) + dzasum_(p, &u[1], &c__1);
00192     ynorm = anorm + bnorm;
00193 
00194     if (xnorm <= 0.) {
00195         *result = 0.;
00196     } else {
00197         *result = dnorm / ynorm / xnorm / eps;
00198     }
00199 
00200     return 0;
00201 
00202 /*     End of ZGLMTS */
00203 
00204 } /* zglmts_ */


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