1 SUBROUTINE tred2(a
,n
,np
,d
,e
)
2 !USE nrutil, ONLY : assert_eq,outerprod
4 INTEGER, PARAMETER :: sp
= 8
6 REAL(SP
), DIMENSION(np
,np
), INTENT(INOUT
) :: a
7 REAL(SP
), DIMENSION(np
), INTENT(OUT
) :: d
,e
8 !LOGICAL(LGT), OPTIONAL, INTENT(IN) :: novectors
10 REAL(SP
) :: f
,g
,h
,hh
,scale
11 REAL(SP
), DIMENSION(size(a
,1)) :: gg
12 !LOGICAL(LGT) :: yesvec
13 !n=assert_eq(size(a,1),size(a,2),size(d),size(e),’tred2’)
14 !if (present(novectors)) then
15 !yesvec=.not. novectors
23 scale
=sum(abs(a(i
,1:l
)))
24 if (scale
== 0.0) then
27 a(i
,1:l
)=a(i
,1:l
)/scale
36 e(j
)=(dot_product(a(j
,1:j
),a(i
,1:j
)) &
37 +dot_product(a(j
+1:l
,j
),a(i
,j
+1:l
)))/h
39 f
=dot_product(e(1:l
),a(i
,1:l
))
41 e(1:l
)=e(1:l
)-hh
*a(i
,1:l
)
44 a(j
,1:j
)=a(j
,1:j
)-a(i
,j
)*e(1:j
)-e(j
)*a(i
,1:j
)
58 gg(1:l
)=matmul(a(i
,1:l
),a(1:l
,1:l
))
59 !a(1:l,1:l)=a(1:l,1:l)-outerprod(a(1:l,i),gg(1:l))
62 a(k
,j
)=a(k
,j
)-gg(j
)*a(k
,i
)