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


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