function [Shat,Omega] = SPECTREgen(S,T);
N = length(S)-1; 
S(1) = (S(1)+S(N+1))/2;  u = fft(S(1:N)',-1,"nonsymmetric");
k=1:N; w = ((-1).^(k-1))'; 
u=w.*u; u1 = u(1:fix(N/2))'; u2=u(fix(N/2)+1:N)';
Shat=(2*T/N)*[u2 u1 0]; Omega = N/(4*T);  
endfunction     
