stzrqf.c
Go to the documentation of this file.
00001 /* stzrqf.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 static real c_b8 = 1.f;
00020 
00021 /* Subroutine */ int stzrqf_(integer *m, integer *n, real *a, integer *lda, 
00022         real *tau, integer *info)
00023 {
00024     /* System generated locals */
00025     integer a_dim1, a_offset, i__1, i__2;
00026     real r__1;
00027 
00028     /* Local variables */
00029     integer i__, k, m1;
00030     extern /* Subroutine */ int sger_(integer *, integer *, real *, real *, 
00031             integer *, real *, integer *, real *, integer *), sgemv_(char *, 
00032             integer *, integer *, real *, real *, integer *, real *, integer *
00033 , real *, real *, integer *), scopy_(integer *, real *, 
00034             integer *, real *, integer *), saxpy_(integer *, real *, real *, 
00035             integer *, real *, integer *), xerbla_(char *, integer *),
00036              slarfp_(integer *, real *, real *, integer *, real *);
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 /*  This routine is deprecated and has been replaced by routine STZRZF. */
00052 
00053 /*  STZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A */
00054 /*  to upper triangular form by means of orthogonal transformations. */
00055 
00056 /*  The upper trapezoidal matrix A is factored as */
00057 
00058 /*     A = ( R  0 ) * Z, */
00059 
00060 /*  where Z is an N-by-N orthogonal matrix and R is an M-by-M upper */
00061 /*  triangular matrix. */
00062 
00063 /*  Arguments */
00064 /*  ========= */
00065 
00066 /*  M       (input) INTEGER */
00067 /*          The number of rows of the matrix A.  M >= 0. */
00068 
00069 /*  N       (input) INTEGER */
00070 /*          The number of columns of the matrix A.  N >= M. */
00071 
00072 /*  A       (input/output) REAL array, dimension (LDA,N) */
00073 /*          On entry, the leading M-by-N upper trapezoidal part of the */
00074 /*          array A must contain the matrix to be factorized. */
00075 /*          On exit, the leading M-by-M upper triangular part of A */
00076 /*          contains the upper triangular matrix R, and elements M+1 to */
00077 /*          N of the first M rows of A, with the array TAU, represent the */
00078 /*          orthogonal matrix Z as a product of M elementary reflectors. */
00079 
00080 /*  LDA     (input) INTEGER */
00081 /*          The leading dimension of the array A.  LDA >= max(1,M). */
00082 
00083 /*  TAU     (output) REAL array, dimension (M) */
00084 /*          The scalar factors of the elementary reflectors. */
00085 
00086 /*  INFO    (output) INTEGER */
00087 /*          = 0:  successful exit */
00088 /*          < 0:  if INFO = -i, the i-th argument had an illegal value */
00089 
00090 /*  Further Details */
00091 /*  =============== */
00092 
00093 /*  The factorization is obtained by Householder's method.  The kth */
00094 /*  transformation matrix, Z( k ), which is used to introduce zeros into */
00095 /*  the ( m - k + 1 )th row of A, is given in the form */
00096 
00097 /*     Z( k ) = ( I     0   ), */
00098 /*              ( 0  T( k ) ) */
00099 
00100 /*  where */
00101 
00102 /*     T( k ) = I - tau*u( k )*u( k )',   u( k ) = (   1    ), */
00103 /*                                                 (   0    ) */
00104 /*                                                 ( z( k ) ) */
00105 
00106 /*  tau is a scalar and z( k ) is an ( n - m ) element vector. */
00107 /*  tau and z( k ) are chosen to annihilate the elements of the kth row */
00108 /*  of X. */
00109 
00110 /*  The scalar tau is returned in the kth element of TAU and the vector */
00111 /*  u( k ) in the kth row of A, such that the elements of z( k ) are */
00112 /*  in  a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in */
00113 /*  the upper triangular part of A. */
00114 
00115 /*  Z is given by */
00116 
00117 /*     Z =  Z( 1 ) * Z( 2 ) * ... * Z( m ). */
00118 
00119 /*  ===================================================================== */
00120 
00121 /*     .. Parameters .. */
00122 /*     .. */
00123 /*     .. Local Scalars .. */
00124 /*     .. */
00125 /*     .. Intrinsic Functions .. */
00126 /*     .. */
00127 /*     .. External Subroutines .. */
00128 /*     .. */
00129 /*     .. Executable Statements .. */
00130 
00131 /*     Test the input parameters. */
00132 
00133     /* Parameter adjustments */
00134     a_dim1 = *lda;
00135     a_offset = 1 + a_dim1;
00136     a -= a_offset;
00137     --tau;
00138 
00139     /* Function Body */
00140     *info = 0;
00141     if (*m < 0) {
00142         *info = -1;
00143     } else if (*n < *m) {
00144         *info = -2;
00145     } else if (*lda < max(1,*m)) {
00146         *info = -4;
00147     }
00148     if (*info != 0) {
00149         i__1 = -(*info);
00150         xerbla_("STZRQF", &i__1);
00151         return 0;
00152     }
00153 
00154 /*     Perform the factorization. */
00155 
00156     if (*m == 0) {
00157         return 0;
00158     }
00159     if (*m == *n) {
00160         i__1 = *n;
00161         for (i__ = 1; i__ <= i__1; ++i__) {
00162             tau[i__] = 0.f;
00163 /* L10: */
00164         }
00165     } else {
00166 /* Computing MIN */
00167         i__1 = *m + 1;
00168         m1 = min(i__1,*n);
00169         for (k = *m; k >= 1; --k) {
00170 
00171 /*           Use a Householder reflection to zero the kth row of A. */
00172 /*           First set up the reflection. */
00173 
00174             i__1 = *n - *m + 1;
00175             slarfp_(&i__1, &a[k + k * a_dim1], &a[k + m1 * a_dim1], lda, &tau[
00176                     k]);
00177 
00178             if (tau[k] != 0.f && k > 1) {
00179 
00180 /*              We now perform the operation  A := A*P( k ). */
00181 
00182 /*              Use the first ( k - 1 ) elements of TAU to store  a( k ), */
00183 /*              where  a( k ) consists of the first ( k - 1 ) elements of */
00184 /*              the  kth column  of  A.  Also  let  B  denote  the  first */
00185 /*              ( k - 1 ) rows of the last ( n - m ) columns of A. */
00186 
00187                 i__1 = k - 1;
00188                 scopy_(&i__1, &a[k * a_dim1 + 1], &c__1, &tau[1], &c__1);
00189 
00190 /*              Form   w = a( k ) + B*z( k )  in TAU. */
00191 
00192                 i__1 = k - 1;
00193                 i__2 = *n - *m;
00194                 sgemv_("No transpose", &i__1, &i__2, &c_b8, &a[m1 * a_dim1 + 
00195                         1], lda, &a[k + m1 * a_dim1], lda, &c_b8, &tau[1], &
00196                         c__1);
00197 
00198 /*              Now form  a( k ) := a( k ) - tau*w */
00199 /*              and       B      := B      - tau*w*z( k )'. */
00200 
00201                 i__1 = k - 1;
00202                 r__1 = -tau[k];
00203                 saxpy_(&i__1, &r__1, &tau[1], &c__1, &a[k * a_dim1 + 1], &
00204                         c__1);
00205                 i__1 = k - 1;
00206                 i__2 = *n - *m;
00207                 r__1 = -tau[k];
00208                 sger_(&i__1, &i__2, &r__1, &tau[1], &c__1, &a[k + m1 * a_dim1]
00209 , lda, &a[m1 * a_dim1 + 1], lda);
00210             }
00211 /* L20: */
00212         }
00213     }
00214 
00215     return 0;
00216 
00217 /*     End of STZRQF */
00218 
00219 } /* stzrqf_ */


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