Re: FFTW Fortran Real2Complex R2C output array structure? fftw_plan_dft_r2c_3d?
- From: "Robert S." <res@xxxxxxxxxxxxxxx>
- Date: Wed, 13 Jun 2007 14:26:21 -0700
On Jun 13, 5:40 am, "Steven G. Johnson" <stev...@xxxxxxxxxxxx> wrote:
On Jun 12, 1:16 pm, "Robert S." <r...@xxxxxxxxxxxxxxx> wrote:
I'm using the FFTW package and am using the fortan wrappers
to compute a 3D transform. This I seem to do successfully, however
I can not seem to disentangle the raw output.>From studying the figure on page 8 of the fftw 3.1.2 manual
[...]
(I don't shuffle the 3rd dimension since this runs from 1---ngrid3/2+1
and already
contains just the +ve frequncies.)
Remember that a Fortran array corresponds to a C array with *reversed*
dimensions (column-major vs. row-major format). So, in the C FFTW
interface, for an r2c (real-input) transform the last dimension is cut
in ~half, but in the Fortran interface the *first* dimension is cut in
~half.
This is discussed in the FFTW manual. See the third bullet point of:
http://www.fftw.org/doc/Fortran_002dinterface-routines.html
and the last example of:
http://www.fftw.org/doc/Fortran-Examples.html
Regards,
Steven G. Johnson
Dear Steven,
Many thanks! The routine works pefectly.
Best,
Robert
AND just for completeness:
The working frequency shuffle routine, based on Stephen's comments, is
presented below.
This places the zero frequency value at the position array(1, ng2/2 ,
ng3/2 )
-----------------------------------------------------------------------------------------------
subroutine FFTWshuffle_R2C_3D(array)
integer :: ng1,ng2,ng3
integer :: j,k,jj,kk
complex(DPC), dimension(:,:,:) :: array
complex(DPC), allocatable, dimension(:,:,:) :: image
ng1 = size(array,dim=1)
ng2 = size(array,dim=2)
ng3 = size(array,dim=3)
allocate (image(ng1,ng2,ng3))
do k=1,ng3
do j=1,ng2
jj = j + ng2/2 + 1
kk = k + ng3/2 + 1
if (jj.gt.ng2) jj=jj-ng2
if (kk.gt.ng3) kk=kk-ng3
image(:,j,k)=array(:,jj,kk)
enddo
enddo
array=image
deallocate (image)
end subroutine FFTWshuffle_R2C_3D
-------------------------------------------------------------------
.
- References:
- FFTW Fortran Real2Complex R2C output array structure? fftw_plan_dft_r2c_3d?
- From: Robert S.
- Re: FFTW Fortran Real2Complex R2C output array structure? fftw_plan_dft_r2c_3d?
- From: Steven G. Johnson
- FFTW Fortran Real2Complex R2C output array structure? fftw_plan_dft_r2c_3d?
- Prev by Date: Re: Calculate % of similarity between two samples
- Next by Date: Re: Calculate % of similarity between two samples
- Previous by thread: Re: FFTW Fortran Real2Complex R2C output array structure? fftw_plan_dft_r2c_3d?
- Next by thread: true
- Index(es):
Relevant Pages
|