[SciPy-user] Fourier-sine transform with SciPy

Lubos Vrbka lists@vrbka....
Sat Jun 7 08:54:53 CDT 2008

hi everybody!

> In the scipy sandbox under image you can find a transforms.py file which 
> contains an implementation of the DST (discrete sine transform).
travis, thanks for the code you sent me. actually, under my version of 
scipy/numpy (0.5.2/1.0.1) it doesn't work, since
Xt = np.fft(xtilde,axis=axis)
isn't a callable object. i had to use
Xt = np.fft.fft(xtilde,axis=axis)
and its equivalent in the inverse sinus transform.

regarding the implementation - it seems to me that to get optimal 
performance, the length of the original array should be 2^m - 1. if i 
have, e.g., 4096 points in the array, then newly constructed one will 
have 8194 points and fft of the length of 16194 will have to be done. is 
this correct?

i know that the following question isn't particularly related to scipy 
itself, but if anybody would be willing to explain these things to me, 
i'd be really grateful.

let's assume the distance (r)/reciprocal distance (k) pair. having my 
odd real function f(r) discretized on <0,L>, i have dr = L/N. the value 
of dk should be then dk = 2*pi/L = 2*pi/(N*dr).

actually, where does the value of N+1 come from (it's mentioned on the 
wiki page http://en.wikipedia.org/wiki/Discrete_sine_transform )?

according to the sampling theorem, the wave vectors corresponding to 0, 
1, ... N/2 should represent the function f in the fourier space, the 
rest of the wave vectors are redundant.

what happens in the case of the dst() routine? is the interval extended 
to <-L,L>, with the dk = 2*pi/2*L? but then, for N points of original 
array, i get N non-redundant values. how does this compare to the 
sampling theorem?

since i need to operate on the ft'ed function before transforming it 
back, and this operation involves the value of dk. i need to know what 
the value of dk really is.

in one implementation of my problem (not using fft), the original 
function was paddded with zeros to the length of 2N and the sum over the 
products f(r)sin(kr) was performed... how does then this compare to the 
dst() above?

any comments/pointers to relevant literature are more than welcome.

with best regards,

Lubos _@_"

More information about the SciPy-user mailing list