How to replace fftn and ifftn with parallel statements

조회 수: 3 (최근 30일)
耀 王
耀 王 2021년 11월 26일
답변: Sanju 2024년 2월 15일
I basically understand that fftn can be replaced by the following code, but how is ifftn implemented?
psi=rand(10,10,10);
% costly way
fftpsi=fftn(psi);
% This might save you some RAM, to be tested
[m,n,p] = size(psi);
for k=1:p
psi(:,:,k) = fftn(psi(:,:,k));
end
psi = reshape(psi,[m*n p]);
for i=1:m*n % you might work on bigger row-block to increase speed
psi(i,:) = fft(psi(i,:));
end
psi = reshape(psi,[m n p]);

답변 (1개)

Sanju
Sanju 2024년 2월 15일
Hi 耀 ,
The “ifftn” function in MATLAB is implemented using a similar approach as the code you provided for “fftn” It performs the inverse Fourier transform on each slice of the input array along the specified dimensions.
Here's an example of how you can implement “ifftn” ,
psi = rand(10, 10, 10);
ifftpsi = ifftn(psi);
[m, n, p] = size(psi);
for k = 1:p
psi(:,:,k) = ifftn(psi(:,:,k));
end
psi = reshape(psi, [m*n p]);
for i = 1:m*n
psi(i,:) = ifft(psi(i,:));
end
psi = reshape(psi, [m n p]);
This code applies the inverse Fourier transform to each slice of “fftpsi” along the third dimension.
You can also refer to the below documentation link if required,
Hope this Helps!

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by