home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
326.lha
/
KFFT_v1.1
/
ifftcr
< prev
next >
Wrap
Text File
|
1989-12-23
|
2KB
|
67 lines
\ IFFTCR - Inverse Fast Fourier Transform - Complex in, Real out
\
\ KFFT V1.1 (C)Copyright 1989, Jerry Kallaus. All rights reserved.
\ May be freely redistributed for non-commercial use (FREEWARE).
INCLUDE? fft1 fftinc
ANEW task-ifftcr
: IFFTCR { a m | n kn km a1r a1i savbits inshift-save --- }
m 1- 2** -> n
[ float_fft? NOT ] .IF
inshift-fft @ DUP -> inshift-save
IF a n 2* inshift-fft @
NEGATE ASHIFT.ARRAY THEN
inshift-fft OFF
.THEN
[ float_fft? w_table_fft? NOT AND ]
.IF
pi_fft n FLOAT S/ ZEXP
.ELSE
m 1- ZCELLS w-table-fft + Z@
.THEN
z1
a ZCELL+ -> kn
n 1- ZCELLS a + -> km
n U2/ 1
DO
ZOVER Z* ZDUP
km Z@ CONJG ZDUP
kn Z@ Z+ -> a1i -> a1r
kn Z@ Z-
ZNEGATE Z*
ZI* ZDUP
a1r a1i Z+
kn DUP ZCELL+ -> kn
Z!
ZNEGATE a1r a1i
Z+ CONJG km DUP ZCELL- -> km
Z!
LOOP
ZDROP ZDROP
a Z@ S+
a Z@ S-
a Z!
kn Z@ ZDUP Z+ CONJG kn Z!
[ auto_scale_fft? ] .IF
a n 2* OR.ABS.ARRAY
>R ( auto scale-down control: )
[ 14 2** ] LITERAL ( Shift input to new stage right )
R@ < IF 1 ELSE 0 THEN ( 0,1 or 2 places depending on )
[ 15 2** ] LITERAL ( highest bit set on output of )
R> < IF 1+ THEN ( last stage. if > 2**14 use 1 )
inshift-fft ! ( if > 2**15 use 2 )
.THEN
a m 1- IFFT
[ auto_scale_fft? ] .IF
inshift-save DUP shifts-fft +! blk-exp-fft +! .THEN
;