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