cglmts.c
Go to the documentation of this file.
00001 /* cglmts.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 complex c_b13 = {-1.f,-0.f};
00020 static complex c_b15 = {1.f,0.f};
00021 
00022 /* Subroutine */ int cglmts_(integer *n, integer *m, integer *p, complex *a, 
00023         complex *af, integer *lda, complex *b, complex *bf, integer *ldb, 
00024         complex *d__, complex *df, complex *x, complex *u, complex *work, 
00025         integer *lwork, real *rwork, 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;
00036     extern /* Subroutine */ int cgemv_(char *, integer *, integer *, complex *
00037 , complex *, integer *, complex *, integer *, complex *, complex *
00038 , integer *);
00039     real anorm, bnorm;
00040     extern /* Subroutine */ int ccopy_(integer *, complex *, integer *, 
00041             complex *, integer *);
00042     real dnorm, xnorm, ynorm;
00043     extern doublereal clange_(char *, integer *, integer *, complex *, 
00044             integer *, real *);
00045     extern /* Subroutine */ int cggglm_(integer *, integer *, integer *, 
00046             complex *, integer *, complex *, integer *, complex *, complex *, 
00047             complex *, complex *, integer *, integer *);
00048     extern doublereal slamch_(char *);
00049     extern /* Subroutine */ int clacpy_(char *, integer *, integer *, complex 
00050             *, integer *, complex *, integer *);
00051     extern doublereal scasum_(integer *, complex *, 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 /*  CGLMTS tests CGGGLM - 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) COMPLEX array, dimension (LDA,M) */
00081 /*          The N-by-M matrix A. */
00082 
00083 /*  AF      (workspace) COMPLEX 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) COMPLEX array, dimension (LDB,P) */
00089 /*          The N-by-P matrix A. */
00090 
00091 /*  BF      (workspace) COMPLEX 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) COMPLEX array, dimension( N ) */
00097 /*          On input, the left hand side of the GLM. */
00098 
00099 /*  DF      (workspace) COMPLEX array, dimension( N ) */
00100 
00101 /*  X       (output) COMPLEX array, dimension( M ) */
00102 /*          solution vector X in the GLM problem. */
00103 
00104 /*  U       (output) COMPLEX array, dimension( P ) */
00105 /*          solution vector U in the GLM problem. */
00106 
00107 /*  WORK    (workspace) COMPLEX array, dimension (LWORK) */
00108 
00109 /*  LWORK   (input) INTEGER */
00110 /*          The dimension of the array WORK. */
00111 
00112 /*  RWORK   (workspace) REAL array, dimension (M) */
00113 
00114 /*  RESULT   (output) REAL */
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 /*     .. Parameters .. */
00123 /*     .. */
00124 /*     .. Local Scalars .. */
00125 /*     .. */
00126 /*     .. External Functions .. */
00127 /*     .. */
00128 /*     .. External Subroutines .. */
00129 
00130 /*     .. Intrinsic Functions .. */
00131 /*     .. */
00132 /*     .. Executable Statements .. */
00133 
00134     /* Parameter adjustments */
00135     af_dim1 = *lda;
00136     af_offset = 1 + af_dim1;
00137     af -= af_offset;
00138     a_dim1 = *lda;
00139     a_offset = 1 + a_dim1;
00140     a -= a_offset;
00141     bf_dim1 = *ldb;
00142     bf_offset = 1 + bf_dim1;
00143     bf -= bf_offset;
00144     b_dim1 = *ldb;
00145     b_offset = 1 + b_dim1;
00146     b -= b_offset;
00147     --d__;
00148     --df;
00149     --x;
00150     --u;
00151     --work;
00152     --rwork;
00153 
00154     /* Function Body */
00155     eps = slamch_("Epsilon");
00156     unfl = slamch_("Safe minimum");
00157 /* Computing MAX */
00158     r__1 = clange_("1", n, m, &a[a_offset], lda, &rwork[1]);
00159     anorm = dmax(r__1,unfl);
00160 /* Computing MAX */
00161     r__1 = clange_("1", n, p, &b[b_offset], ldb, &rwork[1]);
00162     bnorm = dmax(r__1,unfl);
00163 
00164 /*     Copy the matrices A and B to the arrays AF and BF, */
00165 /*     and the vector D the array DF. */
00166 
00167     clacpy_("Full", n, m, &a[a_offset], lda, &af[af_offset], lda);
00168     clacpy_("Full", n, p, &b[b_offset], ldb, &bf[bf_offset], ldb);
00169     ccopy_(n, &d__[1], &c__1, &df[1], &c__1);
00170 
00171 /*     Solve GLM problem */
00172 
00173     cggglm_(n, m, p, &af[af_offset], lda, &bf[bf_offset], ldb, &df[1], &x[1], 
00174             &u[1], &work[1], lwork, &info);
00175 
00176 /*     Test the residual for the solution of LSE */
00177 
00178 /*                       norm( d - A*x - B*u ) */
00179 /*       RESULT = ----------------------------------------- */
00180 /*                (norm(A)+norm(B))*(norm(x)+norm(u))*EPS */
00181 
00182     ccopy_(n, &d__[1], &c__1, &df[1], &c__1);
00183     cgemv_("No transpose", n, m, &c_b13, &a[a_offset], lda, &x[1], &c__1, &
00184             c_b15, &df[1], &c__1);
00185 
00186     cgemv_("No transpose", n, p, &c_b13, &b[b_offset], ldb, &u[1], &c__1, &
00187             c_b15, &df[1], &c__1);
00188 
00189     dnorm = scasum_(n, &df[1], &c__1);
00190     xnorm = scasum_(m, &x[1], &c__1) + scasum_(p, &u[1], &c__1);
00191     ynorm = anorm + bnorm;
00192 
00193     if (xnorm <= 0.f) {
00194         *result = 0.f;
00195     } else {
00196         *result = dnorm / ynorm / xnorm / eps;
00197     }
00198 
00199     return 0;
00200 
00201 /*     End of CGLMTS */
00202 
00203 } /* cglmts_ */


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