sopmtr.c
Go to the documentation of this file.
00001 /* sopmtr.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__1 = 1;
00019 
00020 /* Subroutine */ int sopmtr_(char *side, char *uplo, char *trans, integer *m, 
00021         integer *n, real *ap, real *tau, real *c__, integer *ldc, real *work, 
00022         integer *info)
00023 {
00024     /* System generated locals */
00025     integer c_dim1, c_offset, i__1, i__2;
00026 
00027     /* Local variables */
00028     integer i__, i1, i2, i3, ic, jc, ii, mi, ni, nq;
00029     real aii;
00030     logical left;
00031     extern logical lsame_(char *, char *);
00032     extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, 
00033             integer *, real *, real *, integer *, real *);
00034     logical upper;
00035     extern /* Subroutine */ int xerbla_(char *, integer *);
00036     logical notran, forwrd;
00037 
00038 
00039 /*  -- LAPACK routine (version 3.2) -- */
00040 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00041 /*     November 2006 */
00042 
00043 /*     .. Scalar Arguments .. */
00044 /*     .. */
00045 /*     .. Array Arguments .. */
00046 /*     .. */
00047 
00048 /*  Purpose */
00049 /*  ======= */
00050 
00051 /*  SOPMTR overwrites the general real M-by-N matrix C with */
00052 
00053 /*                  SIDE = 'L'     SIDE = 'R' */
00054 /*  TRANS = 'N':      Q * C          C * Q */
00055 /*  TRANS = 'T':      Q**T * C       C * Q**T */
00056 
00057 /*  where Q is a real orthogonal matrix of order nq, with nq = m if */
00058 /*  SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of */
00059 /*  nq-1 elementary reflectors, as returned by SSPTRD using packed */
00060 /*  storage: */
00061 
00062 /*  if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1); */
00063 
00064 /*  if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1). */
00065 
00066 /*  Arguments */
00067 /*  ========= */
00068 
00069 /*  SIDE    (input) CHARACTER*1 */
00070 /*          = 'L': apply Q or Q**T from the Left; */
00071 /*          = 'R': apply Q or Q**T from the Right. */
00072 
00073 /*  UPLO    (input) CHARACTER*1 */
00074 /*          = 'U': Upper triangular packed storage used in previous */
00075 /*                 call to SSPTRD; */
00076 /*          = 'L': Lower triangular packed storage used in previous */
00077 /*                 call to SSPTRD. */
00078 
00079 /*  TRANS   (input) CHARACTER*1 */
00080 /*          = 'N':  No transpose, apply Q; */
00081 /*          = 'T':  Transpose, apply Q**T. */
00082 
00083 /*  M       (input) INTEGER */
00084 /*          The number of rows of the matrix C. M >= 0. */
00085 
00086 /*  N       (input) INTEGER */
00087 /*          The number of columns of the matrix C. N >= 0. */
00088 
00089 /*  AP      (input) REAL array, dimension */
00090 /*                               (M*(M+1)/2) if SIDE = 'L' */
00091 /*                               (N*(N+1)/2) if SIDE = 'R' */
00092 /*          The vectors which define the elementary reflectors, as */
00093 /*          returned by SSPTRD.  AP is modified by the routine but */
00094 /*          restored on exit. */
00095 
00096 /*  TAU     (input) REAL array, dimension (M-1) if SIDE = 'L' */
00097 /*                                     or (N-1) if SIDE = 'R' */
00098 /*          TAU(i) must contain the scalar factor of the elementary */
00099 /*          reflector H(i), as returned by SSPTRD. */
00100 
00101 /*  C       (input/output) REAL array, dimension (LDC,N) */
00102 /*          On entry, the M-by-N matrix C. */
00103 /*          On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q. */
00104 
00105 /*  LDC     (input) INTEGER */
00106 /*          The leading dimension of the array C. LDC >= max(1,M). */
00107 
00108 /*  WORK    (workspace) REAL array, dimension */
00109 /*                                   (N) if SIDE = 'L' */
00110 /*                                   (M) if SIDE = 'R' */
00111 
00112 /*  INFO    (output) INTEGER */
00113 /*          = 0:  successful exit */
00114 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00115 
00116 /*  ===================================================================== */
00117 
00118 /*     .. Parameters .. */
00119 /*     .. */
00120 /*     .. Local Scalars .. */
00121 /*     .. */
00122 /*     .. External Functions .. */
00123 /*     .. */
00124 /*     .. External Subroutines .. */
00125 /*     .. */
00126 /*     .. Intrinsic Functions .. */
00127 /*     .. */
00128 /*     .. Executable Statements .. */
00129 
00130 /*     Test the input arguments */
00131 
00132     /* Parameter adjustments */
00133     --ap;
00134     --tau;
00135     c_dim1 = *ldc;
00136     c_offset = 1 + c_dim1;
00137     c__ -= c_offset;
00138     --work;
00139 
00140     /* Function Body */
00141     *info = 0;
00142     left = lsame_(side, "L");
00143     notran = lsame_(trans, "N");
00144     upper = lsame_(uplo, "U");
00145 
00146 /*     NQ is the order of Q */
00147 
00148     if (left) {
00149         nq = *m;
00150     } else {
00151         nq = *n;
00152     }
00153     if (! left && ! lsame_(side, "R")) {
00154         *info = -1;
00155     } else if (! upper && ! lsame_(uplo, "L")) {
00156         *info = -2;
00157     } else if (! notran && ! lsame_(trans, "T")) {
00158         *info = -3;
00159     } else if (*m < 0) {
00160         *info = -4;
00161     } else if (*n < 0) {
00162         *info = -5;
00163     } else if (*ldc < max(1,*m)) {
00164         *info = -9;
00165     }
00166     if (*info != 0) {
00167         i__1 = -(*info);
00168         xerbla_("SOPMTR", &i__1);
00169         return 0;
00170     }
00171 
00172 /*     Quick return if possible */
00173 
00174     if (*m == 0 || *n == 0) {
00175         return 0;
00176     }
00177 
00178     if (upper) {
00179 
00180 /*        Q was determined by a call to SSPTRD with UPLO = 'U' */
00181 
00182         forwrd = left && notran || ! left && ! notran;
00183 
00184         if (forwrd) {
00185             i1 = 1;
00186             i2 = nq - 1;
00187             i3 = 1;
00188             ii = 2;
00189         } else {
00190             i1 = nq - 1;
00191             i2 = 1;
00192             i3 = -1;
00193             ii = nq * (nq + 1) / 2 - 1;
00194         }
00195 
00196         if (left) {
00197             ni = *n;
00198         } else {
00199             mi = *m;
00200         }
00201 
00202         i__1 = i2;
00203         i__2 = i3;
00204         for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00205             if (left) {
00206 
00207 /*              H(i) is applied to C(1:i,1:n) */
00208 
00209                 mi = i__;
00210             } else {
00211 
00212 /*              H(i) is applied to C(1:m,1:i) */
00213 
00214                 ni = i__;
00215             }
00216 
00217 /*           Apply H(i) */
00218 
00219             aii = ap[ii];
00220             ap[ii] = 1.f;
00221             slarf_(side, &mi, &ni, &ap[ii - i__ + 1], &c__1, &tau[i__], &c__[
00222                     c_offset], ldc, &work[1]);
00223             ap[ii] = aii;
00224 
00225             if (forwrd) {
00226                 ii = ii + i__ + 2;
00227             } else {
00228                 ii = ii - i__ - 1;
00229             }
00230 /* L10: */
00231         }
00232     } else {
00233 
00234 /*        Q was determined by a call to SSPTRD with UPLO = 'L'. */
00235 
00236         forwrd = left && ! notran || ! left && notran;
00237 
00238         if (forwrd) {
00239             i1 = 1;
00240             i2 = nq - 1;
00241             i3 = 1;
00242             ii = 2;
00243         } else {
00244             i1 = nq - 1;
00245             i2 = 1;
00246             i3 = -1;
00247             ii = nq * (nq + 1) / 2 - 1;
00248         }
00249 
00250         if (left) {
00251             ni = *n;
00252             jc = 1;
00253         } else {
00254             mi = *m;
00255             ic = 1;
00256         }
00257 
00258         i__2 = i2;
00259         i__1 = i3;
00260         for (i__ = i1; i__1 < 0 ? i__ >= i__2 : i__ <= i__2; i__ += i__1) {
00261             aii = ap[ii];
00262             ap[ii] = 1.f;
00263             if (left) {
00264 
00265 /*              H(i) is applied to C(i+1:m,1:n) */
00266 
00267                 mi = *m - i__;
00268                 ic = i__ + 1;
00269             } else {
00270 
00271 /*              H(i) is applied to C(1:m,i+1:n) */
00272 
00273                 ni = *n - i__;
00274                 jc = i__ + 1;
00275             }
00276 
00277 /*           Apply H(i) */
00278 
00279             slarf_(side, &mi, &ni, &ap[ii], &c__1, &tau[i__], &c__[ic + jc * 
00280                     c_dim1], ldc, &work[1]);
00281             ap[ii] = aii;
00282 
00283             if (forwrd) {
00284                 ii = ii + nq - i__ + 1;
00285             } else {
00286                 ii = ii - nq + i__ - 2;
00287             }
00288 /* L20: */
00289         }
00290     }
00291     return 0;
00292 
00293 /*     End of SOPMTR */
00294 
00295 } /* sopmtr_ */


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