slarhs.c
Go to the documentation of this file.
00001 /* slarhs.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__2 = 2;
00019 static real c_b32 = 1.f;
00020 static real c_b33 = 0.f;
00021 static integer c__1 = 1;
00022 
00023 /* Subroutine */ int slarhs_(char *path, char *xtype, char *uplo, char *trans, 
00024          integer *m, integer *n, integer *kl, integer *ku, integer *nrhs, 
00025         real *a, integer *lda, real *x, integer *ldx, real *b, integer *ldb, 
00026         integer *iseed, integer *info)
00027 {
00028     /* System generated locals */
00029     integer a_dim1, a_offset, b_dim1, b_offset, x_dim1, x_offset, i__1;
00030 
00031     /* Builtin functions */
00032     /* Subroutine */ int s_copy(char *, char *, ftnlen, ftnlen);
00033 
00034     /* Local variables */
00035     integer j;
00036     char c1[1], c2[2];
00037     integer mb, nx;
00038     logical gen, tri, qrs, sym, band;
00039     char diag[1];
00040     logical tran;
00041     extern logical lsame_(char *, char *);
00042     extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *, 
00043             integer *, real *, real *, integer *, real *, integer *, real *, 
00044             real *, integer *), sgbmv_(char *, integer *, 
00045             integer *, integer *, integer *, real *, real *, integer *, real *
00046 , integer *, real *, real *, integer *), ssbmv_(char *, 
00047             integer *, integer *, real *, real *, integer *, real *, integer *
00048 , real *, real *, integer *), stbmv_(char *, char *, char 
00049             *, integer *, integer *, real *, integer *, real *, integer *), strmm_(char *, char *, char *, char *, 
00050             integer *, integer *, real *, real *, integer *, real *, integer *
00051 ), sspmv_(char *, integer *, real 
00052             *, real *, real *, integer *, real *, real *, integer *), 
00053             ssymm_(char *, char *, integer *, integer *, real *, real *, 
00054             integer *, real *, integer *, real *, real *, integer *), stpmv_(char *, char *, char *, integer *, real *, real *, 
00055              integer *), xerbla_(char *, integer *);
00056     extern logical lsamen_(integer *, char *, char *);
00057     extern /* Subroutine */ int slacpy_(char *, integer *, integer *, real *, 
00058             integer *, real *, integer *);
00059     logical notran;
00060     extern /* Subroutine */ int slarnv_(integer *, integer *, integer *, real 
00061             *);
00062 
00063 
00064 /*  -- LAPACK test routine (version 3.1) -- */
00065 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00066 /*     November 2006 */
00067 
00068 /*     .. Scalar Arguments .. */
00069 /*     .. */
00070 /*     .. Array Arguments .. */
00071 /*     .. */
00072 
00073 /*  Purpose */
00074 /*  ======= */
00075 
00076 /*  SLARHS chooses a set of NRHS random solution vectors and sets */
00077 /*  up the right hand sides for the linear system */
00078 /*     op( A ) * X = B, */
00079 /*  where op( A ) may be A or A' (transpose of A). */
00080 
00081 /*  Arguments */
00082 /*  ========= */
00083 
00084 /*  PATH    (input) CHARACTER*3 */
00085 /*          The type of the real matrix A.  PATH may be given in any */
00086 /*          combination of upper and lower case.  Valid types include */
00087 /*             xGE:  General m x n matrix */
00088 /*             xGB:  General banded matrix */
00089 /*             xPO:  Symmetric positive definite, 2-D storage */
00090 /*             xPP:  Symmetric positive definite packed */
00091 /*             xPB:  Symmetric positive definite banded */
00092 /*             xSY:  Symmetric indefinite, 2-D storage */
00093 /*             xSP:  Symmetric indefinite packed */
00094 /*             xSB:  Symmetric indefinite banded */
00095 /*             xTR:  Triangular */
00096 /*             xTP:  Triangular packed */
00097 /*             xTB:  Triangular banded */
00098 /*             xQR:  General m x n matrix */
00099 /*             xLQ:  General m x n matrix */
00100 /*             xQL:  General m x n matrix */
00101 /*             xRQ:  General m x n matrix */
00102 /*          where the leading character indicates the precision. */
00103 
00104 /*  XTYPE   (input) CHARACTER*1 */
00105 /*          Specifies how the exact solution X will be determined: */
00106 /*          = 'N':  New solution; generate a random X. */
00107 /*          = 'C':  Computed; use value of X on entry. */
00108 
00109 /*  UPLO    (input) CHARACTER*1 */
00110 /*          Specifies whether the upper or lower triangular part of the */
00111 /*          matrix A is stored, if A is symmetric. */
00112 /*          = 'U':  Upper triangular */
00113 /*          = 'L':  Lower triangular */
00114 
00115 /*  TRANS   (input) CHARACTER*1 */
00116 /*          Specifies the operation applied to the matrix A. */
00117 /*          = 'N':  System is  A * x = b */
00118 /*          = 'T':  System is  A'* x = b */
00119 /*          = 'C':  System is  A'* x = b */
00120 
00121 /*  M       (input) INTEGER */
00122 /*          The number or rows of the matrix A.  M >= 0. */
00123 
00124 /*  N       (input) INTEGER */
00125 /*          The number of columns of the matrix A.  N >= 0. */
00126 
00127 /*  KL      (input) INTEGER */
00128 /*          Used only if A is a band matrix; specifies the number of */
00129 /*          subdiagonals of A if A is a general band matrix or if A is */
00130 /*          symmetric or triangular and UPLO = 'L'; specifies the number */
00131 /*          of superdiagonals of A if A is symmetric or triangular and */
00132 /*          UPLO = 'U'.  0 <= KL <= M-1. */
00133 
00134 /*  KU      (input) INTEGER */
00135 /*          Used only if A is a general band matrix or if A is */
00136 /*          triangular. */
00137 
00138 /*          If PATH = xGB, specifies the number of superdiagonals of A, */
00139 /*          and 0 <= KU <= N-1. */
00140 
00141 /*          If PATH = xTR, xTP, or xTB, specifies whether or not the */
00142 /*          matrix has unit diagonal: */
00143 /*          = 1:  matrix has non-unit diagonal (default) */
00144 /*          = 2:  matrix has unit diagonal */
00145 
00146 /*  NRHS    (input) INTEGER */
00147 /*          The number of right hand side vectors in the system A*X = B. */
00148 
00149 /*  A       (input) REAL array, dimension (LDA,N) */
00150 /*          The test matrix whose type is given by PATH. */
00151 
00152 /*  LDA     (input) INTEGER */
00153 /*          The leading dimension of the array A. */
00154 /*          If PATH = xGB, LDA >= KL+KU+1. */
00155 /*          If PATH = xPB, xSB, xHB, or xTB, LDA >= KL+1. */
00156 /*          Otherwise, LDA >= max(1,M). */
00157 
00158 /*  X       (input or output) REAL array, dimension(LDX,NRHS) */
00159 /*          On entry, if XTYPE = 'C' (for 'Computed'), then X contains */
00160 /*          the exact solution to the system of linear equations. */
00161 /*          On exit, if XTYPE = 'N' (for 'New'), then X is initialized */
00162 /*          with random values. */
00163 
00164 /*  LDX     (input) INTEGER */
00165 /*          The leading dimension of the array X.  If TRANS = 'N', */
00166 /*          LDX >= max(1,N); if TRANS = 'T', LDX >= max(1,M). */
00167 
00168 /*  B       (output) REAL array, dimension (LDB,NRHS) */
00169 /*          The right hand side vector(s) for the system of equations, */
00170 /*          computed from B = op(A) * X, where op(A) is determined by */
00171 /*          TRANS. */
00172 
00173 /*  LDB     (input) INTEGER */
00174 /*          The leading dimension of the array B.  If TRANS = 'N', */
00175 /*          LDB >= max(1,M); if TRANS = 'T', LDB >= max(1,N). */
00176 
00177 /*  ISEED   (input/output) INTEGER array, dimension (4) */
00178 /*          The seed vector for the random number generator (used in */
00179 /*          SLATMS).  Modified on exit. */
00180 
00181 /*  INFO    (output) INTEGER */
00182 /*          = 0:  successful exit */
00183 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00184 
00185 /*  ===================================================================== */
00186 
00187 /*     .. Parameters .. */
00188 /*     .. */
00189 /*     .. Local Scalars .. */
00190 /*     .. */
00191 /*     .. External Functions .. */
00192 /*     .. */
00193 /*     .. External Subroutines .. */
00194 /*     .. */
00195 /*     .. Intrinsic Functions .. */
00196 /*     .. */
00197 /*     .. Executable Statements .. */
00198 
00199 /*     Test the input parameters. */
00200 
00201     /* Parameter adjustments */
00202     a_dim1 = *lda;
00203     a_offset = 1 + a_dim1;
00204     a -= a_offset;
00205     x_dim1 = *ldx;
00206     x_offset = 1 + x_dim1;
00207     x -= x_offset;
00208     b_dim1 = *ldb;
00209     b_offset = 1 + b_dim1;
00210     b -= b_offset;
00211     --iseed;
00212 
00213     /* Function Body */
00214     *info = 0;
00215     *(unsigned char *)c1 = *(unsigned char *)path;
00216     s_copy(c2, path + 1, (ftnlen)2, (ftnlen)2);
00217     tran = lsame_(trans, "T") || lsame_(trans, "C");
00218     notran = ! tran;
00219     gen = lsame_(path + 1, "G");
00220     qrs = lsame_(path + 1, "Q") || lsame_(path + 2, 
00221             "Q");
00222     sym = lsame_(path + 1, "P") || lsame_(path + 1, 
00223             "S");
00224     tri = lsame_(path + 1, "T");
00225     band = lsame_(path + 2, "B");
00226     if (! lsame_(c1, "Single precision")) {
00227         *info = -1;
00228     } else if (! (lsame_(xtype, "N") || lsame_(xtype, 
00229             "C"))) {
00230         *info = -2;
00231     } else if ((sym || tri) && ! (lsame_(uplo, "U") || 
00232             lsame_(uplo, "L"))) {
00233         *info = -3;
00234     } else if ((gen || qrs) && ! (tran || lsame_(trans, "N"))) {
00235         *info = -4;
00236     } else if (*m < 0) {
00237         *info = -5;
00238     } else if (*n < 0) {
00239         *info = -6;
00240     } else if (band && *kl < 0) {
00241         *info = -7;
00242     } else if (band && *ku < 0) {
00243         *info = -8;
00244     } else if (*nrhs < 0) {
00245         *info = -9;
00246     } else if (! band && *lda < max(1,*m) || band && (sym || tri) && *lda < *
00247             kl + 1 || band && gen && *lda < *kl + *ku + 1) {
00248         *info = -11;
00249     } else if (notran && *ldx < max(1,*n) || tran && *ldx < max(1,*m)) {
00250         *info = -13;
00251     } else if (notran && *ldb < max(1,*m) || tran && *ldb < max(1,*n)) {
00252         *info = -15;
00253     }
00254     if (*info != 0) {
00255         i__1 = -(*info);
00256         xerbla_("SLARHS", &i__1);
00257         return 0;
00258     }
00259 
00260 /*     Initialize X to NRHS random vectors unless XTYPE = 'C'. */
00261 
00262     if (tran) {
00263         nx = *m;
00264         mb = *n;
00265     } else {
00266         nx = *n;
00267         mb = *m;
00268     }
00269     if (! lsame_(xtype, "C")) {
00270         i__1 = *nrhs;
00271         for (j = 1; j <= i__1; ++j) {
00272             slarnv_(&c__2, &iseed[1], n, &x[j * x_dim1 + 1]);
00273 /* L10: */
00274         }
00275     }
00276 
00277 /*     Multiply X by op( A ) using an appropriate */
00278 /*     matrix multiply routine. */
00279 
00280     if (lsamen_(&c__2, c2, "GE") || lsamen_(&c__2, c2, 
00281             "QR") || lsamen_(&c__2, c2, "LQ") || lsamen_(&c__2, c2, "QL") || 
00282             lsamen_(&c__2, c2, "RQ")) {
00283 
00284 /*        General matrix */
00285 
00286         sgemm_(trans, "N", &mb, nrhs, &nx, &c_b32, &a[a_offset], lda, &x[
00287                 x_offset], ldx, &c_b33, &b[b_offset], ldb);
00288 
00289     } else if (lsamen_(&c__2, c2, "PO") || lsamen_(&
00290             c__2, c2, "SY")) {
00291 
00292 /*        Symmetric matrix, 2-D storage */
00293 
00294         ssymm_("Left", uplo, n, nrhs, &c_b32, &a[a_offset], lda, &x[x_offset], 
00295                  ldx, &c_b33, &b[b_offset], ldb);
00296 
00297     } else if (lsamen_(&c__2, c2, "GB")) {
00298 
00299 /*        General matrix, band storage */
00300 
00301         i__1 = *nrhs;
00302         for (j = 1; j <= i__1; ++j) {
00303             sgbmv_(trans, &mb, &nx, kl, ku, &c_b32, &a[a_offset], lda, &x[j * 
00304                     x_dim1 + 1], &c__1, &c_b33, &b[j * b_dim1 + 1], &c__1);
00305 /* L20: */
00306         }
00307 
00308     } else if (lsamen_(&c__2, c2, "PB")) {
00309 
00310 /*        Symmetric matrix, band storage */
00311 
00312         i__1 = *nrhs;
00313         for (j = 1; j <= i__1; ++j) {
00314             ssbmv_(uplo, n, kl, &c_b32, &a[a_offset], lda, &x[j * x_dim1 + 1], 
00315                      &c__1, &c_b33, &b[j * b_dim1 + 1], &c__1);
00316 /* L30: */
00317         }
00318 
00319     } else if (lsamen_(&c__2, c2, "PP") || lsamen_(&
00320             c__2, c2, "SP")) {
00321 
00322 /*        Symmetric matrix, packed storage */
00323 
00324         i__1 = *nrhs;
00325         for (j = 1; j <= i__1; ++j) {
00326             sspmv_(uplo, n, &c_b32, &a[a_offset], &x[j * x_dim1 + 1], &c__1, &
00327                     c_b33, &b[j * b_dim1 + 1], &c__1);
00328 /* L40: */
00329         }
00330 
00331     } else if (lsamen_(&c__2, c2, "TR")) {
00332 
00333 /*        Triangular matrix.  Note that for triangular matrices, */
00334 /*           KU = 1 => non-unit triangular */
00335 /*           KU = 2 => unit triangular */
00336 
00337         slacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00338         if (*ku == 2) {
00339             *(unsigned char *)diag = 'U';
00340         } else {
00341             *(unsigned char *)diag = 'N';
00342         }
00343         strmm_("Left", uplo, trans, diag, n, nrhs, &c_b32, &a[a_offset], lda, 
00344                 &b[b_offset], ldb)
00345                 ;
00346 
00347     } else if (lsamen_(&c__2, c2, "TP")) {
00348 
00349 /*        Triangular matrix, packed storage */
00350 
00351         slacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00352         if (*ku == 2) {
00353             *(unsigned char *)diag = 'U';
00354         } else {
00355             *(unsigned char *)diag = 'N';
00356         }
00357         i__1 = *nrhs;
00358         for (j = 1; j <= i__1; ++j) {
00359             stpmv_(uplo, trans, diag, n, &a[a_offset], &b[j * b_dim1 + 1], &
00360                     c__1);
00361 /* L50: */
00362         }
00363 
00364     } else if (lsamen_(&c__2, c2, "TB")) {
00365 
00366 /*        Triangular matrix, banded storage */
00367 
00368         slacpy_("Full", n, nrhs, &x[x_offset], ldx, &b[b_offset], ldb);
00369         if (*ku == 2) {
00370             *(unsigned char *)diag = 'U';
00371         } else {
00372             *(unsigned char *)diag = 'N';
00373         }
00374         i__1 = *nrhs;
00375         for (j = 1; j <= i__1; ++j) {
00376             stbmv_(uplo, trans, diag, n, kl, &a[a_offset], lda, &b[j * b_dim1 
00377                     + 1], &c__1);
00378 /* L60: */
00379         }
00380 
00381     } else {
00382 
00383 /*        If PATH is none of the above, return with an error code. */
00384 
00385         *info = -1;
00386         i__1 = -(*info);
00387         xerbla_("SLARHS", &i__1);
00388     }
00389 
00390     return 0;
00391 
00392 /*     End of SLARHS */
00393 
00394 } /* slarhs_ */


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