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


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