Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program DFT
- implicit none
- integer :: k, N, x, y, j, r, l, istat, p
- integer, parameter :: dp = selected_real_kind(15,300)
- real, allocatable,dimension(:) :: h
- complex, allocatable, dimension(:) :: rst
- complex, dimension(:,:), allocatable :: W
- real(kind=dp) :: pi
- p = 2*pi
- !open file to write results to
- open(unit=100, file="dft.dat", status='replace')
- N = 400
- !allocate arrays as length N, apart from W (NxN)
- allocate(h(N))
- allocate(rst(N))
- allocate(W(-N/2:N/2,1:N))
- pi = 3.14159265359
- !loop to create the sample containing array
- do k=1,N
- h(k) = k*(pi*0.005)
- end do
- !loop to fill the product matrix with values
- do j = -N/2,N/2
- do k = 1, N
- W(j,k) = EXP((2.0_dp*pi*cmplx(0.0_dp,1.0_dp)*j*k)/N)
- end do
- end do
- !use of matmul command to multiply matrices
- rst = matmul(W,h)
- print *, h, w
- write(100,*) rst
- end program
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement