	PROGRAM xtred2
!	driver for routine tred2
	USE nrtype
	USE nr
	IMPLICIT NONE
	INTEGER(I4B), PARAMETER :: NP=10
	INTEGER(I4B) :: i,j
	REAL(DP), DIMENSION(NP) :: d,e
	REAL(DP), DIMENSION(NP,NP) :: a,f,c = reshape( (/ &
		5.0_dp,4.3_dp,3.0_dp,2.0_dp,1.0_dp,&
		0.0_dp,-1.0_dp,-2.0_dp,-3.0_dp,-4.0_dp,&
		4.3_dp,5.1_dp,4.0_dp,3.0_dp,2.0_dp,&
		1.0_dp,0.0_dp,-1.0_dp,-2.0_dp,-3.0_dp,&
		3.0_dp,4.0_dp,5.0_dp,4.0_dp,3.0_dp,&
		2.0_dp,1.0_dp,0.0_dp,-1.0_dp,-2.0_dp,&
		2.0_dp,3.0_dp,4.0_dp,5.0_dp,4.0_dp,&
		3.0_dp,2.0_dp,1.0_dp,0.0_dp,-1.0_dp,&
		1.0_dp,2.0_dp,3.0_dp,4.0_dp,5.0_dp,&
		4.0_dp,3.0_dp,2.0_dp,1.0_dp,0.0_dp,&
		0.0_dp,1.0_dp,2.0_dp,3.0_dp,4.0_dp,&
		5.0_dp,4.0_dp,3.0_dp,2.0_dp,1.0_dp,&
		-1.0_dp,0.0_dp,1.0_dp,2.0_dp,3.0_dp,&
		4.0_dp,5.0_dp,4.0_dp,3.0_dp,2.0_dp,&
		-2.0_dp,-1.0_dp,0.0_dp,1.0_dp,2.0_dp,&
		3.0_dp,4.0_dp,5.0_dp,4.0_dp,3.0_dp,&
		-3.0_dp,-2.0_dp,-1.0_dp,0.0_dp,1.0_dp,&
		2.0_dp,3.0_dp,4.0_dp,5.0_dp,4.0_dp,&
		-4.0_dp,-3.0_dp,-2.0_dp,-1.0_dp,0.0_dp,&
		1.0_dp,2.0_dp,3.0_dp,4.0_dp,5.0_dp /),&
		(/ NP,NP /) )
	a(:,:)=c(:,:)
	call tred2(a,d,e)
	write(*,'(/1x,a)') 'Diagonal elements'
	write(*,'(1x,5f12.6)') (d(i),i=1,NP)
	write(*,'(/1x,a)') 'Off-diagonal elements'
	write(*,'(1x,5f12.6)') (e(i),i=2,NP)
!	check transformation matrix
	f=matmul(c,a)
	f=matmul(trandpose(f),a)
!	how does it look?
	write(*,'(/1x,a)') 'Tridiagonal matrix'
	do i=1,NP
		write(*,'(1x,10f7.2)') (f(i,j),j=1,NP)
	end do
	END PROGRAM xtred2
