zptts2.c
Go to the documentation of this file.
00001 /* zptts2.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 /* Subroutine */ int zptts2_(integer *iuplo, integer *n, integer *nrhs, 
00017         doublereal *d__, doublecomplex *e, doublecomplex *b, integer *ldb)
00018 {
00019     /* System generated locals */
00020     integer b_dim1, b_offset, i__1, i__2, i__3, i__4, i__5, i__6;
00021     doublereal d__1;
00022     doublecomplex z__1, z__2, z__3, z__4;
00023 
00024     /* Builtin functions */
00025     void d_cnjg(doublecomplex *, doublecomplex *);
00026 
00027     /* Local variables */
00028     integer i__, j;
00029     extern /* Subroutine */ int zdscal_(integer *, doublereal *, 
00030             doublecomplex *, integer *);
00031 
00032 
00033 /*  -- LAPACK routine (version 3.2) -- */
00034 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00035 /*     November 2006 */
00036 
00037 /*     .. Scalar Arguments .. */
00038 /*     .. */
00039 /*     .. Array Arguments .. */
00040 /*     .. */
00041 
00042 /*  Purpose */
00043 /*  ======= */
00044 
00045 /*  ZPTTS2 solves a tridiagonal system of the form */
00046 /*     A * X = B */
00047 /*  using the factorization A = U'*D*U or A = L*D*L' computed by ZPTTRF. */
00048 /*  D is a diagonal matrix specified in the vector D, U (or L) is a unit */
00049 /*  bidiagonal matrix whose superdiagonal (subdiagonal) is specified in */
00050 /*  the vector E, and X and B are N by NRHS matrices. */
00051 
00052 /*  Arguments */
00053 /*  ========= */
00054 
00055 /*  IUPLO   (input) INTEGER */
00056 /*          Specifies the form of the factorization and whether the */
00057 /*          vector E is the superdiagonal of the upper bidiagonal factor */
00058 /*          U or the subdiagonal of the lower bidiagonal factor L. */
00059 /*          = 1:  A = U'*D*U, E is the superdiagonal of U */
00060 /*          = 0:  A = L*D*L', E is the subdiagonal of L */
00061 
00062 /*  N       (input) INTEGER */
00063 /*          The order of the tridiagonal matrix A.  N >= 0. */
00064 
00065 /*  NRHS    (input) INTEGER */
00066 /*          The number of right hand sides, i.e., the number of columns */
00067 /*          of the matrix B.  NRHS >= 0. */
00068 
00069 /*  D       (input) DOUBLE PRECISION array, dimension (N) */
00070 /*          The n diagonal elements of the diagonal matrix D from the */
00071 /*          factorization A = U'*D*U or A = L*D*L'. */
00072 
00073 /*  E       (input) COMPLEX*16 array, dimension (N-1) */
00074 /*          If IUPLO = 1, the (n-1) superdiagonal elements of the unit */
00075 /*          bidiagonal factor U from the factorization A = U'*D*U. */
00076 /*          If IUPLO = 0, the (n-1) subdiagonal elements of the unit */
00077 /*          bidiagonal factor L from the factorization A = L*D*L'. */
00078 
00079 /*  B       (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
00080 /*          On entry, the right hand side vectors B for the system of */
00081 /*          linear equations. */
00082 /*          On exit, the solution vectors, X. */
00083 
00084 /*  LDB     (input) INTEGER */
00085 /*          The leading dimension of the array B.  LDB >= max(1,N). */
00086 
00087 /*  ===================================================================== */
00088 
00089 /*     .. Local Scalars .. */
00090 /*     .. */
00091 /*     .. External Subroutines .. */
00092 /*     .. */
00093 /*     .. Intrinsic Functions .. */
00094 /*     .. */
00095 /*     .. Executable Statements .. */
00096 
00097 /*     Quick return if possible */
00098 
00099     /* Parameter adjustments */
00100     --d__;
00101     --e;
00102     b_dim1 = *ldb;
00103     b_offset = 1 + b_dim1;
00104     b -= b_offset;
00105 
00106     /* Function Body */
00107     if (*n <= 1) {
00108         if (*n == 1) {
00109             d__1 = 1. / d__[1];
00110             zdscal_(nrhs, &d__1, &b[b_offset], ldb);
00111         }
00112         return 0;
00113     }
00114 
00115     if (*iuplo == 1) {
00116 
00117 /*        Solve A * X = B using the factorization A = U'*D*U, */
00118 /*        overwriting each right hand side vector with its solution. */
00119 
00120         if (*nrhs <= 2) {
00121             j = 1;
00122 L10:
00123 
00124 /*           Solve U' * x = b. */
00125 
00126             i__1 = *n;
00127             for (i__ = 2; i__ <= i__1; ++i__) {
00128                 i__2 = i__ + j * b_dim1;
00129                 i__3 = i__ + j * b_dim1;
00130                 i__4 = i__ - 1 + j * b_dim1;
00131                 d_cnjg(&z__3, &e[i__ - 1]);
00132                 z__2.r = b[i__4].r * z__3.r - b[i__4].i * z__3.i, z__2.i = b[
00133                         i__4].r * z__3.i + b[i__4].i * z__3.r;
00134                 z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i - z__2.i;
00135                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00136 /* L20: */
00137             }
00138 
00139 /*           Solve D * U * x = b. */
00140 
00141             i__1 = *n;
00142             for (i__ = 1; i__ <= i__1; ++i__) {
00143                 i__2 = i__ + j * b_dim1;
00144                 i__3 = i__ + j * b_dim1;
00145                 i__4 = i__;
00146                 z__1.r = b[i__3].r / d__[i__4], z__1.i = b[i__3].i / d__[i__4]
00147                         ;
00148                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00149 /* L30: */
00150             }
00151             for (i__ = *n - 1; i__ >= 1; --i__) {
00152                 i__1 = i__ + j * b_dim1;
00153                 i__2 = i__ + j * b_dim1;
00154                 i__3 = i__ + 1 + j * b_dim1;
00155                 i__4 = i__;
00156                 z__2.r = b[i__3].r * e[i__4].r - b[i__3].i * e[i__4].i, 
00157                         z__2.i = b[i__3].r * e[i__4].i + b[i__3].i * e[i__4]
00158                         .r;
00159                 z__1.r = b[i__2].r - z__2.r, z__1.i = b[i__2].i - z__2.i;
00160                 b[i__1].r = z__1.r, b[i__1].i = z__1.i;
00161 /* L40: */
00162             }
00163             if (j < *nrhs) {
00164                 ++j;
00165                 goto L10;
00166             }
00167         } else {
00168             i__1 = *nrhs;
00169             for (j = 1; j <= i__1; ++j) {
00170 
00171 /*              Solve U' * x = b. */
00172 
00173                 i__2 = *n;
00174                 for (i__ = 2; i__ <= i__2; ++i__) {
00175                     i__3 = i__ + j * b_dim1;
00176                     i__4 = i__ + j * b_dim1;
00177                     i__5 = i__ - 1 + j * b_dim1;
00178                     d_cnjg(&z__3, &e[i__ - 1]);
00179                     z__2.r = b[i__5].r * z__3.r - b[i__5].i * z__3.i, z__2.i =
00180                              b[i__5].r * z__3.i + b[i__5].i * z__3.r;
00181                     z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i - z__2.i;
00182                     b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00183 /* L50: */
00184                 }
00185 
00186 /*              Solve D * U * x = b. */
00187 
00188                 i__2 = *n + j * b_dim1;
00189                 i__3 = *n + j * b_dim1;
00190                 i__4 = *n;
00191                 z__1.r = b[i__3].r / d__[i__4], z__1.i = b[i__3].i / d__[i__4]
00192                         ;
00193                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00194                 for (i__ = *n - 1; i__ >= 1; --i__) {
00195                     i__2 = i__ + j * b_dim1;
00196                     i__3 = i__ + j * b_dim1;
00197                     i__4 = i__;
00198                     z__2.r = b[i__3].r / d__[i__4], z__2.i = b[i__3].i / d__[
00199                             i__4];
00200                     i__5 = i__ + 1 + j * b_dim1;
00201                     i__6 = i__;
00202                     z__3.r = b[i__5].r * e[i__6].r - b[i__5].i * e[i__6].i, 
00203                             z__3.i = b[i__5].r * e[i__6].i + b[i__5].i * e[
00204                             i__6].r;
00205                     z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
00206                     b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00207 /* L60: */
00208                 }
00209 /* L70: */
00210             }
00211         }
00212     } else {
00213 
00214 /*        Solve A * X = B using the factorization A = L*D*L', */
00215 /*        overwriting each right hand side vector with its solution. */
00216 
00217         if (*nrhs <= 2) {
00218             j = 1;
00219 L80:
00220 
00221 /*           Solve L * x = b. */
00222 
00223             i__1 = *n;
00224             for (i__ = 2; i__ <= i__1; ++i__) {
00225                 i__2 = i__ + j * b_dim1;
00226                 i__3 = i__ + j * b_dim1;
00227                 i__4 = i__ - 1 + j * b_dim1;
00228                 i__5 = i__ - 1;
00229                 z__2.r = b[i__4].r * e[i__5].r - b[i__4].i * e[i__5].i, 
00230                         z__2.i = b[i__4].r * e[i__5].i + b[i__4].i * e[i__5]
00231                         .r;
00232                 z__1.r = b[i__3].r - z__2.r, z__1.i = b[i__3].i - z__2.i;
00233                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00234 /* L90: */
00235             }
00236 
00237 /*           Solve D * L' * x = b. */
00238 
00239             i__1 = *n;
00240             for (i__ = 1; i__ <= i__1; ++i__) {
00241                 i__2 = i__ + j * b_dim1;
00242                 i__3 = i__ + j * b_dim1;
00243                 i__4 = i__;
00244                 z__1.r = b[i__3].r / d__[i__4], z__1.i = b[i__3].i / d__[i__4]
00245                         ;
00246                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00247 /* L100: */
00248             }
00249             for (i__ = *n - 1; i__ >= 1; --i__) {
00250                 i__1 = i__ + j * b_dim1;
00251                 i__2 = i__ + j * b_dim1;
00252                 i__3 = i__ + 1 + j * b_dim1;
00253                 d_cnjg(&z__3, &e[i__]);
00254                 z__2.r = b[i__3].r * z__3.r - b[i__3].i * z__3.i, z__2.i = b[
00255                         i__3].r * z__3.i + b[i__3].i * z__3.r;
00256                 z__1.r = b[i__2].r - z__2.r, z__1.i = b[i__2].i - z__2.i;
00257                 b[i__1].r = z__1.r, b[i__1].i = z__1.i;
00258 /* L110: */
00259             }
00260             if (j < *nrhs) {
00261                 ++j;
00262                 goto L80;
00263             }
00264         } else {
00265             i__1 = *nrhs;
00266             for (j = 1; j <= i__1; ++j) {
00267 
00268 /*              Solve L * x = b. */
00269 
00270                 i__2 = *n;
00271                 for (i__ = 2; i__ <= i__2; ++i__) {
00272                     i__3 = i__ + j * b_dim1;
00273                     i__4 = i__ + j * b_dim1;
00274                     i__5 = i__ - 1 + j * b_dim1;
00275                     i__6 = i__ - 1;
00276                     z__2.r = b[i__5].r * e[i__6].r - b[i__5].i * e[i__6].i, 
00277                             z__2.i = b[i__5].r * e[i__6].i + b[i__5].i * e[
00278                             i__6].r;
00279                     z__1.r = b[i__4].r - z__2.r, z__1.i = b[i__4].i - z__2.i;
00280                     b[i__3].r = z__1.r, b[i__3].i = z__1.i;
00281 /* L120: */
00282                 }
00283 
00284 /*              Solve D * L' * x = b. */
00285 
00286                 i__2 = *n + j * b_dim1;
00287                 i__3 = *n + j * b_dim1;
00288                 i__4 = *n;
00289                 z__1.r = b[i__3].r / d__[i__4], z__1.i = b[i__3].i / d__[i__4]
00290                         ;
00291                 b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00292                 for (i__ = *n - 1; i__ >= 1; --i__) {
00293                     i__2 = i__ + j * b_dim1;
00294                     i__3 = i__ + j * b_dim1;
00295                     i__4 = i__;
00296                     z__2.r = b[i__3].r / d__[i__4], z__2.i = b[i__3].i / d__[
00297                             i__4];
00298                     i__5 = i__ + 1 + j * b_dim1;
00299                     d_cnjg(&z__4, &e[i__]);
00300                     z__3.r = b[i__5].r * z__4.r - b[i__5].i * z__4.i, z__3.i =
00301                              b[i__5].r * z__4.i + b[i__5].i * z__4.r;
00302                     z__1.r = z__2.r - z__3.r, z__1.i = z__2.i - z__3.i;
00303                     b[i__2].r = z__1.r, b[i__2].i = z__1.i;
00304 /* L130: */
00305                 }
00306 /* L140: */
00307             }
00308         }
00309     }
00310 
00311     return 0;
00312 
00313 /*     End of ZPTTS2 */
00314 
00315 } /* zptts2_ */


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