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


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