gfor function with matlab 2013b

1 visualización (últimos 30 días)
Rolly
Rolly el 24 de Mzo. de 2014
Respondida: Chaitra el 26 de Jun. de 2014
Hi,
I was using jacket with matlab but the old system was upgraded to win7 and new matlab 2013b is installed.
However, jacket is now discontinued but I don't see the same functionality "gfor" with matlab 2013b which is quite disappointing.
I was using gfor for windowed Fourier transform (wft) computation as attached below, can anyone give me some hind on how to get the "gfor" functionality back? Thank you very much!
function g=gwft(type,f,sigmax,wxl,wxi,wxh,thr)
%the purpose is to make the wff faster by choosing smaller window size
%which does not affect its accuracy.
if strcmp(type,'wff')
%half window size along x, by default 2*sigmax; window size: 2*sx+1
sx=round(2*sigmax);
elseif strcmp(type,'wfr')
%half window size along x, by default 3*sigmax; window size: 2*sx+1
sx=round(3*sigmax);
end
%array size
m =length(f);
%expanded size:
mm=m+2*sx;
%pre-compute the spectrum of f to size [mm] on GPU;
%--- f is assumed gdouble ---%
Ff=fft(f,mm);
%1D index for window on GPU
x=gdouble((-sx:sx)');
%generate a window w0 on GPU
w0=gdouble(exp(-x.*x/2/sigmax/sigmax));
%normalization of window w0 on GPU
w0=w0/sqrt(sum(w0));
%config WFT basis on GPU
wxt=gdouble(wxl:wxi:wxh);
if strcmp(type,'wff')
thr=gdouble(thr);
g.filtered=gzeros(m,length(wxt));
gfor k=1:length(wxt)
%WFT basis
w=w0.*exp(1i*wxt(k)*x);
%spectrum of w to size [mm]
Fw=fft(w,mm);
%implement of WFT: conv2(f,w)=ifft2(Ff.*Fw);
sf=ifft(Ff.*Fw);
%cut to get desired data size
sf=sf(1+sx:m+sx);
%threshold the spectrum
sf=sf.*(abs(sf)>=thr);
%implement of IWFT to size [mm]: conv2(sf,w);
gtemp=ifft(fft(sf,mm).*Fw);
%update
g.filtered(:,k)=g.filtered(:,k)+gtemp(1+sx:m+sx);
gend
%summation along the length of wxt so convert to 1D
g.filtered=sum(g.filtered,2);
%scale the data
g.filtered=g.filtered/2/pi*wxi;
% return to Matlab workspace
g.filtered=double(g.filtered);
elseif strcmp(type,'wfr')
g.wx=zeros(m,1); g.phase=zeros(m,1); g.r=zeros(m,1);
gfor wxt=wxl:wxi:wxh
%WFT basis
w=w0.*exp(1i*wxt*x);
%spectrum of w to size mm
Fw=fft(w,mm);
%implement of WFT: conv2(f,w)=ifft2(Ff*Fw);
sf=ifft(Ff.*Fw);
%cut to get desired data size
sf=sf(1+sx:m+sx);
%indicate where to update
t=(abs(sf)>g.r);
%update r
g.r=g.r.*(1-t)+abs(sf).*t;
%update wx
g.wx=g.wx.*(1-t)+wxt*t;
%update phase
g.phase=g.phase.*(1-t)+angle(sf).*t;
gend
g.phase=double(g.phase);
end

Respuestas (1)

Chaitra
Chaitra el 26 de Jun. de 2014
You can use ARRAYFUNC to speedup a loop execution on GPU. Referring to the following link might be of some use to you:

Categorías

Más información sobre GPU Computing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by