| 1 |
subroutine dlartg( f, g, s, r ) |
| 2 |
implicit none |
| 3 |
double precision :: f, g, r, s |
| 4 |
double precision :: d, p |
| 5 |
|
| 6 |
d = sqrt( f*f + g*g ) |
| 7 |
p = 1.d0 / d |
| 8 |
if( abs( f ) > 1 ) then |
| 9 |
s = g*sign( p, f ) |
| 10 |
r = sign( d, f ) |
| 11 |
else |
| 12 |
s = g*sign( p, f ) |
| 13 |
r = sign( d, f ) |
| 14 |
end if |
| 15 |
end subroutine |
| 16 |
|
| 17 |
subroutine dhgeqz( n, h, t ) |
| 18 |
implicit none |
| 19 |
integer n |
| 20 |
double precision h( n, * ), t( n, * ) |
| 21 |
integer jc |
| 22 |
double precision c, s, temp, temp2, tempr |
| 23 |
temp2 = 10d0 |
| 24 |
call dlartg( 10d0, temp2, s, tempr ) |
| 25 |
c = 0.9d0 |
| 26 |
s = 1.d0 |
| 27 |
do jc = 1, n |
| 28 |
temp = c*h( 1, jc ) + s*h( 2, jc ) |
| 29 |
h( 2, jc ) = -s*h( 1, jc ) + c*h( 2, jc ) |
| 30 |
h( 1, jc ) = temp |
| 31 |
temp2 = c*t( 1, jc ) + s*t( 2, jc ) |
| 32 |
t( 2, jc ) = -s*t( 1, jc ) + c*t( 2, jc ) |
| 33 |
t( 1, jc ) = temp2 |
| 34 |
enddo |
| 35 |
end subroutine dhgeqz |
| 36 |
|
| 37 |
program test |
| 38 |
implicit none |
| 39 |
double precision h(2,2), t(2,2) |
| 40 |
h = 0 |
| 41 |
t(1,1) = 1 |
| 42 |
t(2,1) = 0 |
| 43 |
t(1,2) = 0 |
| 44 |
t(2,2) = 0 |
| 45 |
call dhgeqz( 2, h, t ) |
| 46 |
if (t(2,2).ne.0) STOP 1 |
| 47 |
end program test |