00001 SUBROUTINE DGGSVP( JOBU, JOBV, JOBQ, M, P, N, A, LDA, B, LDB,
00002 $ TOLA, TOLB, K, L, U, LDU, V, LDV, Q, LDQ,
00003 $ IWORK, 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 DOUBLE PRECISION TOLA, TOLB
00014
00015
00016 INTEGER IWORK( * )
00017 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), Q( LDQ, * ),
00018 $ TAU( * ), U( LDU, * ), V( LDV, * ), WORK( * )
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
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 DOUBLE PRECISION ZERO, ONE
00151 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
00152
00153
00154 LOGICAL FORWRD, WANTQ, WANTU, WANTV
00155 INTEGER I, J
00156
00157
00158 LOGICAL LSAME
00159 EXTERNAL LSAME
00160
00161
00162 EXTERNAL DGEQPF, DGEQR2, DGERQ2, DLACPY, DLAPMT, DLASET,
00163 $ DORG2R, DORM2R, DORMR2, XERBLA
00164
00165
00166 INTRINSIC ABS, MAX, MIN
00167
00168
00169
00170
00171
00172 WANTU = LSAME( JOBU, 'U' )
00173 WANTV = LSAME( JOBV, 'V' )
00174 WANTQ = LSAME( JOBQ, 'Q' )
00175 FORWRD = .TRUE.
00176
00177 INFO = 0
00178 IF( .NOT.( WANTU .OR. LSAME( JOBU, 'N' ) ) ) THEN
00179 INFO = -1
00180 ELSE IF( .NOT.( WANTV .OR. LSAME( JOBV, 'N' ) ) ) THEN
00181 INFO = -2
00182 ELSE IF( .NOT.( WANTQ .OR. LSAME( JOBQ, 'N' ) ) ) THEN
00183 INFO = -3
00184 ELSE IF( M.LT.0 ) THEN
00185 INFO = -4
00186 ELSE IF( P.LT.0 ) THEN
00187 INFO = -5
00188 ELSE IF( N.LT.0 ) THEN
00189 INFO = -6
00190 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
00191 INFO = -8
00192 ELSE IF( LDB.LT.MAX( 1, P ) ) THEN
00193 INFO = -10
00194 ELSE IF( LDU.LT.1 .OR. ( WANTU .AND. LDU.LT.M ) ) THEN
00195 INFO = -16
00196 ELSE IF( LDV.LT.1 .OR. ( WANTV .AND. LDV.LT.P ) ) THEN
00197 INFO = -18
00198 ELSE IF( LDQ.LT.1 .OR. ( WANTQ .AND. LDQ.LT.N ) ) THEN
00199 INFO = -20
00200 END IF
00201 IF( INFO.NE.0 ) THEN
00202 CALL XERBLA( 'DGGSVP', -INFO )
00203 RETURN
00204 END IF
00205
00206
00207
00208
00209 DO 10 I = 1, N
00210 IWORK( I ) = 0
00211 10 CONTINUE
00212 CALL DGEQPF( P, N, B, LDB, IWORK, TAU, WORK, INFO )
00213
00214
00215
00216 CALL DLAPMT( FORWRD, M, N, A, LDA, IWORK )
00217
00218
00219
00220 L = 0
00221 DO 20 I = 1, MIN( P, N )
00222 IF( ABS( B( I, I ) ).GT.TOLB )
00223 $ L = L + 1
00224 20 CONTINUE
00225
00226 IF( WANTV ) THEN
00227
00228
00229
00230 CALL DLASET( 'Full', P, P, ZERO, ZERO, V, LDV )
00231 IF( P.GT.1 )
00232 $ CALL DLACPY( 'Lower', P-1, N, B( 2, 1 ), LDB, V( 2, 1 ),
00233 $ LDV )
00234 CALL DORG2R( P, P, MIN( P, N ), V, LDV, TAU, WORK, INFO )
00235 END IF
00236
00237
00238
00239 DO 40 J = 1, L - 1
00240 DO 30 I = J + 1, L
00241 B( I, J ) = ZERO
00242 30 CONTINUE
00243 40 CONTINUE
00244 IF( P.GT.L )
00245 $ CALL DLASET( 'Full', P-L, N, ZERO, ZERO, B( L+1, 1 ), LDB )
00246
00247 IF( WANTQ ) THEN
00248
00249
00250
00251 CALL DLASET( 'Full', N, N, ZERO, ONE, Q, LDQ )
00252 CALL DLAPMT( FORWRD, N, N, Q, LDQ, IWORK )
00253 END IF
00254
00255 IF( P.GE.L .AND. N.NE.L ) THEN
00256
00257
00258
00259 CALL DGERQ2( L, N, B, LDB, TAU, WORK, INFO )
00260
00261
00262
00263 CALL DORMR2( 'Right', 'Transpose', M, N, L, B, LDB, TAU, A,
00264 $ LDA, WORK, INFO )
00265
00266 IF( WANTQ ) THEN
00267
00268
00269
00270 CALL DORMR2( 'Right', 'Transpose', N, N, L, B, LDB, TAU, Q,
00271 $ LDQ, WORK, INFO )
00272 END IF
00273
00274
00275
00276 CALL DLASET( 'Full', L, N-L, ZERO, ZERO, B, LDB )
00277 DO 60 J = N - L + 1, N
00278 DO 50 I = J - N + L + 1, L
00279 B( I, J ) = ZERO
00280 50 CONTINUE
00281 60 CONTINUE
00282
00283 END IF
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293 DO 70 I = 1, N - L
00294 IWORK( I ) = 0
00295 70 CONTINUE
00296 CALL DGEQPF( M, N-L, A, LDA, IWORK, TAU, WORK, INFO )
00297
00298
00299
00300 K = 0
00301 DO 80 I = 1, MIN( M, N-L )
00302 IF( ABS( A( I, I ) ).GT.TOLA )
00303 $ K = K + 1
00304 80 CONTINUE
00305
00306
00307
00308 CALL DORM2R( 'Left', 'Transpose', M, L, MIN( M, N-L ), A, LDA,
00309 $ TAU, A( 1, N-L+1 ), LDA, WORK, INFO )
00310
00311 IF( WANTU ) THEN
00312
00313
00314
00315 CALL DLASET( 'Full', M, M, ZERO, ZERO, U, LDU )
00316 IF( M.GT.1 )
00317 $ CALL DLACPY( 'Lower', M-1, N-L, A( 2, 1 ), LDA, U( 2, 1 ),
00318 $ LDU )
00319 CALL DORG2R( M, M, MIN( M, N-L ), U, LDU, TAU, WORK, INFO )
00320 END IF
00321
00322 IF( WANTQ ) THEN
00323
00324
00325
00326 CALL DLAPMT( FORWRD, N, N-L, Q, LDQ, IWORK )
00327 END IF
00328
00329
00330
00331
00332 DO 100 J = 1, K - 1
00333 DO 90 I = J + 1, K
00334 A( I, J ) = ZERO
00335 90 CONTINUE
00336 100 CONTINUE
00337 IF( M.GT.K )
00338 $ CALL DLASET( 'Full', M-K, N-L, ZERO, ZERO, A( K+1, 1 ), LDA )
00339
00340 IF( N-L.GT.K ) THEN
00341
00342
00343
00344 CALL DGERQ2( K, N-L, A, LDA, TAU, WORK, INFO )
00345
00346 IF( WANTQ ) THEN
00347
00348
00349
00350 CALL DORMR2( 'Right', 'Transpose', N, N-L, K, A, LDA, TAU,
00351 $ Q, LDQ, WORK, INFO )
00352 END IF
00353
00354
00355
00356 CALL DLASET( 'Full', K, N-L-K, ZERO, ZERO, A, LDA )
00357 DO 120 J = N - L - K + 1, N - L
00358 DO 110 I = J - N + L + K + 1, K
00359 A( I, J ) = ZERO
00360 110 CONTINUE
00361 120 CONTINUE
00362
00363 END IF
00364
00365 IF( M.GT.K ) THEN
00366
00367
00368
00369 CALL DGEQR2( M-K, L, A( K+1, N-L+1 ), LDA, TAU, WORK, INFO )
00370
00371 IF( WANTU ) THEN
00372
00373
00374
00375 CALL DORM2R( 'Right', 'No transpose', M, M-K, MIN( M-K, L ),
00376 $ A( K+1, N-L+1 ), LDA, TAU, U( 1, K+1 ), LDU,
00377 $ WORK, INFO )
00378 END IF
00379
00380
00381
00382 DO 140 J = N - L + 1, N
00383 DO 130 I = J - N + K + L + 1, M
00384 A( I, J ) = ZERO
00385 130 CONTINUE
00386 140 CONTINUE
00387
00388 END IF
00389
00390 RETURN
00391
00392
00393
00394 END