00001 DOUBLE PRECISION FUNCTION ZQRT14( TRANS, M, N, NRHS, A, LDA, X,
00002 $ LDX, WORK, LWORK )
00003
00004
00005
00006
00007
00008
00009 CHARACTER TRANS
00010 INTEGER LDA, LDX, LWORK, M, N, NRHS
00011
00012
00013 COMPLEX*16 A( LDA, * ), WORK( LWORK ), X( LDX, * )
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 DOUBLE PRECISION ZERO, ONE
00067 PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
00068
00069
00070 LOGICAL TPSD
00071 INTEGER I, INFO, J, LDWORK
00072 DOUBLE PRECISION ANRM, ERR, XNRM
00073
00074
00075 DOUBLE PRECISION RWORK( 1 )
00076
00077
00078 LOGICAL LSAME
00079 DOUBLE PRECISION DLAMCH, ZLANGE
00080 EXTERNAL LSAME, DLAMCH, ZLANGE
00081
00082
00083 EXTERNAL XERBLA, ZGELQ2, ZGEQR2, ZLACPY, ZLASCL
00084
00085
00086 INTRINSIC ABS, DBLE, DCONJG, MAX, MIN
00087
00088
00089
00090 ZQRT14 = ZERO
00091 IF( LSAME( TRANS, 'N' ) ) THEN
00092 LDWORK = M + NRHS
00093 TPSD = .FALSE.
00094 IF( LWORK.LT.( M+NRHS )*( N+2 ) ) THEN
00095 CALL XERBLA( 'ZQRT14', 10 )
00096 RETURN
00097 ELSE IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
00098 RETURN
00099 END IF
00100 ELSE IF( LSAME( TRANS, 'C' ) ) THEN
00101 LDWORK = M
00102 TPSD = .TRUE.
00103 IF( LWORK.LT.( N+NRHS )*( M+2 ) ) THEN
00104 CALL XERBLA( 'ZQRT14', 10 )
00105 RETURN
00106 ELSE IF( M.LE.0 .OR. NRHS.LE.0 ) THEN
00107 RETURN
00108 END IF
00109 ELSE
00110 CALL XERBLA( 'ZQRT14', 1 )
00111 RETURN
00112 END IF
00113
00114
00115
00116 CALL ZLACPY( 'All', M, N, A, LDA, WORK, LDWORK )
00117 ANRM = ZLANGE( 'M', M, N, WORK, LDWORK, RWORK )
00118 IF( ANRM.NE.ZERO )
00119 $ CALL ZLASCL( 'G', 0, 0, ANRM, ONE, M, N, WORK, LDWORK, INFO )
00120
00121
00122
00123 IF( TPSD ) THEN
00124
00125
00126
00127 CALL ZLACPY( 'All', M, NRHS, X, LDX, WORK( N*LDWORK+1 ),
00128 $ LDWORK )
00129 XNRM = ZLANGE( 'M', M, NRHS, WORK( N*LDWORK+1 ), LDWORK,
00130 $ RWORK )
00131 IF( XNRM.NE.ZERO )
00132 $ CALL ZLASCL( 'G', 0, 0, XNRM, ONE, M, NRHS,
00133 $ WORK( N*LDWORK+1 ), LDWORK, INFO )
00134 ANRM = ZLANGE( 'One-norm', M, N+NRHS, WORK, LDWORK, RWORK )
00135
00136
00137
00138 CALL ZGEQR2( M, N+NRHS, WORK, LDWORK,
00139 $ WORK( LDWORK*( N+NRHS )+1 ),
00140 $ WORK( LDWORK*( N+NRHS )+MIN( M, N+NRHS )+1 ),
00141 $ INFO )
00142
00143
00144
00145
00146 ERR = ZERO
00147 DO 20 J = N + 1, N + NRHS
00148 DO 10 I = N + 1, MIN( M, J )
00149 ERR = MAX( ERR, ABS( WORK( I+( J-1 )*M ) ) )
00150 10 CONTINUE
00151 20 CONTINUE
00152
00153 ELSE
00154
00155
00156
00157 DO 40 I = 1, N
00158 DO 30 J = 1, NRHS
00159 WORK( M+J+( I-1 )*LDWORK ) = DCONJG( X( I, J ) )
00160 30 CONTINUE
00161 40 CONTINUE
00162
00163 XNRM = ZLANGE( 'M', NRHS, N, WORK( M+1 ), LDWORK, RWORK )
00164 IF( XNRM.NE.ZERO )
00165 $ CALL ZLASCL( 'G', 0, 0, XNRM, ONE, NRHS, N, WORK( M+1 ),
00166 $ LDWORK, INFO )
00167
00168
00169
00170 CALL ZGELQ2( LDWORK, N, WORK, LDWORK, WORK( LDWORK*N+1 ),
00171 $ WORK( LDWORK*( N+1 )+1 ), INFO )
00172
00173
00174
00175
00176 ERR = ZERO
00177 DO 60 J = M + 1, N
00178 DO 50 I = J, LDWORK
00179 ERR = MAX( ERR, ABS( WORK( I+( J-1 )*LDWORK ) ) )
00180 50 CONTINUE
00181 60 CONTINUE
00182
00183 END IF
00184
00185 ZQRT14 = ERR / ( DBLE( MAX( M, N, NRHS ) )*DLAMCH( 'Epsilon' ) )
00186
00187 RETURN
00188
00189
00190
00191 END