Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. program DFT
  2. implicit none
  3. integer :: k, N, x, y, j, r, l, istat, p
  4. integer, parameter :: dp = selected_real_kind(15,300)
  5. real, allocatable,dimension(:) :: h
  6. complex, allocatable, dimension(:) :: rst
  7. complex, dimension(:,:), allocatable :: W
  8. real(kind=dp) :: pi
  9. p = 2*pi
  10. !open file to write results to
  11. open(unit=100, file="dft.dat", status='replace')
  12.  
  13. N = 400
  14. !allocate arrays as length N, apart from W (NxN)
  15. allocate(h(N))
  16. allocate(rst(N))
  17. allocate(W(-N/2:N/2,1:N))
  18.  
  19. pi = 3.14159265359
  20. !loop to create the sample containing array
  21. do k=1,N
  22. h(k) = k*(pi*0.005)
  23. end do
  24.  
  25. !loop to fill the product matrix with values
  26. do j = -N/2,N/2
  27. do k = 1, N
  28.  
  29. W(j,k) = EXP((2.0_dp*pi*cmplx(0.0_dp,1.0_dp)*j*k)/N)
  30.  
  31. end do
  32. end do
  33. !use of matmul command to multiply matrices
  34. rst = matmul(W,h)
  35. print *, h, w
  36. write(100,*) rst
  37.  
  38. end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement