0

I want to fine eigenvalue and eigenvector of matrix that is symmetric positive definite define. However, I can not use function GVCSP in Fortran in Linux. Are there another function in Fortran that is equivalent GVCSP function.

here is my code:

program main

  integer , parameter :: n=4
  real*8 A(n,n), eigval(n), eigvec(n,n),eigvalmatrix(n,n)

  integer i,j

  do i=1,n
      eigval(i)=0
      do j=1,n
          eigvec(i,j)=0
          eigvalmatrix(i,j)=0
      end do
  end do

A(1,1)=-1
A(1,2)=0
A(1,3)=4
A(1,4)=2

A(2,1)=0
A(2,2)=2
A(2,3)=3
A(2,4)=-2

A(3,1)=4
A(3,2)=3
A(3,3)=0
A(3,4)=-4

A(4,1)=2
A(4,2)=-2
A(4,3)=-4
A(4,4)=1

call GVCSP(A, eigvalmatrix, eigval,eigvec)
  end program
Ian Bush
  • 6,996
  • 1
  • 21
  • 27
PHuong
  • 11
  • 3
  • Use lapack - http://www.netlib.org/lapack/explore-html/d2/d8a/group__double_s_yeigen.html . Also always use Implicit None in your code, and never use the completely non-standard real*8, instead learn the proper way to do it with kind values - https://stackoverflow.com/questions/838310/fortran-90-kind-parameter – Ian Bush Feb 18 '20 at 09:37
  • Dear Ian Bush, thank you for your help. T tried to use some subroutine that you mentioned, however, I can not run my program on ubuntu 18.04 , I had the error: "undefined reference to `dsyev_", do I nedd to install something for my laptop to run some subroutine – PHuong Feb 20 '20 at 08:29
  • Yes, you need to install lapack. If running on Linux you can usually get it using the package manager. If on windows I can't help you. – Ian Bush Feb 20 '20 at 09:16
  • Dear Ian Bush, thank you for your reply, I run fortran program on linux. So can you guide me how to install this package or give me a web that guide me how to install? I expect to receive your help so much. – PHuong Feb 21 '20 at 02:55
  • Depends on you exact version of linux but something like https://askubuntu.com/questions/623578/installing-blas-and-lapack-packages You will also need to link against the libraries https://stackoverflow.com/questions/35007006/error-in-linking-gfortran-to-lapack-and-blas – Ian Bush Feb 21 '20 at 09:39

0 Answers0