dqrt15.c
Go to the documentation of this file.
00001 /* dqrt15.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__16 = 16;
00019 static integer c__2 = 2;
00020 static integer c__1 = 1;
00021 static doublereal c_b18 = 0.;
00022 static doublereal c_b19 = 1.;
00023 static doublereal c_b22 = 2.;
00024 static integer c__0 = 0;
00025 
00026 /* Subroutine */ int dqrt15_(integer *scale, integer *rksel, integer *m, 
00027         integer *n, integer *nrhs, doublereal *a, integer *lda, doublereal *b, 
00028          integer *ldb, doublereal *s, integer *rank, doublereal *norma, 
00029         doublereal *normb, integer *iseed, doublereal *work, integer *lwork)
00030 {
00031     /* System generated locals */
00032     integer a_dim1, a_offset, b_dim1, b_offset, i__1, i__2;
00033     doublereal d__1;
00034 
00035     /* Local variables */
00036     integer j, mn;
00037     doublereal eps;
00038     integer info;
00039     doublereal temp;
00040     extern doublereal dnrm2_(integer *, doublereal *, integer *);
00041     extern /* Subroutine */ int dscal_(integer *, doublereal *, doublereal *, 
00042             integer *), dlarf_(char *, integer *, integer *, doublereal *, 
00043             integer *, doublereal *, doublereal *, integer *, doublereal *), dgemm_(char *, char *, integer *, integer *, integer *, 
00044             doublereal *, doublereal *, integer *, doublereal *, integer *, 
00045             doublereal *, doublereal *, integer *);
00046     extern doublereal dasum_(integer *, doublereal *, integer *);
00047     doublereal dummy[1];
00048     extern doublereal dlamch_(char *), dlange_(char *, integer *, 
00049             integer *, doublereal *, integer *, doublereal *);
00050     extern /* Subroutine */ int dlascl_(char *, integer *, integer *, 
00051             doublereal *, doublereal *, integer *, integer *, doublereal *, 
00052             integer *, integer *);
00053     extern doublereal dlarnd_(integer *, integer *);
00054     extern /* Subroutine */ int dlaord_(char *, integer *, doublereal *, 
00055             integer *), dlaset_(char *, integer *, integer *, 
00056             doublereal *, doublereal *, doublereal *, integer *), 
00057             xerbla_(char *, integer *);
00058     doublereal bignum;
00059     extern /* Subroutine */ int dlaror_(char *, char *, integer *, integer *, 
00060             doublereal *, integer *, integer *, doublereal *, integer *), dlarnv_(integer *, integer *, integer *, 
00061             doublereal *);
00062     doublereal smlnum;
00063 
00064 
00065 /*  -- LAPACK test routine (version 3.1) -- */
00066 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00067 /*     November 2006 */
00068 
00069 /*     .. Scalar Arguments .. */
00070 /*     .. */
00071 /*     .. Array Arguments .. */
00072 /*     .. */
00073 
00074 /*  Purpose */
00075 /*  ======= */
00076 
00077 /*  DQRT15 generates a matrix with full or deficient rank and of various */
00078 /*  norms. */
00079 
00080 /*  Arguments */
00081 /*  ========= */
00082 
00083 /*  SCALE   (input) INTEGER */
00084 /*          SCALE = 1: normally scaled matrix */
00085 /*          SCALE = 2: matrix scaled up */
00086 /*          SCALE = 3: matrix scaled down */
00087 
00088 /*  RKSEL   (input) INTEGER */
00089 /*          RKSEL = 1: full rank matrix */
00090 /*          RKSEL = 2: rank-deficient matrix */
00091 
00092 /*  M       (input) INTEGER */
00093 /*          The number of rows of the matrix A. */
00094 
00095 /*  N       (input) INTEGER */
00096 /*          The number of columns of A. */
00097 
00098 /*  NRHS    (input) INTEGER */
00099 /*          The number of columns of B. */
00100 
00101 /*  A       (output) DOUBLE PRECISION array, dimension (LDA,N) */
00102 /*          The M-by-N matrix A. */
00103 
00104 /*  LDA     (input) INTEGER */
00105 /*          The leading dimension of the array A. */
00106 
00107 /*  B       (output) DOUBLE PRECISION array, dimension (LDB, NRHS) */
00108 /*          A matrix that is in the range space of matrix A. */
00109 
00110 /*  LDB     (input) INTEGER */
00111 /*          The leading dimension of the array B. */
00112 
00113 /*  S       (output) DOUBLE PRECISION array, dimension MIN(M,N) */
00114 /*          Singular values of A. */
00115 
00116 /*  RANK    (output) INTEGER */
00117 /*          number of nonzero singular values of A. */
00118 
00119 /*  NORMA   (output) DOUBLE PRECISION */
00120 /*          one-norm of A. */
00121 
00122 /*  NORMB   (output) DOUBLE PRECISION */
00123 /*          one-norm of B. */
00124 
00125 /*  ISEED   (input/output) integer array, dimension (4) */
00126 /*          seed for random number generator. */
00127 
00128 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK) */
00129 
00130 /*  LWORK   (input) INTEGER */
00131 /*          length of work space required. */
00132 /*          LWORK >= MAX(M+MIN(M,N),NRHS*MIN(M,N),2*N+M) */
00133 
00134 /*  ===================================================================== */
00135 
00136 /*     .. Parameters .. */
00137 /*     .. */
00138 /*     .. Local Scalars .. */
00139 /*     .. */
00140 /*     .. Local Arrays .. */
00141 /*     .. */
00142 /*     .. External Functions .. */
00143 /*     .. */
00144 /*     .. External Subroutines .. */
00145 /*     .. */
00146 /*     .. Intrinsic Functions .. */
00147 /*     .. */
00148 /*     .. Executable Statements .. */
00149 
00150     /* Parameter adjustments */
00151     a_dim1 = *lda;
00152     a_offset = 1 + a_dim1;
00153     a -= a_offset;
00154     b_dim1 = *ldb;
00155     b_offset = 1 + b_dim1;
00156     b -= b_offset;
00157     --s;
00158     --iseed;
00159     --work;
00160 
00161     /* Function Body */
00162     mn = min(*m,*n);
00163 /* Computing MAX */
00164     i__1 = *m + mn, i__2 = mn * *nrhs, i__1 = max(i__1,i__2), i__2 = (*n << 1)
00165              + *m;
00166     if (*lwork < max(i__1,i__2)) {
00167         xerbla_("DQRT15", &c__16);
00168         return 0;
00169     }
00170 
00171     smlnum = dlamch_("Safe minimum");
00172     bignum = 1. / smlnum;
00173     eps = dlamch_("Epsilon");
00174     smlnum = smlnum / eps / eps;
00175     bignum = 1. / smlnum;
00176 
00177 /*     Determine rank and (unscaled) singular values */
00178 
00179     if (*rksel == 1) {
00180         *rank = mn;
00181     } else if (*rksel == 2) {
00182         *rank = mn * 3 / 4;
00183         i__1 = mn;
00184         for (j = *rank + 1; j <= i__1; ++j) {
00185             s[j] = 0.;
00186 /* L10: */
00187         }
00188     } else {
00189         xerbla_("DQRT15", &c__2);
00190     }
00191 
00192     if (*rank > 0) {
00193 
00194 /*        Nontrivial case */
00195 
00196         s[1] = 1.;
00197         i__1 = *rank;
00198         for (j = 2; j <= i__1; ++j) {
00199 L20:
00200             temp = dlarnd_(&c__1, &iseed[1]);
00201             if (temp > .1) {
00202                 s[j] = abs(temp);
00203             } else {
00204                 goto L20;
00205             }
00206 /* L30: */
00207         }
00208         dlaord_("Decreasing", rank, &s[1], &c__1);
00209 
00210 /*        Generate 'rank' columns of a random orthogonal matrix in A */
00211 
00212         dlarnv_(&c__2, &iseed[1], m, &work[1]);
00213         d__1 = 1. / dnrm2_(m, &work[1], &c__1);
00214         dscal_(m, &d__1, &work[1], &c__1);
00215         dlaset_("Full", m, rank, &c_b18, &c_b19, &a[a_offset], lda)
00216                 ;
00217         dlarf_("Left", m, rank, &work[1], &c__1, &c_b22, &a[a_offset], lda, &
00218                 work[*m + 1]);
00219 
00220 /*        workspace used: m+mn */
00221 
00222 /*        Generate consistent rhs in the range space of A */
00223 
00224         i__1 = *rank * *nrhs;
00225         dlarnv_(&c__2, &iseed[1], &i__1, &work[1]);
00226         dgemm_("No transpose", "No transpose", m, nrhs, rank, &c_b19, &a[
00227                 a_offset], lda, &work[1], rank, &c_b18, &b[b_offset], ldb);
00228 
00229 /*        work space used: <= mn *nrhs */
00230 
00231 /*        generate (unscaled) matrix A */
00232 
00233         i__1 = *rank;
00234         for (j = 1; j <= i__1; ++j) {
00235             dscal_(m, &s[j], &a[j * a_dim1 + 1], &c__1);
00236 /* L40: */
00237         }
00238         if (*rank < *n) {
00239             i__1 = *n - *rank;
00240             dlaset_("Full", m, &i__1, &c_b18, &c_b18, &a[(*rank + 1) * a_dim1 
00241                     + 1], lda);
00242         }
00243         dlaror_("Right", "No initialization", m, n, &a[a_offset], lda, &iseed[
00244                 1], &work[1], &info);
00245 
00246     } else {
00247 
00248 /*        work space used 2*n+m */
00249 
00250 /*        Generate null matrix and rhs */
00251 
00252         i__1 = mn;
00253         for (j = 1; j <= i__1; ++j) {
00254             s[j] = 0.;
00255 /* L50: */
00256         }
00257         dlaset_("Full", m, n, &c_b18, &c_b18, &a[a_offset], lda);
00258         dlaset_("Full", m, nrhs, &c_b18, &c_b18, &b[b_offset], ldb)
00259                 ;
00260 
00261     }
00262 
00263 /*     Scale the matrix */
00264 
00265     if (*scale != 1) {
00266         *norma = dlange_("Max", m, n, &a[a_offset], lda, dummy);
00267         if (*norma != 0.) {
00268             if (*scale == 2) {
00269 
00270 /*              matrix scaled up */
00271 
00272                 dlascl_("General", &c__0, &c__0, norma, &bignum, m, n, &a[
00273                         a_offset], lda, &info);
00274                 dlascl_("General", &c__0, &c__0, norma, &bignum, &mn, &c__1, &
00275                         s[1], &mn, &info);
00276                 dlascl_("General", &c__0, &c__0, norma, &bignum, m, nrhs, &b[
00277                         b_offset], ldb, &info);
00278             } else if (*scale == 3) {
00279 
00280 /*              matrix scaled down */
00281 
00282                 dlascl_("General", &c__0, &c__0, norma, &smlnum, m, n, &a[
00283                         a_offset], lda, &info);
00284                 dlascl_("General", &c__0, &c__0, norma, &smlnum, &mn, &c__1, &
00285                         s[1], &mn, &info);
00286                 dlascl_("General", &c__0, &c__0, norma, &smlnum, m, nrhs, &b[
00287                         b_offset], ldb, &info);
00288             } else {
00289                 xerbla_("DQRT15", &c__1);
00290                 return 0;
00291             }
00292         }
00293     }
00294 
00295     *norma = dasum_(&mn, &s[1], &c__1);
00296     *normb = dlange_("One-norm", m, nrhs, &b[b_offset], ldb, dummy)
00297             ;
00298 
00299     return 0;
00300 
00301 /*     End of DQRT15 */
00302 
00303 } /* dqrt15_ */


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