00001 subroutine invmat(nm,mat)
00002 implicit none
00003 integer , intent(in) :: nm
00004 real(8) , intent(inout) :: mat(nm,nm)
00005 integer :: ipiv(nm)
00006 integer :: Lwork
00007 real(8) , allocatable :: work(:)
00008 integer :: info
00009
00010 Lwork = 10*nm
00011 allocate (work(Lwork))
00012 info = 0
00013 call dgetrf(nm,nm,mat,nm,ipiv,info)
00014 call dgetri(nm,mat,nm,ipiv,work,Lwork,info)
00015
00016 if(info /= 0) then
00017 write(6,*) 'info (subrouitine inv):' , info
00018 stop
00019 end if
00020 deallocate(work)
00021 return
00022 end subroutine
00023
00024 subroutine invmat_complex(nm,mat)
00025 implicit none
00026 integer,intent(in)::nm
00027 complex(8),intent(inout)::mat(nm,nm)
00028 integer::ipiv(nm)
00029 integer::Lwork
00030 complex(8),allocatable::work(:)
00031 integer::info
00032
00033 Lwork = 10*nm
00034 allocate (work(Lwork))
00035 info = 0
00036 call zgetrf(nm,nm,mat,nm,ipiv,info)
00037 call zgetri(nm,mat,nm,ipiv,work,Lwork,info)
00038
00039 if(info /= 0) then
00040 write(6,*) 'info (subrouitine inv):' , info
00041 stop
00042 end if
00043 deallocate(work)
00044 return
00045 end subroutine
00046
00047 subroutine diagV(nm,mat,eig)
00048 implicit none
00049 integer,intent(in)::nm
00050 complex(8),intent(inout)::mat(nm,nm)
00051 real(8),intent(out)::eig(nm)
00052 integer::LWORK,LRWORK,LIWORK
00053 integer,allocatable::iwork_zheevd(:)
00054 real(8),allocatable::rwork_zheevd(:)
00055 complex(8),allocatable::work_zheevd(:)
00056 integer::ind
00057 real(8)::eps
00058
00059 LWORK= 2*nm+nm**2
00060 LRWORK=1+12*nm+3*nm**2
00061 LIWORK=3+10*nm
00062 allocate(work_zheevd(LWORK));work_zheevd(:)=0.0d0
00063 allocate(rwork_zheevd(LRWORK));rwork_zheevd(:)=0.0d0
00064 allocate(iwork_zheevd(LIWORK));iwork_zheevd(:)=0
00065 eps=1.0d-18
00066 ind=0
00067
00068 call zheevd("V","U",nm,mat,nm,eig,work_zheevd,LWORK,rwork_zheevd,LRWORK,iwork_zheevd,LIWORK,ind)
00069
00070 if(ind/=0)then
00071 write(6,*)'ind=',ind
00072 stop
00073 endif
00074
00075 deallocate(work_zheevd,rwork_zheevd,iwork_zheevd)
00076 return
00077 end subroutine
00078
00079 subroutine OUTER_PRODUCT(vec_x,vec_y,vec_z)
00080 implicit none
00081 real(8)::vec_x(3),vec_y(3),vec_z(3)
00082
00083 vec_z(1)=vec_x(2)*vec_y(3)-vec_x(3)*vec_y(2)
00084 vec_z(2)=vec_x(3)*vec_y(1)-vec_x(1)*vec_y(3)
00085 vec_z(3)=vec_x(1)*vec_y(2)-vec_x(2)*vec_y(1)
00086
00087 return
00088 end subroutine