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


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