numeric-linalg
Educational material on the SciPy implementation of numerical linear algebra algorithms
Name | Size | Mode | |
.. | |||
lapack/TESTING/LIN/cqpt01.f | 5539B | -rw-r--r-- |
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
*> \brief \b CQPT01 * * =========== DOCUMENTATION =========== * * Online html documentation available at * http://www.netlib.org/lapack/explore-html/ * * Definition: * =========== * * REAL FUNCTION CQPT01( M, N, K, A, AF, LDA, TAU, JPVT, * WORK, LWORK ) * * .. Scalar Arguments .. * INTEGER K, LDA, LWORK, M, N * .. * .. Array Arguments .. * INTEGER JPVT( * ) * COMPLEX A( LDA, * ), AF( LDA, * ), TAU( * ), * $ WORK( LWORK ) * .. * * *> \par Purpose: * ============= *> *> \verbatim *> *> CQPT01 tests the QR-factorization with pivoting of a matrix A. The *> array AF contains the (possibly partial) QR-factorization of A, where *> the upper triangle of AF(1:k,1:k) is a partial triangular factor, *> the entries below the diagonal in the first k columns are the *> Householder vectors, and the rest of AF contains a partially updated *> matrix. *> *> This function returns ||A*P - Q*R|| / ( ||norm(A)||*eps*max(M,N) ) *> where || . || is matrix one norm. *> \endverbatim * * Arguments: * ========== * *> \param[in] M *> \verbatim *> M is INTEGER *> The number of rows of the matrices A and AF. *> \endverbatim *> *> \param[in] N *> \verbatim *> N is INTEGER *> The number of columns of the matrices A and AF. *> \endverbatim *> *> \param[in] K *> \verbatim *> K is INTEGER *> The number of columns of AF that have been reduced *> to upper triangular form. *> \endverbatim *> *> \param[in] A *> \verbatim *> A is COMPLEX array, dimension (LDA, N) *> The original matrix A. *> \endverbatim *> *> \param[in] AF *> \verbatim *> AF is COMPLEX array, dimension (LDA,N) *> The (possibly partial) output of CGEQPF. The upper triangle *> of AF(1:k,1:k) is a partial triangular factor, the entries *> below the diagonal in the first k columns are the Householder *> vectors, and the rest of AF contains a partially updated *> matrix. *> \endverbatim *> *> \param[in] LDA *> \verbatim *> LDA is INTEGER *> The leading dimension of the arrays A and AF. *> \endverbatim *> *> \param[in] TAU *> \verbatim *> TAU is COMPLEX array, dimension (K) *> Details of the Householder transformations as returned by *> CGEQPF. *> \endverbatim *> *> \param[in] JPVT *> \verbatim *> JPVT is INTEGER array, dimension (N) *> Pivot information as returned by CGEQPF. *> \endverbatim *> *> \param[out] WORK *> \verbatim *> WORK is COMPLEX array, dimension (LWORK) *> \endverbatim *> *> \param[in] LWORK *> \verbatim *> LWORK is INTEGER *> The length of the array WORK. LWORK >= M*N+N. *> \endverbatim * * Authors: * ======== * *> \author Univ. of Tennessee *> \author Univ. of California Berkeley *> \author Univ. of Colorado Denver *> \author NAG Ltd. * *> \ingroup complex_lin * * ===================================================================== REAL FUNCTION CQPT01( M, N, K, A, AF, LDA, TAU, JPVT, $ WORK, LWORK ) * * -- LAPACK test routine -- * -- LAPACK is a software package provided by Univ. of Tennessee, -- * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- * * .. Scalar Arguments .. INTEGER K, LDA, LWORK, M, N * .. * .. Array Arguments .. INTEGER JPVT( * ) COMPLEX A( LDA, * ), AF( LDA, * ), TAU( * ), $ WORK( LWORK ) * .. * * ===================================================================== * * .. Parameters .. REAL ZERO, ONE PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 ) * .. * .. Local Scalars .. INTEGER I, INFO, J REAL NORMA * .. * .. Local Arrays .. REAL RWORK( 1 ) * .. * .. External Functions .. REAL CLANGE, SLAMCH EXTERNAL CLANGE, SLAMCH * .. * .. External Subroutines .. EXTERNAL CAXPY, CCOPY, CUNMQR, XERBLA * .. * .. Intrinsic Functions .. INTRINSIC CMPLX, MAX, MIN, REAL * .. * .. Executable Statements .. * CQPT01 = ZERO * * Test if there is enough workspace * IF( LWORK.LT.M*N+N ) THEN CALL XERBLA( 'CQPT01', 10 ) RETURN END IF * * Quick return if possible * IF( M.LE.0 .OR. N.LE.0 ) $ RETURN * NORMA = CLANGE( 'One-norm', M, N, A, LDA, RWORK ) * DO J = 1, K DO I = 1, MIN( J, M ) WORK( ( J-1 )*M+I ) = AF( I, J ) END DO DO I = J + 1, M WORK( ( J-1 )*M+I ) = ZERO END DO END DO DO J = K + 1, N CALL CCOPY( M, AF( 1, J ), 1, WORK( ( J-1 )*M+1 ), 1 ) END DO * CALL CUNMQR( 'Left', 'No transpose', M, N, K, AF, LDA, TAU, WORK, $ M, WORK( M*N+1 ), LWORK-M*N, INFO ) * DO J = 1, N * * Compare i-th column of QR and jpvt(i)-th column of A * CALL CAXPY( M, CMPLX( -ONE ), A( 1, JPVT( J ) ), 1, $ WORK( ( J-1 )*M+1 ), 1 ) END DO * CQPT01 = CLANGE( 'One-norm', M, N, WORK, M, RWORK ) / $ ( REAL( MAX( M, N ) )*SLAMCH( 'Epsilon' ) ) IF( NORMA.NE.ZERO ) $ CQPT01 = CQPT01 / NORMA * RETURN * * End of CQPT01 * END