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


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