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


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