16 subroutine matinv ( N, M, AA, BB, DET )
20 integer,
intent(in) :: n
21 integer,
intent(in) :: m
22 real,
dimension(N,N),
intent(in out) :: aa
23 real,
dimension(N,M),
intent(in out) :: bb
24 real,
intent(out) :: det
27 integer :: i, j, k, ik, jk
28 real,
PARAMETER :: epsmach = 2.e-16
30 integer,
allocatable :: pc(:), pl(:)
31 real,
allocatable :: cs(:)
59 if ( abs(aa(i,j)) > pav )
then 81 if ( ik /= k ) det = -det
82 if ( jk /= k ) det = -det
84 if ( abs(det) < epsmach )
then 86 write (*,*)
' DETERMINANT EQUALS ZERO, NO SOLUTION!' 137 if (abs(pv) < epsmach)
then 138 WRITE(*,*)
' PIVOT TOO SMALL - STOP' 142 aa(k,i) = aa(k,i) / pv
146 bb(k,i) = bb(k,i) / pv
153 if ( j == k )
CONTINUE 156 aa(j,i) = aa(j,i) - cs(j) * aa(k,i)
160 bb(j,i) = bb(j,i) - cs(j) * bb(k,i)
177 if ( ik == i )
CONTINUE 201 if ( jk == j )
CONTINUE 212 deallocate( pc, pl, cs )
214 end subroutine matinv
235 subroutine jacobi_eigenvalue ( n, a, it_max, v, d, it_num, rot_num )
239 integer,
intent(in) :: n
240 real,
dimension(n,n),
intent(in out) :: a
241 integer,
intent(in) :: it_max
242 real,
dimension(n,n),
intent(out) :: v
243 real,
dimension(n),
intent(out) :: d
244 integer,
intent(out) :: it_num
245 integer,
intent(out) :: rot_num
248 integer :: i, j, k, l, m, p, q
261 real,
dimension(n) :: bw
262 real,
dimension(n) :: w, zw
281 do while ( it_num < it_max )
291 thresh = thresh + a(i,j) ** 2
295 thresh = sqrt( thresh ) / real( 4 * n, kind = 8 )
297 if ( thresh == 0.0 )
then 304 gapq = 10.0 * abs( a(p,q) )
305 termp = gapq + abs( d(p) )
306 termq = gapq + abs( d(q) )
310 if ( 4 < it_num .and. termp == abs( d(p) ) .and. termq == abs( d(q) ) )
then 316 else if ( thresh <= abs( a(p,q) ) )
then 319 term = abs( h ) + gapq
321 if ( term == abs( h ) )
then 324 theta = 0.5 * h / a(p,q)
325 t = 1.0 / ( abs( theta ) + sqrt( 1.0 + theta * theta ) )
326 if ( theta < 0.0 )
then 331 c = 1.0 / sqrt( 1.0 + t * t )
333 tau = s / ( 1.0 + c )
350 a(j,p) = g - s * ( h + g * tau )
351 a(j,q) = h + s * ( g - h * tau )
357 a(p,j) = g - s * ( h + g * tau )
358 a(j,q) = h + s * ( g - h * tau )
364 a(p,j) = g - s * ( h + g * tau )
365 a(q,j) = h + s * ( g - h * tau )
373 v(j,p) = g - s * ( h + g * tau )
374 v(j,q) = h + s * ( g - h * tau )
377 rot_num = rot_num + 1
384 bw(1:n) = bw(1:n) + zw(1:n)
405 if ( d(l) < d(m) )
then 424 end subroutine jacobi_eigenvalue