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


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