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


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