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


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