-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.f90
83 lines (62 loc) · 1.59 KB
/
main.f90
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
module timer
real(8) :: t1,t2
contains
subroutine tic()
implicit none
call cpu_time(t1)
end subroutine tic
subroutine toc()
implicit none
call cpu_time(t2)
print*,"Time Taken -->", real(t2-t1)
end subroutine toc
end module timer
program main
use eigen_solver
use timer
implicit none
integer,parameter :: ndim=1000
real(dp) :: mat(ndim,ndim)
real(dp) :: val(ndim)
complex(dp) :: zmat(ndim,ndim)
complex(dp) :: zval(ndim)
!real(dp) :: vec(ndim,ndim)
real(dp),allocatable :: vec(:,:)
complex(dp),allocatable :: zvec(:,:)
integer :: i,j,k,ierr
! generate a randm matrix
do i = 1,ndim
do j = 1,ndim
mat(j,i) = i*j*1.0d0 + sin(j*i*1.0d0) ! an example of symetric matrix
zmat(j,i) = cmplx(mat(j,i),0)
enddo
enddo
allocate(vec(ndim,ndim))
allocate(zvec(ndim,ndim))
! call eigen(mat,val,vec,ierr)
! if (ierr .eq. 0) then
! print*, "val=:,",val
! else
! print*,"failed to solve eigen value,error info: ",ierr
! endif
!call eigen(zmat,zval,zvec,ierr)
! if (ierr .eq. 0) then
! print*, "zval=:,",zval
! else
! print*,"failed to solve complex eigen value,error info: ",ierr
! endif
!call eigen(mat,'U',val,vec,ierr)
! if (ierr .eq. 0) then
! print*, "sym val=:,",val
! else
! print*,"failed to solve sym real mat eigen value,error info: ",ierr
! endif
call tic()
call eigen(mat,'U',val,vec,ierr)
call toc()
if (ierr .eq. 0) then
print*, " val=:,",val(1)
else
print*,"failed to solve hermite mat eigen value,error info: ",ierr
endif
end