slaptm.c
Go to the documentation of this file.
00001 /* slaptm.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 slaptm_(integer *n, integer *nrhs, real *alpha, real *
00017         d__, real *e, real *x, integer *ldx, real *beta, real *b, integer *
00018         ldb)
00019 {
00020     /* System generated locals */
00021     integer b_dim1, b_offset, x_dim1, x_offset, i__1, i__2;
00022 
00023     /* Local variables */
00024     integer i__, j;
00025 
00026 
00027 /*  -- LAPACK auxiliary routine (version 3.1) -- */
00028 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00029 /*     November 2006 */
00030 
00031 /*     .. Scalar Arguments .. */
00032 /*     .. */
00033 /*     .. Array Arguments .. */
00034 /*     .. */
00035 
00036 /*  Purpose */
00037 /*  ======= */
00038 
00039 /*  SLAPTM multiplies an N by NRHS matrix X by a symmetric tridiagonal */
00040 /*  matrix A and stores the result in a matrix B.  The operation has the */
00041 /*  form */
00042 
00043 /*     B := alpha * A * X + beta * B */
00044 
00045 /*  where alpha may be either 1. or -1. and beta may be 0., 1., or -1. */
00046 
00047 /*  Arguments */
00048 /*  ========= */
00049 
00050 /*  N       (input) INTEGER */
00051 /*          The order of the matrix A.  N >= 0. */
00052 
00053 /*  NRHS    (input) INTEGER */
00054 /*          The number of right hand sides, i.e., the number of columns */
00055 /*          of the matrices X and B. */
00056 
00057 /*  ALPHA   (input) REAL */
00058 /*          The scalar alpha.  ALPHA must be 1. or -1.; otherwise, */
00059 /*          it is assumed to be 0. */
00060 
00061 /*  D       (input) REAL array, dimension (N) */
00062 /*          The n diagonal elements of the tridiagonal matrix A. */
00063 
00064 /*  E       (input) REAL array, dimension (N-1) */
00065 /*          The (n-1) subdiagonal or superdiagonal elements of A. */
00066 
00067 /*  X       (input) REAL array, dimension (LDX,NRHS) */
00068 /*          The N by NRHS matrix X. */
00069 
00070 /*  LDX     (input) INTEGER */
00071 /*          The leading dimension of the array X.  LDX >= max(N,1). */
00072 
00073 /*  BETA    (input) REAL */
00074 /*          The scalar beta.  BETA must be 0., 1., or -1.; otherwise, */
00075 /*          it is assumed to be 1. */
00076 
00077 /*  B       (input/output) REAL array, dimension (LDB,NRHS) */
00078 /*          On entry, the N by NRHS matrix B. */
00079 /*          On exit, B is overwritten by the matrix expression */
00080 /*          B := alpha * A * X + beta * B. */
00081 
00082 /*  LDB     (input) INTEGER */
00083 /*          The leading dimension of the array B.  LDB >= max(N,1). */
00084 
00085 /*  ===================================================================== */
00086 
00087 /*     .. Parameters .. */
00088 /*     .. */
00089 /*     .. Local Scalars .. */
00090 /*     .. */
00091 /*     .. Executable Statements .. */
00092 
00093     /* Parameter adjustments */
00094     --d__;
00095     --e;
00096     x_dim1 = *ldx;
00097     x_offset = 1 + x_dim1;
00098     x -= x_offset;
00099     b_dim1 = *ldb;
00100     b_offset = 1 + b_dim1;
00101     b -= b_offset;
00102 
00103     /* Function Body */
00104     if (*n == 0) {
00105         return 0;
00106     }
00107 
00108 /*     Multiply B by BETA if BETA.NE.1. */
00109 
00110     if (*beta == 0.f) {
00111         i__1 = *nrhs;
00112         for (j = 1; j <= i__1; ++j) {
00113             i__2 = *n;
00114             for (i__ = 1; i__ <= i__2; ++i__) {
00115                 b[i__ + j * b_dim1] = 0.f;
00116 /* L10: */
00117             }
00118 /* L20: */
00119         }
00120     } else if (*beta == -1.f) {
00121         i__1 = *nrhs;
00122         for (j = 1; j <= i__1; ++j) {
00123             i__2 = *n;
00124             for (i__ = 1; i__ <= i__2; ++i__) {
00125                 b[i__ + j * b_dim1] = -b[i__ + j * b_dim1];
00126 /* L30: */
00127             }
00128 /* L40: */
00129         }
00130     }
00131 
00132     if (*alpha == 1.f) {
00133 
00134 /*        Compute B := B + A*X */
00135 
00136         i__1 = *nrhs;
00137         for (j = 1; j <= i__1; ++j) {
00138             if (*n == 1) {
00139                 b[j * b_dim1 + 1] += d__[1] * x[j * x_dim1 + 1];
00140             } else {
00141                 b[j * b_dim1 + 1] = b[j * b_dim1 + 1] + d__[1] * x[j * x_dim1 
00142                         + 1] + e[1] * x[j * x_dim1 + 2];
00143                 b[*n + j * b_dim1] = b[*n + j * b_dim1] + e[*n - 1] * x[*n - 
00144                         1 + j * x_dim1] + d__[*n] * x[*n + j * x_dim1];
00145                 i__2 = *n - 1;
00146                 for (i__ = 2; i__ <= i__2; ++i__) {
00147                     b[i__ + j * b_dim1] = b[i__ + j * b_dim1] + e[i__ - 1] * 
00148                             x[i__ - 1 + j * x_dim1] + d__[i__] * x[i__ + j * 
00149                             x_dim1] + e[i__] * x[i__ + 1 + j * x_dim1];
00150 /* L50: */
00151                 }
00152             }
00153 /* L60: */
00154         }
00155     } else if (*alpha == -1.f) {
00156 
00157 /*        Compute B := B - A*X */
00158 
00159         i__1 = *nrhs;
00160         for (j = 1; j <= i__1; ++j) {
00161             if (*n == 1) {
00162                 b[j * b_dim1 + 1] -= d__[1] * x[j * x_dim1 + 1];
00163             } else {
00164                 b[j * b_dim1 + 1] = b[j * b_dim1 + 1] - d__[1] * x[j * x_dim1 
00165                         + 1] - e[1] * x[j * x_dim1 + 2];
00166                 b[*n + j * b_dim1] = b[*n + j * b_dim1] - e[*n - 1] * x[*n - 
00167                         1 + j * x_dim1] - d__[*n] * x[*n + j * x_dim1];
00168                 i__2 = *n - 1;
00169                 for (i__ = 2; i__ <= i__2; ++i__) {
00170                     b[i__ + j * b_dim1] = b[i__ + j * b_dim1] - e[i__ - 1] * 
00171                             x[i__ - 1 + j * x_dim1] - d__[i__] * x[i__ + j * 
00172                             x_dim1] - e[i__] * x[i__ + 1 + j * x_dim1];
00173 /* L70: */
00174                 }
00175             }
00176 /* L80: */
00177         }
00178     }
00179     return 0;
00180 
00181 /*     End of SLAPTM */
00182 
00183 } /* slaptm_ */


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