sormr2.c
Go to the documentation of this file.
00001 /* sormr2.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 sormr2_(char *side, char *trans, integer *m, integer *n, 
00017         integer *k, real *a, integer *lda, real *tau, real *c__, integer *ldc, 
00018          real *work, integer *info)
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, c_dim1, c_offset, i__1, i__2;
00022 
00023     /* Local variables */
00024     integer i__, i1, i2, i3, mi, ni, nq;
00025     real aii;
00026     logical left;
00027     extern logical lsame_(char *, char *);
00028     extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, 
00029             integer *, real *, real *, integer *, real *), xerbla_(
00030             char *, integer *);
00031     logical notran;
00032 
00033 
00034 /*  -- LAPACK routine (version 3.2) -- */
00035 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00036 /*     November 2006 */
00037 
00038 /*     .. Scalar Arguments .. */
00039 /*     .. */
00040 /*     .. Array Arguments .. */
00041 /*     .. */
00042 
00043 /*  Purpose */
00044 /*  ======= */
00045 
00046 /*  SORMR2 overwrites the general real m by n matrix C with */
00047 
00048 /*        Q * C  if SIDE = 'L' and TRANS = 'N', or */
00049 
00050 /*        Q'* C  if SIDE = 'L' and TRANS = 'T', or */
00051 
00052 /*        C * Q  if SIDE = 'R' and TRANS = 'N', or */
00053 
00054 /*        C * Q' if SIDE = 'R' and TRANS = 'T', */
00055 
00056 /*  where Q is a real orthogonal matrix defined as the product of k */
00057 /*  elementary reflectors */
00058 
00059 /*        Q = H(1) H(2) . . . H(k) */
00060 
00061 /*  as returned by SGERQF. Q is of order m if SIDE = 'L' and of order n */
00062 /*  if SIDE = 'R'. */
00063 
00064 /*  Arguments */
00065 /*  ========= */
00066 
00067 /*  SIDE    (input) CHARACTER*1 */
00068 /*          = 'L': apply Q or Q' from the Left */
00069 /*          = 'R': apply Q or Q' from the Right */
00070 
00071 /*  TRANS   (input) CHARACTER*1 */
00072 /*          = 'N': apply Q  (No transpose) */
00073 /*          = 'T': apply Q' (Transpose) */
00074 
00075 /*  M       (input) INTEGER */
00076 /*          The number of rows of the matrix C. M >= 0. */
00077 
00078 /*  N       (input) INTEGER */
00079 /*          The number of columns of the matrix C. N >= 0. */
00080 
00081 /*  K       (input) INTEGER */
00082 /*          The number of elementary reflectors whose product defines */
00083 /*          the matrix Q. */
00084 /*          If SIDE = 'L', M >= K >= 0; */
00085 /*          if SIDE = 'R', N >= K >= 0. */
00086 
00087 /*  A       (input) REAL array, dimension */
00088 /*                               (LDA,M) if SIDE = 'L', */
00089 /*                               (LDA,N) if SIDE = 'R' */
00090 /*          The i-th row must contain the vector which defines the */
00091 /*          elementary reflector H(i), for i = 1,2,...,k, as returned by */
00092 /*          SGERQF in the last k rows of its array argument A. */
00093 /*          A is modified by the routine but restored on exit. */
00094 
00095 /*  LDA     (input) INTEGER */
00096 /*          The leading dimension of the array A. LDA >= max(1,K). */
00097 
00098 /*  TAU     (input) REAL array, dimension (K) */
00099 /*          TAU(i) must contain the scalar factor of the elementary */
00100 /*          reflector H(i), as returned by SGERQF. */
00101 
00102 /*  C       (input/output) REAL array, dimension (LDC,N) */
00103 /*          On entry, the m by n matrix C. */
00104 /*          On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q. */
00105 
00106 /*  LDC     (input) INTEGER */
00107 /*          The leading dimension of the array C. LDC >= max(1,M). */
00108 
00109 /*  WORK    (workspace) REAL array, dimension */
00110 /*                                   (N) if SIDE = 'L', */
00111 /*                                   (M) if SIDE = 'R' */
00112 
00113 /*  INFO    (output) INTEGER */
00114 /*          = 0: successful exit */
00115 /*          < 0: if INFO = -i, the i-th argument had an illegal value */
00116 
00117 /*  ===================================================================== */
00118 
00119 /*     .. Parameters .. */
00120 /*     .. */
00121 /*     .. Local Scalars .. */
00122 /*     .. */
00123 /*     .. External Functions .. */
00124 /*     .. */
00125 /*     .. External Subroutines .. */
00126 /*     .. */
00127 /*     .. Intrinsic Functions .. */
00128 /*     .. */
00129 /*     .. Executable Statements .. */
00130 
00131 /*     Test the input arguments */
00132 
00133     /* Parameter adjustments */
00134     a_dim1 = *lda;
00135     a_offset = 1 + a_dim1;
00136     a -= a_offset;
00137     --tau;
00138     c_dim1 = *ldc;
00139     c_offset = 1 + c_dim1;
00140     c__ -= c_offset;
00141     --work;
00142 
00143     /* Function Body */
00144     *info = 0;
00145     left = lsame_(side, "L");
00146     notran = lsame_(trans, "N");
00147 
00148 /*     NQ is the order of Q */
00149 
00150     if (left) {
00151         nq = *m;
00152     } else {
00153         nq = *n;
00154     }
00155     if (! left && ! lsame_(side, "R")) {
00156         *info = -1;
00157     } else if (! notran && ! lsame_(trans, "T")) {
00158         *info = -2;
00159     } else if (*m < 0) {
00160         *info = -3;
00161     } else if (*n < 0) {
00162         *info = -4;
00163     } else if (*k < 0 || *k > nq) {
00164         *info = -5;
00165     } else if (*lda < max(1,*k)) {
00166         *info = -7;
00167     } else if (*ldc < max(1,*m)) {
00168         *info = -10;
00169     }
00170     if (*info != 0) {
00171         i__1 = -(*info);
00172         xerbla_("SORMR2", &i__1);
00173         return 0;
00174     }
00175 
00176 /*     Quick return if possible */
00177 
00178     if (*m == 0 || *n == 0 || *k == 0) {
00179         return 0;
00180     }
00181 
00182     if (left && ! notran || ! left && notran) {
00183         i1 = 1;
00184         i2 = *k;
00185         i3 = 1;
00186     } else {
00187         i1 = *k;
00188         i2 = 1;
00189         i3 = -1;
00190     }
00191 
00192     if (left) {
00193         ni = *n;
00194     } else {
00195         mi = *m;
00196     }
00197 
00198     i__1 = i2;
00199     i__2 = i3;
00200     for (i__ = i1; i__2 < 0 ? i__ >= i__1 : i__ <= i__1; i__ += i__2) {
00201         if (left) {
00202 
00203 /*           H(i) is applied to C(1:m-k+i,1:n) */
00204 
00205             mi = *m - *k + i__;
00206         } else {
00207 
00208 /*           H(i) is applied to C(1:m,1:n-k+i) */
00209 
00210             ni = *n - *k + i__;
00211         }
00212 
00213 /*        Apply H(i) */
00214 
00215         aii = a[i__ + (nq - *k + i__) * a_dim1];
00216         a[i__ + (nq - *k + i__) * a_dim1] = 1.f;
00217         slarf_(side, &mi, &ni, &a[i__ + a_dim1], lda, &tau[i__], &c__[
00218                 c_offset], ldc, &work[1]);
00219         a[i__ + (nq - *k + i__) * a_dim1] = aii;
00220 /* L10: */
00221     }
00222     return 0;
00223 
00224 /*     End of SORMR2 */
00225 
00226 } /* sormr2_ */


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