! test_permanent.f90 compute permanent of a matrix n!*n^2 flops program test_permanent implicit none integer, parameter :: sz = 20 double precision, dimension(sz,sz) :: A double precision :: perm integer :: last integer :: i, j, k, n ! for timing double precision :: start, now, next character*20 :: start_date character*20 :: start_time integer :: clock_count, clock_rate, clock_max interface double precision function permanent(n, sz, A) integer, intent(in) :: n, sz double precision, dimension(sz,sz), intent(in) :: A end function permanent double precision function udrnrt() end function udrnrt function permute(n, vector, permuter) result(last) integer, intent(in) :: n ! number of items to permute integer, dimension(1:*), intent(inout) :: vector, permuter integer :: last end function permute end interface print *, 'test_permanent.f90' ! for timing call date_and_time(date=start_date, time=start_time); print *, 'start_date=', start_date(5:6), '/', start_date(7:8), '/', start_date(1:4) print *, 'start_time=', start_time(1:2), ':', start_time(3:4), ':', start_time(5:10) call system_clock(count=clock_count, count_rate=clock_rate, count_max=clock_max) print *, 'clock_count=', clock_count, ', clock_rate=', clock_rate, ', clock_max=', clock_max start = (1.0D0+clock_count)/clock_rate print *, ' ' n = 1 do while(n .le. 12) print *, 'initializing, n=',n do i=1,n do j=1,n A(i,j) = udrnrt() if(n .le. 4) then print *, 'A(',i,',',j,')=',A(i,j) end if end do ! j end do ! i call system_clock(count=clock_count) now = (1.0D0+clock_count)/clock_rate perm = permanent(n, sz, A) call system_clock(count=clock_count) next = (1.0D0+clock_count)/clock_rate print *, 'permanent = ',perm,' in ',next-now, ' seconds' n=n+1 end do ! while print *, ' ' print *, 'flops are n * n!' print *, 'finished test_permanent.f90' end program test_permanent