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


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