sbdt01.c
Go to the documentation of this file.
00001 /* sbdt01.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_b7 = -1.f;
00020 static real c_b9 = 1.f;
00021 
00022 /* Subroutine */ int sbdt01_(integer *m, integer *n, integer *kd, real *a, 
00023         integer *lda, real *q, integer *ldq, real *d__, real *e, real *pt, 
00024         integer *ldpt, real *work, real *resid)
00025 {
00026     /* System generated locals */
00027     integer a_dim1, a_offset, pt_dim1, pt_offset, q_dim1, q_offset, i__1, 
00028             i__2;
00029     real r__1, r__2;
00030 
00031     /* Local variables */
00032     integer i__, j;
00033     real eps, anorm;
00034     extern /* Subroutine */ int sgemv_(char *, integer *, integer *, real *, 
00035             real *, integer *, real *, integer *, real *, real *, integer *);
00036     extern doublereal sasum_(integer *, real *, integer *);
00037     extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
00038             integer *);
00039     extern doublereal slamch_(char *), slange_(char *, integer *, 
00040             integer *, real *, integer *, real *);
00041 
00042 
00043 /*  -- LAPACK test routine (version 3.1) -- */
00044 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00045 /*     November 2006 */
00046 
00047 /*     .. Scalar Arguments .. */
00048 /*     .. */
00049 /*     .. Array Arguments .. */
00050 /*     .. */
00051 
00052 /*  Purpose */
00053 /*  ======= */
00054 
00055 /*  SBDT01 reconstructs a general matrix A from its bidiagonal form */
00056 /*     A = Q * B * P' */
00057 /*  where Q (m by min(m,n)) and P' (min(m,n) by n) are orthogonal */
00058 /*  matrices and B is bidiagonal. */
00059 
00060 /*  The test ratio to test the reduction is */
00061 /*     RESID = norm( A - Q * B * PT ) / ( n * norm(A) * EPS ) */
00062 /*  where PT = P' and EPS is the machine precision. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  M       (input) INTEGER */
00068 /*          The number of rows of the matrices A and Q. */
00069 
00070 /*  N       (input) INTEGER */
00071 /*          The number of columns of the matrices A and P'. */
00072 
00073 /*  KD      (input) INTEGER */
00074 /*          If KD = 0, B is diagonal and the array E is not referenced. */
00075 /*          If KD = 1, the reduction was performed by xGEBRD; B is upper */
00076 /*          bidiagonal if M >= N, and lower bidiagonal if M < N. */
00077 /*          If KD = -1, the reduction was performed by xGBBRD; B is */
00078 /*          always upper bidiagonal. */
00079 
00080 /*  A       (input) REAL array, dimension (LDA,N) */
00081 /*          The m by n matrix A. */
00082 
00083 /*  LDA     (input) INTEGER */
00084 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00085 
00086 /*  Q       (input) REAL array, dimension (LDQ,N) */
00087 /*          The m by min(m,n) orthogonal matrix Q in the reduction */
00088 /*          A = Q * B * P'. */
00089 
00090 /*  LDQ     (input) INTEGER */
00091 /*          The leading dimension of the array Q.  LDQ >= max(1,M). */
00092 
00093 /*  D       (input) REAL array, dimension (min(M,N)) */
00094 /*          The diagonal elements of the bidiagonal matrix B. */
00095 
00096 /*  E       (input) REAL array, dimension (min(M,N)-1) */
00097 /*          The superdiagonal elements of the bidiagonal matrix B if */
00098 /*          m >= n, or the subdiagonal elements of B if m < n. */
00099 
00100 /*  PT      (input) REAL array, dimension (LDPT,N) */
00101 /*          The min(m,n) by n orthogonal matrix P' in the reduction */
00102 /*          A = Q * B * P'. */
00103 
00104 /*  LDPT    (input) INTEGER */
00105 /*          The leading dimension of the array PT. */
00106 /*          LDPT >= max(1,min(M,N)). */
00107 
00108 /*  WORK    (workspace) REAL array, dimension (M+N) */
00109 
00110 /*  RESID   (output) REAL */
00111 /*          The test ratio:  norm(A - Q * B * P') / ( n * norm(A) * EPS ) */
00112 
00113 /*  ===================================================================== */
00114 
00115 /*     .. Parameters .. */
00116 /*     .. */
00117 /*     .. Local Scalars .. */
00118 /*     .. */
00119 /*     .. External Functions .. */
00120 /*     .. */
00121 /*     .. External Subroutines .. */
00122 /*     .. */
00123 /*     .. Intrinsic Functions .. */
00124 /*     .. */
00125 /*     .. Executable Statements .. */
00126 
00127 /*     Quick return if possible */
00128 
00129     /* Parameter adjustments */
00130     a_dim1 = *lda;
00131     a_offset = 1 + a_dim1;
00132     a -= a_offset;
00133     q_dim1 = *ldq;
00134     q_offset = 1 + q_dim1;
00135     q -= q_offset;
00136     --d__;
00137     --e;
00138     pt_dim1 = *ldpt;
00139     pt_offset = 1 + pt_dim1;
00140     pt -= pt_offset;
00141     --work;
00142 
00143     /* Function Body */
00144     if (*m <= 0 || *n <= 0) {
00145         *resid = 0.f;
00146         return 0;
00147     }
00148 
00149 /*     Compute A - Q * B * P' one column at a time. */
00150 
00151     *resid = 0.f;
00152     if (*kd != 0) {
00153 
00154 /*        B is bidiagonal. */
00155 
00156         if (*kd != 0 && *m >= *n) {
00157 
00158 /*           B is upper bidiagonal and M >= N. */
00159 
00160             i__1 = *n;
00161             for (j = 1; j <= i__1; ++j) {
00162                 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00163                 i__2 = *n - 1;
00164                 for (i__ = 1; i__ <= i__2; ++i__) {
00165                     work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1] + e[i__]
00166                              * pt[i__ + 1 + j * pt_dim1];
00167 /* L10: */
00168                 }
00169                 work[*m + *n] = d__[*n] * pt[*n + j * pt_dim1];
00170                 sgemv_("No transpose", m, n, &c_b7, &q[q_offset], ldq, &work[*
00171                         m + 1], &c__1, &c_b9, &work[1], &c__1);
00172 /* Computing MAX */
00173                 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00174                 *resid = dmax(r__1,r__2);
00175 /* L20: */
00176             }
00177         } else if (*kd < 0) {
00178 
00179 /*           B is upper bidiagonal and M < N. */
00180 
00181             i__1 = *n;
00182             for (j = 1; j <= i__1; ++j) {
00183                 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00184                 i__2 = *m - 1;
00185                 for (i__ = 1; i__ <= i__2; ++i__) {
00186                     work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1] + e[i__]
00187                              * pt[i__ + 1 + j * pt_dim1];
00188 /* L30: */
00189                 }
00190                 work[*m + *m] = d__[*m] * pt[*m + j * pt_dim1];
00191                 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00192                         m + 1], &c__1, &c_b9, &work[1], &c__1);
00193 /* Computing MAX */
00194                 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00195                 *resid = dmax(r__1,r__2);
00196 /* L40: */
00197             }
00198         } else {
00199 
00200 /*           B is lower bidiagonal. */
00201 
00202             i__1 = *n;
00203             for (j = 1; j <= i__1; ++j) {
00204                 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00205                 work[*m + 1] = d__[1] * pt[j * pt_dim1 + 1];
00206                 i__2 = *m;
00207                 for (i__ = 2; i__ <= i__2; ++i__) {
00208                     work[*m + i__] = e[i__ - 1] * pt[i__ - 1 + j * pt_dim1] + 
00209                             d__[i__] * pt[i__ + j * pt_dim1];
00210 /* L50: */
00211                 }
00212                 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00213                         m + 1], &c__1, &c_b9, &work[1], &c__1);
00214 /* Computing MAX */
00215                 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00216                 *resid = dmax(r__1,r__2);
00217 /* L60: */
00218             }
00219         }
00220     } else {
00221 
00222 /*        B is diagonal. */
00223 
00224         if (*m >= *n) {
00225             i__1 = *n;
00226             for (j = 1; j <= i__1; ++j) {
00227                 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00228                 i__2 = *n;
00229                 for (i__ = 1; i__ <= i__2; ++i__) {
00230                     work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1];
00231 /* L70: */
00232                 }
00233                 sgemv_("No transpose", m, n, &c_b7, &q[q_offset], ldq, &work[*
00234                         m + 1], &c__1, &c_b9, &work[1], &c__1);
00235 /* Computing MAX */
00236                 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00237                 *resid = dmax(r__1,r__2);
00238 /* L80: */
00239             }
00240         } else {
00241             i__1 = *n;
00242             for (j = 1; j <= i__1; ++j) {
00243                 scopy_(m, &a[j * a_dim1 + 1], &c__1, &work[1], &c__1);
00244                 i__2 = *m;
00245                 for (i__ = 1; i__ <= i__2; ++i__) {
00246                     work[*m + i__] = d__[i__] * pt[i__ + j * pt_dim1];
00247 /* L90: */
00248                 }
00249                 sgemv_("No transpose", m, m, &c_b7, &q[q_offset], ldq, &work[*
00250                         m + 1], &c__1, &c_b9, &work[1], &c__1);
00251 /* Computing MAX */
00252                 r__1 = *resid, r__2 = sasum_(m, &work[1], &c__1);
00253                 *resid = dmax(r__1,r__2);
00254 /* L100: */
00255             }
00256         }
00257     }
00258 
00259 /*     Compute norm(A - Q * B * P') / ( n * norm(A) * EPS ) */
00260 
00261     anorm = slange_("1", m, n, &a[a_offset], lda, &work[1]);
00262     eps = slamch_("Precision");
00263 
00264     if (anorm <= 0.f) {
00265         if (*resid != 0.f) {
00266             *resid = 1.f / eps;
00267         }
00268     } else {
00269         if (anorm >= *resid) {
00270             *resid = *resid / anorm / ((real) (*n) * eps);
00271         } else {
00272             if (anorm < 1.f) {
00273 /* Computing MIN */
00274                 r__1 = *resid, r__2 = (real) (*n) * anorm;
00275                 *resid = dmin(r__1,r__2) / anorm / ((real) (*n) * eps);
00276             } else {
00277 /* Computing MIN */
00278                 r__1 = *resid / anorm, r__2 = (real) (*n);
00279                 *resid = dmin(r__1,r__2) / ((real) (*n) * eps);
00280             }
00281         }
00282     }
00283 
00284     return 0;
00285 
00286 /*     End of SBDT01 */
00287 
00288 } /* sbdt01_ */


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