Archive

Archive for 2012年1月

vim-latex for MacVim

2012年01月26日 留下评论

See http://code.google.com/p/macvim/wiki/FAQ for instructions on how to install vim-latex(or known as latex-suite) on macvim.

However, on my Mac OS X Lion, there seems to be a problem with \lv using the default setting. When commanding \lv a pile of error messages jumped out. The fix I found is the following: go to ftplugin/latex-suite, open texrc,  uncomment the line

TexLet g:Tex_TreatMacViewerAsUNIX = 1

and add here or to .vimrc the following:

TexLet g:Tex_ViewRule_pdf = ‘open -a Skim’

I use Skim as my pdf viewer. These two resolve the problem.

 

分类:Uncategorized

Computing Determinant in Fortran

2012年01月6日 2 条评论

It may seem that one should go to LAPACK and find a routine that does just this job. However, it turns out that LAPACK does not really have such a routine. So a little bit of detour is needed. If you want to deal with a general, complex matrix, not symmetric, not Hermitian, then the way to go is using Gauss elimination(GE). LAPACK provides routines to find the LU decomposition of a matrix, which is essentially GE and can be used to compute the determinant. Here is the code snippet:


 1 complex(kind=8) function det(N, mat)
 2     implicit none
 3     integer(kind=8), intent(in) :: N
 4     complex(kind=8), intent(inout), dimension(:,:) :: mat
 5     integer(kind=8) :: i, info
 6     integer, allocatable :: ipiv(:)
 7     real(kind=8) :: sgn
 8
 9     allocate(ipiv(N))
10
11     ipiv = 0
12     
13     call zgetrf(N, N, mat, N, ipiv, info)
14     
15     det = ONE
16     do i = 1, N
17         det = det*mat(i, i)
18     end do
19     sgn = ONE
20     do i = 1, N
21         if(ipiv(i) /= i) then
22             sgn = -sgn
23         end if
24     end do
25     det = sgn*det  
26 end function det
分类:Uncategorized