fast convolution filtering works at least for complex numbers.

This commit is contained in:
Mark Borgerding
2003-12-31 22:49:14 +00:00
parent 212ec326e0
commit 0243552944
4 changed files with 326 additions and 7 deletions

View File

@ -15,6 +15,7 @@ SELFTEST=st_$(DATATYPE)
TESTREAL=tr_$(DATATYPE)
TESTKFC=tkfc_$(DATATYPE)
FFTUTIL=kf_$(DATATYPE)
FASTFILT=ff_$(DATATYPE)
ifeq "$(DATATYPE)" "short"
TYPEFLAGS=-DFIXED_POINT -Dkiss_fft_scalar=short
@ -32,13 +33,17 @@ else
endif
all: $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(FFTUTIL) $(TESTKFC)
all: $(BENCHKISS) $(SELFTEST) $(BENCHFFTW) $(TESTREAL) $(FFTUTIL) \
$(TESTKFC) $(FASTFILT)
CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer
#-DUSE_SKIP
# If the above flags do not work, try the following
#CFLAGS=-Wall -O3
$(FASTFILT): ../kiss_fft.c kiss_fastfir.c kiss_fftr.c
$(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) -lm $+ -DFAST_FILT_UTIL
$(FFTUTIL): ../kiss_fft.c fftutil.c kiss_fftnd.c kiss_fftr.c
$(CC) -o $@ $(CFLAGS) -I.. $(TYPEFLAGS) -lm $+

View File

@ -44,9 +44,9 @@ def fastfilter(sig,h,nfft=None):
return concatenate( res )
def main():
siglen = 1e5
hlen = 500
nfft = 1024*4
siglen = 1e4
hlen = 50
nfft = 128
print 'nfft=%d'%nfft
# make a signal
sig = make_random( siglen )
@ -57,14 +57,28 @@ def main():
# perform MAC filtering
yslow = slowfilter(sig,h)
#print '<YSLOW>',yslow,'</YSLOW>'
yfast = fastfilter(sig,h,nfft)
#yfast = fastfilter(sig,h,nfft)
yfast = utilfastfilter(sig,h,nfft)
#print yfast
print 'len(yslow)=%d'%len(yslow)
print 'len(yfast)=%d'%len(yfast)
diff = yslow-yfast
snr = 10*log10( vdot(yslow,yslow) / vdot(diff,diff) )
snr = 10*log10( abs( vdot(yslow,yslow) / vdot(diff,diff) ) )
print 'snr=%s' % snr
if snr < 10.0:
print yslow[:5]
print yfast[:5]
def utilfastfilter(sig,h,nfft):
import compfft
import os
open( 'sig.dat','w').write( compfft.dopack(sig,'f',1) )
open( 'h.dat','w').write( compfft.dopack(h,'f',1) )
cmd = './ff_float -n %d -i sig.dat -h h.dat -o out.dat' % nfft
print cmd
ec = os.system(cmd)
print 'exited->',ec
return compfft.dounpack(open('out.dat').read(),'f',1)
if __name__ == "__main__":
main()