1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
|
SUBROUTINE MB04PB( N, ILO, A, LDA, QG, LDQG, CS, TAU, DWORK,
$ LDWORK, INFO )
C
C SLICOT RELEASE 5.0.
C
C Copyright (c) 2002-2009 NICONET e.V.
C
C This program is free software: you can redistribute it and/or
C modify it under the terms of the GNU General Public License as
C published by the Free Software Foundation, either version 2 of
C the License, or (at your option) any later version.
C
C This program is distributed in the hope that it will be useful,
C but WITHOUT ANY WARRANTY; without even the implied warranty of
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
C GNU General Public License for more details.
C
C You should have received a copy of the GNU General Public License
C along with this program. If not, see
C <http://www.gnu.org/licenses/>.
C
C PURPOSE
C
C To reduce a Hamiltonian matrix,
C
C [ A G ]
C H = [ T ] ,
C [ Q -A ]
C
C where A is an N-by-N matrix and G,Q are N-by-N symmetric matrices,
C to Paige/Van Loan (PVL) form. That is, an orthogonal symplectic U
C is computed so that
C
C T [ Aout Gout ]
C U H U = [ T ] ,
C [ Qout -Aout ]
C
C where Aout is upper Hessenberg and Qout is diagonal.
C Blocked version.
C
C ARGUMENTS
C
C Input/Output Parameters
C
C N (input) INTEGER
C The order of the matrix A. N >= 0.
C
C ILO (input) INTEGER
C It is assumed that A is already upper triangular and Q is
C zero in rows and columns 1:ILO-1. ILO is normally set by a
C previous call to MB04DD; otherwise it should be set to 1.
C 1 <= ILO <= N, if N > 0; ILO = 1, if N = 0.
C
C A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
C On entry, the leading N-by-N part of this array must
C contain the matrix A.
C On exit, the leading N-by-N part of this array contains
C the matrix Aout and, in the zero part of Aout,
C information about the elementary reflectors used to
C compute the PVL factorization.
C
C LDA INTEGER
C The leading dimension of the array A. LDA >= MAX(1,N).
C
C QG (input/output) DOUBLE PRECISION array, dimension
C (LDQG,N+1)
C On entry, the leading N-by-N+1 part of this array must
C contain the lower triangular part of the matrix Q and
C the upper triangular part of the matrix G.
C On exit, the leading N-by-N+1 part of this array contains
C the diagonal of the matrix Qout, the upper triangular part
C of the matrix Gout and, in the zero parts of Qout,
C information about the elementary reflectors used to
C compute the PVL factorization.
C
C LDQG INTEGER
C The leading dimension of the array QG. LDQG >= MAX(1,N).
C
C CS (output) DOUBLE PRECISION array, dimension (2N-2)
C On exit, the first 2N-2 elements of this array contain the
C cosines and sines of the symplectic Givens rotations used
C to compute the PVL factorization.
C
C TAU (output) DOUBLE PRECISION array, dimension (N-1)
C On exit, the first N-1 elements of this array contain the
C scalar factors of some of the elementary reflectors.
C
C Workspace
C
C DWORK DOUBLE PRECISION array, dimension (LDWORK)
C On exit, if INFO = 0, DWORK(1) returns the optimal
C value of LDWORK, 8*N*NB + 3*NB, where NB is the optimal
C block size determined by the function UE01MD.
C On exit, if INFO = -10, DWORK(1) returns the minimum
C value of LDWORK.
C
C LDWORK INTEGER
C The length of the array DWORK. LDWORK >= MAX(1,N-1).
C
C Error Indicator
C
C INFO INTEGER
C = 0: successful exit;
C < 0: if INFO = -i, the i-th argument had an illegal
C value.
C
C METHOD
C
C The matrix U is represented as a product of symplectic reflectors
C and Givens rotators
C
C U = diag( H(1),H(1) ) G(1) diag( F(1),F(1) )
C diag( H(2),H(2) ) G(2) diag( F(2),F(2) )
C ....
C diag( H(n-1),H(n-1) ) G(n-1) diag( F(n-1),F(n-1) ).
C
C Each H(i) has the form
C
C H(i) = I - tau * v * v'
C
C where tau is a real scalar, and v is a real vector with
C v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in
C QG(i+2:n,i), and tau in QG(i+1,i).
C
C Each F(i) has the form
C
C F(i) = I - nu * w * w'
C
C where nu is a real scalar, and w is a real vector with
C w(1:i) = 0 and w(i+1) = 1; w(i+2:n) is stored on exit in
C A(i+2:n,i), and nu in TAU(i).
C
C Each G(i) is a Givens rotator acting on rows i+1 and n+i+1,
C where the cosine is stored in CS(2*i-1) and the sine in
C CS(2*i).
C
C NUMERICAL ASPECTS
C
C The algorithm requires O(N**3) floating point operations and is
C strongly backward stable.
C
C REFERENCES
C
C [1] C. F. VAN LOAN:
C A symplectic method for approximating all the eigenvalues of
C a Hamiltonian matrix.
C Linear Algebra and its Applications, 61, pp. 233-251, 1984.
C
C [2] D. KRESSNER:
C Block algorithms for orthogonal symplectic factorizations.
C BIT, 43 (4), pp. 775-790, 2003.
C
C CONTRIBUTORS
C
C D. Kressner (Technical Univ. Berlin, Germany) and
C P. Benner (Technical Univ. Chemnitz, Germany), December 2003.
C
C REVISIONS
C
C V. Sima, Nov. 2008 (SLICOT version of the HAPACK routine DHAPVB).
C
C KEYWORDS
C
C Elementary matrix operations, Hamiltonian matrix.
C
C ******************************************************************
C
C .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0D0, ONE = 1.0D0 )
C .. Scalar Arguments ..
INTEGER ILO, INFO, LDA, LDQG, LDWORK, N
C .. Array Arguments ..
DOUBLE PRECISION A(LDA,*), CS(*), DWORK(*), QG(LDQG,*), TAU(*)
C .. Local Scalars ..
INTEGER I, IB, IERR, NB, NBMIN, NH, NIB, NNB, NX, PDW,
$ PXA, PXG, PXQ, PYA, WRKOPT
C .. External Functions ..
INTEGER UE01MD
EXTERNAL UE01MD
C .. External Subroutines ..
EXTERNAL DGEMM, DSYR2K, MB04PA, MB04PU, XERBLA
C .. Intrinsic Functions ..
INTRINSIC DBLE, MAX, MIN
C
C .. Executable Statements ..
C
C Check the scalar input parameters.
C
INFO = 0
IF ( N.LT.0 ) THEN
INFO = -1
ELSE IF ( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THEN
INFO = -2
ELSE IF ( LDA.LT.MAX( 1, N ) ) THEN
INFO = -4
ELSE IF ( LDQG.LT.MAX( 1, N ) ) THEN
INFO = -6
ELSE IF ( LDWORK.LT.MAX( 1, N-1 ) ) THEN
DWORK(1) = DBLE( MAX( 1, N-1 ) )
INFO = -10
END IF
C
C Return if there were illegal values.
C
IF ( INFO.NE.0 ) THEN
CALL XERBLA( 'MB04PB', -INFO )
RETURN
END IF
C
C Set elements 1:ILO-1 of TAU and CS.
C
DO 10 I = 1, ILO - 1
TAU( I ) = ZERO
CS(2*I-1) = ONE
CS(2*I) = ZERO
10 CONTINUE
C
C Quick return if possible.
C
IF ( N.LE.ILO ) THEN
DWORK(1) = ONE
RETURN
END IF
C
C Determine the block size.
C
NH = N - ILO + 1
NB = UE01MD( 1, 'MB04PB', ' ', N, ILO, -1 )
NBMIN = 2
WRKOPT = N-1
IF ( NB.GT.1 .AND. NB.LT.NH ) THEN
C
C Determine when to cross over from blocked to unblocked code.
C
NX = MAX( NB, UE01MD( 3, 'MB04PB', ' ', N, ILO, -1 ) )
IF ( NX.LT.NH ) THEN
C
C Check whether workspace is large enough for blocked code.
C
WRKOPT = 8*N*NB + 3*NB
IF ( LDWORK.LT.WRKOPT ) THEN
C
C Not enough workspace available. Determine minimum value
C of NB, and reduce NB.
C
NBMIN = MAX( 2, UE01MD( 2, 'MB04PB', ' ', N, ILO, -1 ) )
NB = LDWORK / ( 8*N + 3 )
END IF
END IF
END IF
C
NNB = N*NB
PXA = 1
PYA = PXA + 2*NNB
PXQ = PYA + 2*NNB
PXG = PXQ + 2*NNB
PDW = PXG + 2*NNB
C
IF ( NB.LT.NBMIN .OR. NB.GE.NH ) THEN
C
C Use unblocked code.
C
I = ILO
C
ELSE
DO 20 I = ILO, N-NX-1, NB
IB = MIN( NB, N-I )
NIB = N*IB
C
C Reduce rows and columns i:i+nb-1 to PVL form and return the
C matrices XA, XG, XQ, and YA which are needed to update the
C unreduced parts of the matrices.
C
CALL MB04PA( .TRUE., N-I+1, I-1, IB, A(1,I), LDA, QG(1,I),
$ LDQG, DWORK(PXA), N, DWORK(PXG), N,
$ DWORK(PXQ), N, DWORK(PYA), N, CS(2*I-1),
$ TAU(I), DWORK(PDW) )
IF ( N.GT.I+IB ) THEN
C
C Update the submatrix A(1:n,i+ib+1:n).
C
CALL DGEMM( 'No transpose', 'Transpose', N-I-IB, N-I-IB,
$ IB, ONE, QG(I+IB+1,I), LDQG, DWORK(PXA+IB+1),
$ N, ONE, A(I+IB+1,I+IB+1), LDA )
CALL DGEMM( 'No transpose', 'Transpose', N-I-IB, N-I-IB,
$ IB, ONE, A(I+IB+1,I), LDA,
$ DWORK(PXA+NIB+IB+1), N, ONE,
$ A(I+IB+1,I+IB+1), LDA )
CALL DGEMM( 'No transpose', 'Transpose', N, N-I-IB, IB,
$ ONE, DWORK(PYA), N, QG(I+IB+1,I), LDQG, ONE,
$ A(1,I+IB+1), LDA )
CALL DGEMM( 'No transpose', 'Transpose', N, N-I-IB, IB,
$ ONE, DWORK(PYA+NIB), N, A(I+IB+1,I), LDA,
$ ONE, A(1,I+IB+1), LDA )
C
C Update the submatrix Q(i+ib+1:n,i+ib+1:n).
C
CALL DSYR2K( 'Lower', 'No Transpose', N-I-IB, IB, ONE,
$ DWORK(PXQ+IB+1), N, QG(I+IB+1,I), LDQG, ONE,
$ QG(I+IB+1,I+IB+1), LDQG )
CALL DSYR2K( 'Lower', 'No Transpose', N-I-IB, IB, ONE,
$ DWORK(PXQ+NIB+IB+1), N, A(I+IB+1,I), LDA,
$ ONE, QG(I+IB+1,I+IB+1), LDQG )
C
C Update the submatrix G(1:n,1:n).
C
CALL DGEMM( 'No transpose', 'Transpose', I+IB, N-I-IB,
$ IB, ONE, DWORK(PXG), N, QG(I+IB+1,I), LDQG,
$ ONE, QG(1,I+IB+2), LDQG )
CALL DGEMM( 'No transpose', 'Transpose', I+IB, N-I-IB,
$ IB, ONE, DWORK(PXG+NIB), N, A(I+IB+1,I), LDA,
$ ONE, QG(1,I+IB+2), LDQG )
CALL DSYR2K( 'Upper', 'No Transpose', N-I-IB, IB, ONE,
$ DWORK(PXG+IB+I), N, QG(I+IB+1,I), LDQG, ONE,
$ QG(I+IB+1,I+IB+2), LDQG )
CALL DSYR2K( 'Upper', 'No Transpose', N-I-IB, IB, ONE,
$ DWORK(PXG+NIB+IB+I), N, A(I+IB+1,I), LDA,
$ ONE, QG(I+IB+1,I+IB+2), LDQG )
END IF
20 CONTINUE
END IF
C
C Unblocked code to reduce the rest of the matrices.
C
CALL MB04PU( N, I, A, LDA, QG, LDQG, CS, TAU, DWORK, LDWORK,
$ IERR )
C
DWORK( 1 ) = DBLE( WRKOPT )
C
RETURN
C *** Last line of MB04PB ***
END
|