I have created the following module: quantum.f90
module quantum
implicit none
contains
function renyi_entropy(A, N, p) result(entropy)
implicit none
integer :: N, p, INFO, i
real :: A(N,N), eval(N), WORK(3*N-1)
real :: entropy
call SSYEV('N', 'U', N, A, N, eval, WORK, 3*N-1, INFO)
entropy = 0.0
if (p == 1) then
do i = 1,N
entropy = entropy - eval(i)*LOG(eval(i))
end do
else
do i = 1,N
entropy = entropy + eval(i)**p
end do
entropy = LOG(entropy) / (1-p)
end if
entropy = entropy / LOG(2.0)
end function renyi_entropy
end module quantum
I use it in my program wishart.f90
as follows:
program wishart
use quantum
implicit none
integer :: d1, d2
real, allocatable :: A(:, :), W(:, :)
d1 = 4
d2 = 3
allocate(A(d1, d2), W(d1, d1))
call random_number(A)
W = matmul(A, transpose(A))
print*, renyi_entropy(W, d1, 1)
end program wishart
On the command line I give: gfortran -c quantum.f90 wishart.f90 -llapack -lblas
and then gfortran quantum.o wishart.o
. This results in
quantum.o: in function `__quantum_MOD_renyi_entropy':
quantum.f90:(.text+0x13e): undefined reference to `ssyev_'
collect2: error: ld returned 1 exit status