Borrar filtros
Borrar filtros

How to replace fftn and ifftn with parallel statements

2 visualizaciones (últimos 30 días)
耀 王
耀 王 el 26 de Nov. de 2021
Respondida: Sanju el 15 de Feb. de 2024
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]);

Respuestas (1)

Sanju
Sanju el 15 de Feb. de 2024
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!

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by