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