function [Shat,Omega,q] = SPECTRE(S,T,q);
S(1) = (S(1)+S(2^q+1))/2; u=FFTnum(-1,q,S(1:2^q)');
k=1:2^q; w = ((-1).^(k-1))'; 
u=w.*u; u1=u(1:2^(q-1))'; u2=u(2^(q-1)+1:2^q)';
f=[u2 u1 0];
Shat=(2*T/2^q)*f; Omega = 2^(q-2)/T;  
endfunction     
