00001 /* sgeqr2.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 sgeqr2_(integer *m, integer *n, real *a, integer *lda, 00021 real *tau, real *work, integer *info) 00022 { 00023 /* System generated locals */ 00024 integer a_dim1, a_offset, i__1, i__2, i__3; 00025 00026 /* Local variables */ 00027 integer i__, k; 00028 real aii; 00029 extern /* Subroutine */ int slarf_(char *, integer *, integer *, real *, 00030 integer *, real *, real *, integer *, real *), xerbla_( 00031 char *, integer *), slarfp_(integer *, real *, real *, 00032 integer *, real *); 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 /* SGEQR2 computes a QR factorization of a real m by n matrix A: */ 00048 /* A = Q * R. */ 00049 00050 /* Arguments */ 00051 /* ========= */ 00052 00053 /* M (input) INTEGER */ 00054 /* The number of rows of the matrix A. M >= 0. */ 00055 00056 /* N (input) INTEGER */ 00057 /* The number of columns of the matrix A. N >= 0. */ 00058 00059 /* A (input/output) REAL array, dimension (LDA,N) */ 00060 /* On entry, the m by n matrix A. */ 00061 /* On exit, the elements on and above the diagonal of the array */ 00062 /* contain the min(m,n) by n upper trapezoidal matrix R (R is */ 00063 /* upper triangular if m >= n); the elements below the diagonal, */ 00064 /* with the array TAU, represent the orthogonal matrix Q as a */ 00065 /* product of elementary reflectors (see Further Details). */ 00066 00067 /* LDA (input) INTEGER */ 00068 /* The leading dimension of the array A. LDA >= max(1,M). */ 00069 00070 /* TAU (output) REAL array, dimension (min(M,N)) */ 00071 /* The scalar factors of the elementary reflectors (see Further */ 00072 /* Details). */ 00073 00074 /* WORK (workspace) REAL array, dimension (N) */ 00075 00076 /* INFO (output) INTEGER */ 00077 /* = 0: successful exit */ 00078 /* < 0: if INFO = -i, the i-th argument had an illegal value */ 00079 00080 /* Further Details */ 00081 /* =============== */ 00082 00083 /* The matrix Q is represented as a product of elementary reflectors */ 00084 00085 /* Q = H(1) H(2) . . . H(k), where k = min(m,n). */ 00086 00087 /* Each H(i) has the form */ 00088 00089 /* H(i) = I - tau * v * v' */ 00090 00091 /* where tau is a real scalar, and v is a real vector with */ 00092 /* v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i), */ 00093 /* and tau in TAU(i). */ 00094 00095 /* ===================================================================== */ 00096 00097 /* .. Parameters .. */ 00098 /* .. */ 00099 /* .. Local Scalars .. */ 00100 /* .. */ 00101 /* .. External Subroutines .. */ 00102 /* .. */ 00103 /* .. Intrinsic Functions .. */ 00104 /* .. */ 00105 /* .. Executable Statements .. */ 00106 00107 /* Test the input arguments */ 00108 00109 /* Parameter adjustments */ 00110 a_dim1 = *lda; 00111 a_offset = 1 + a_dim1; 00112 a -= a_offset; 00113 --tau; 00114 --work; 00115 00116 /* Function Body */ 00117 *info = 0; 00118 if (*m < 0) { 00119 *info = -1; 00120 } else if (*n < 0) { 00121 *info = -2; 00122 } else if (*lda < max(1,*m)) { 00123 *info = -4; 00124 } 00125 if (*info != 0) { 00126 i__1 = -(*info); 00127 xerbla_("SGEQR2", &i__1); 00128 return 0; 00129 } 00130 00131 k = min(*m,*n); 00132 00133 i__1 = k; 00134 for (i__ = 1; i__ <= i__1; ++i__) { 00135 00136 /* Generate elementary reflector H(i) to annihilate A(i+1:m,i) */ 00137 00138 i__2 = *m - i__ + 1; 00139 /* Computing MIN */ 00140 i__3 = i__ + 1; 00141 slarfp_(&i__2, &a[i__ + i__ * a_dim1], &a[min(i__3, *m)+ i__ * a_dim1] 00142 , &c__1, &tau[i__]); 00143 if (i__ < *n) { 00144 00145 /* Apply H(i) to A(i:m,i+1:n) from the left */ 00146 00147 aii = a[i__ + i__ * a_dim1]; 00148 a[i__ + i__ * a_dim1] = 1.f; 00149 i__2 = *m - i__ + 1; 00150 i__3 = *n - i__; 00151 slarf_("Left", &i__2, &i__3, &a[i__ + i__ * a_dim1], &c__1, &tau[ 00152 i__], &a[i__ + (i__ + 1) * a_dim1], lda, &work[1]); 00153 a[i__ + i__ * a_dim1] = aii; 00154 } 00155 /* L10: */ 00156 } 00157 return 0; 00158 00159 /* End of SGEQR2 */ 00160 00161 } /* sgeqr2_ */