00001 SUBROUTINE CGGSVP( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
00002 $ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
00003 $ IWORK, RWORK, TAU, WORK, INFO )
00004
00005
00006
00007
00008
00009
00010
00011 CHARACTER JOBQ, JOBU, JOBV
00012 INTEGER INFO, K, L, LDA, LDB, LDQ, LDU, LDV, M, N, P
00013 REAL TOLA, TOLB
00014
00015
00016 INTEGER IWORK( * )
00017 REAL RWORK( * )
00018 COMPLEX A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
00019 $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
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
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 COMPLEX CZERO, CONE
00153 PARAMETER ( CZERO = ( 0.0E+0, 0.0E+0 ),
00154 $ CONE = ( 1.0E+0, 0.0E+0 ) )
00155
00156
00157 LOGICAL FORWRD, WANTQ, WANTU, WANTV
00158 INTEGER I, J
00159 COMPLEX T
00160
00161
00162 LOGICAL LSAME
00163 EXTERNAL LSAME
00164
00165
00166 EXTERNAL CGEQPF, CGEQR2, CGERQ2, CLACPY, CLAPMT, CLASET,
00167 $ CUNG2R, CUNM2R, CUNMR2, XERBLA
00168
00169
00170 INTRINSIC ABS, AIMAG, MAX, MIN, REAL
00171
00172
00173 REAL CABS1
00174
00175
00176 CABS1( T ) = ABS( REAL( T ) ) + ABS( AIMAG( T ) )
00177
00178
00179
00180
00181
00182 WANTU = LSAME( JOBU, 'U' )
00183 WANTV = LSAME( JOBV, 'V' )
00184 WANTQ = LSAME( JOBQ, 'Q' )
00185 FORWRD = .TRUE.
00186
00187 INFO = 0
00188 IF( .NOT.( WANTU .OR. LSAME( JOBU, 'N' ) ) ) THEN
00189 INFO = -1
00190 ELSE IF( .NOT.( WANTV .OR. LSAME( JOBV, 'N' ) ) ) THEN
00191 INFO = -2
00192 ELSE IF( .NOT.( WANTQ .OR. LSAME( JOBQ, 'N' ) ) ) THEN
00193 INFO = -3
00194 ELSE IF( M.LT.0 ) THEN
00195 INFO = -4
00196 ELSE IF( P.LT.0 ) THEN
00197 INFO = -5
00198 ELSE IF( N.LT.0 ) THEN
00199 INFO = -6
00200 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00201 INFO = -8
00202 ELSE IF( LDB.LT.MAX( 1, P ) ) THEN
00203 INFO = -10
00204 ELSE IF( LDU.LT.1 .OR. ( WANTU .AND. LDU.LT.M ) ) THEN
00205 INFO = -16
00206 ELSE IF( LDV.LT.1 .OR. ( WANTV .AND. LDV.LT.P ) ) THEN
00207 INFO = -18
00208 ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
00209 INFO = -20
00210 END IF
00211 IF( INFO.NE.0 ) THEN
00212 CALL XERBLA( 'CGGSVP', -INFO )
00213 RETURN
00214 END IF
00215
00216
00217
00218
00219 DO 10 I = 1, N
00220 IWORK( I ) = 0
00221 10 CONTINUE
00222 CALL CGEQPF( P, N, B, LDB, IWORK, TAU, WORK, RWORK, INFO )
00223
00224
00225
00226 CALL CLAPMT( FORWRD, M, N, A, LDA, IWORK )
00227
00228
00229
00230 L = 0
00231 DO 20 I = 1, MIN( P, N )
00232 IF( CABS1( B( I, I ) ).GT.TOLB )
00233 $ L = L + 1
00234 20 CONTINUE
00235
00236 IF( WANTV ) THEN
00237
00238
00239
00240 CALL CLASET( 'Full', P, P, CZERO, CZERO, V, LDV )
00241 IF( P.GT.1 )
00242 $ CALL CLACPY( 'Lower', P-1, N, B( 2, 1 ), LDB, V( 2, 1 ),
00243 $ LDV )
00244 CALL CUNG2R( P, P, MIN( P, N ), V, LDV, TAU, WORK, INFO )
00245 END IF
00246
00247
00248
00249 DO 40 J = 1, L - 1
00250 DO 30 I = J + 1, L
00251 B( I, J ) = CZERO
00252 30 CONTINUE
00253 40 CONTINUE
00254 IF( P.GT.L )
00255 $ CALL CLASET( 'Full', P-L, N, CZERO, CZERO, B( L+1, 1 ), LDB )
00256
00257 IF( WANTQ ) THEN
00258
00259
00260
00261 CALL CLASET( 'Full', N, N, CZERO, CONE, Q, LDQ )
00262 CALL CLAPMT( FORWRD, N, N, Q, LDQ, IWORK )
00263 END IF
00264
00265 IF( P.GE.L .AND. N.NE.L ) THEN
00266
00267
00268
00269 CALL CGERQ2( L, N, B, LDB, TAU, WORK, INFO )
00270
00271
00272
00273 CALL CUNMR2( 'Right', 'Conjugate transpose', M, N, L, B, LDB,
00274 $ TAU, A, LDA, WORK, INFO )
00275 IF( WANTQ ) THEN
00276
00277
00278
00279 CALL CUNMR2( 'Right', 'Conjugate transpose', N, N, L, B,
00280 $ LDB, TAU, Q, LDQ, WORK, INFO )
00281 END IF
00282
00283
00284
00285 CALL CLASET( 'Full', L, N-L, CZERO, CZERO, B, LDB )
00286 DO 60 J = N - L + 1, N
00287 DO 50 I = J - N + L + 1, L
00288 B( I, J ) = CZERO
00289 50 CONTINUE
00290 60 CONTINUE
00291
00292 END IF
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 DO 70 I = 1, N - L
00303 IWORK( I ) = 0
00304 70 CONTINUE
00305 CALL CGEQPF( M, N-L, A, LDA, IWORK, TAU, WORK, RWORK, INFO )
00306
00307
00308
00309 K = 0
00310 DO 80 I = 1, MIN( M, N-L )
00311 IF( CABS1( A( I, I ) ).GT.TOLA )
00312 $ K = K + 1
00313 80 CONTINUE
00314
00315
00316
00317 CALL CUNM2R( 'Left', 'Conjugate transpose', M, L, MIN( M, N-L ),
00318 $ A, LDA, TAU, A( 1, N-L+1 ), LDA, WORK, INFO )
00319
00320 IF( WANTU ) THEN
00321
00322
00323
00324 CALL CLASET( 'Full', M, M, CZERO, CZERO, U, LDU )
00325 IF( M.GT.1 )
00326 $ CALL CLACPY( 'Lower', M-1, N-L, A( 2, 1 ), LDA, U( 2, 1 ),
00327 $ LDU )
00328 CALL CUNG2R( M, M, MIN( M, N-L ), U, LDU, TAU, WORK, INFO )
00329 END IF
00330
00331 IF( WANTQ ) THEN
00332
00333
00334
00335 CALL CLAPMT( FORWRD, N, N-L, Q, LDQ, IWORK )
00336 END IF
00337
00338
00339
00340
00341 DO 100 J = 1, K - 1
00342 DO 90 I = J + 1, K
00343 A( I, J ) = CZERO
00344 90 CONTINUE
00345 100 CONTINUE
00346 IF( M.GT.K )
00347 $ CALL CLASET( 'Full', M-K, N-L, CZERO, CZERO, A( K+1, 1 ), LDA )
00348
00349 IF( N-L.GT.K ) THEN
00350
00351
00352
00353 CALL CGERQ2( K, N-L, A, LDA, TAU, WORK, INFO )
00354
00355 IF( WANTQ ) THEN
00356
00357
00358
00359 CALL CUNMR2( 'Right', 'Conjugate transpose', N, N-L, K, A,
00360 $ LDA, TAU, Q, LDQ, WORK, INFO )
00361 END IF
00362
00363
00364
00365 CALL CLASET( 'Full', K, N-L-K, CZERO, CZERO, A, LDA )
00366 DO 120 J = N - L - K + 1, N - L
00367 DO 110 I = J - N + L + K + 1, K
00368 A( I, J ) = CZERO
00369 110 CONTINUE
00370 120 CONTINUE
00371
00372 END IF
00373
00374 IF( M.GT.K ) THEN
00375
00376
00377
00378 CALL CGEQR2( M-K, L, A( K+1, N-L+1 ), LDA, TAU, WORK, INFO )
00379
00380 IF( WANTU ) THEN
00381
00382
00383
00384 CALL CUNM2R( 'Right', 'No transpose', M, M-K, MIN( M-K, L ),
00385 $ A( K+1, N-L+1 ), LDA, TAU, U( 1, K+1 ), LDU,
00386 $ WORK, INFO )
00387 END IF
00388
00389
00390
00391 DO 140 J = N - L + 1, N
00392 DO 130 I = J - N + K + L + 1, M
00393 A( I, J ) = CZERO
00394 130 CONTINUE
00395 140 CONTINUE
00396
00397 END IF
00398
00399 RETURN
00400
00401
00402
00403 END