function [n,x,wsave]=sint(n,x,wsave);
persistent i k kc kw modn nf np1 ns2 sqrt3 t1 t2 xh ;
if isempty(i), i=0; end;
if isempty(k), k=0; end;
if isempty(kc), kc=0; end;
if isempty(kw), kw=0; end;
if isempty(modn), modn=0; end;
if isempty(nf), nf=0; end;
if isempty(np1), np1=0; end;
if isempty(ns2), ns2=0; end;
if isempty(sqrt3), sqrt3=0; end;
if isempty(t1), t1=0; end;
if isempty(t2), t2=0; end;
if isempty(xh), xh=0; end;
%***BEGIN PROLOGUE SINT
%***PURPOSE Compute the sine transform of a real, odd sequence.
%***LIBRARY SLATEC (FFTPACK)
%***CATEGORY J1A3
%***TYPE SINGLE PRECISION (SINT-S)
%***KEYWORDS FFTPACK, FOURIER TRANSFORM
%***AUTHOR Swarztrauber, P. N., (NCAR)
%***DESCRIPTION
%
% subroutine SINT computes the discrete Fourier sine transform
% of an odd sequence X(I). The transform is defined below at
% output parameter X.
%
% SINT is the unnormalized inverse of itself since a call of SINT
% followed by another call of SINT will multiply the input sequence
% X by 2*(N+1).
%
% The array WSAVE which is used by subroutine SINT must be
% initialized by calling subroutine SINTI(N,WSAVE).
%
% Input Parameters
%
% N the length of the sequence to be transformed. The method
% is most efficient when N+1 is the product of small primes.
%
% X an array which contains the sequence to be transformed
%
%
% WSAVE a work array with dimension at least INT(3.5*N+16)
% in the program that calls SINT. The WSAVE array must be
% initialized by calling subroutine SINTI(N,WSAVE), and a
% different WSAVE array must be used for each different
% value of N. This initialization does not have to be
% repeated so long as N remains unchanged. Thus subsequent
% transforms can be obtained faster than the first.
%
% Output Parameters
%
% X For I=1,...,N
%
% X(I)= the sum from K=1 to K=N
%
% 2*X(K)*SIN(K*I*PI/(N+1))
%
% A call of SINT followed by another call of
% SINT will multiply the sequence X by 2*(N+1).
% Hence SINT is the unnormalized inverse
% of itself.
%
% WSAVE contains initialization calculations which must not be
% destroyed between calls of SINT.
%
%***REFERENCES P. N. Swarztrauber, Vectorizing the FFTs, in Parallel
% Computations (G. Rodrigue, ed.), Academic Press,
% 1982, pp. 51-83.
%***ROUTINES CALLED RFFTF
%***REVISION HISTORY (YYMMDD)
% 790601 DATE WRITTEN
% 830401 Modified to use SLATEC library source file format.
% 860115 Modified by Ron Boisvert to adhere to Fortran 77 by
% (a) changing dummy array size declarations (1) to (*),
% (b) changing definition of variable SQRT3 by using
% FORTRAN intrinsic function SQRT instead of a DATA
% statement.
% 881128 Modified by Dick Valent to meet prologue standards.
% 891009 Removed unreferenced statement label. (WRB)
% 891009 REVISION DATE from Version 3.2
% 891214 Prologue converted to Version 4.0 format. (BAB)
% 920501 Reformatted the REFERENCES section. (WRB)
%***end PROLOGUE SINT
x_shape=size(x);x=reshape(x,1,[]);
wsave_shape=size(wsave);wsave=reshape(wsave,1,[]);
%***FIRST EXECUTABLE STATEMENT SINT
sqrt3 = sqrt(3.);
if( n<2 )
x(1) = x(1) + x(1);
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
wsave_shape=zeros(wsave_shape);wsave_shape(:)=wsave(1:numel(wsave_shape));wsave=wsave_shape;
return;
elseif( n==2 ) ;
xh = sqrt3.*(x(1)+x(2));
x(2) = sqrt3.*(x(1)-x(2));
x(1) = xh;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
wsave_shape=zeros(wsave_shape);wsave_shape(:)=wsave(1:numel(wsave_shape));wsave=wsave_shape;
return;
else;
np1 = fix(n + 1);
ns2 = fix(fix(n./2));
wsave(1) = 0.;
kw = fix(np1);
for k = 1 : ns2;
kw = fix(kw + 1);
kc = fix(np1 - k);
t1 = x(k) - x(kc);
t2 = wsave(kw).*(x(k)+x(kc));
wsave(k+1) = t1 + t2;
wsave(kc+1) = t2 - t1;
end; k = fix(ns2+1);
modn = fix(rem(n,2));
if( modn~=0 )
wsave(ns2+2) = 4..*x(ns2+1);
end;
nf = fix(np1 + ns2 + 1);
[np1,wsave,dumvar3]=rfftf(np1,wsave,wsave(sub2ind(size(wsave),max(nf,1)):end)); dumvar3i=find((wsave(sub2ind(size(wsave),max(nf,1)):end))~=(dumvar3)); wsave(nf-1+dumvar3i)=dumvar3(dumvar3i);
x(1) = .5.*wsave(1);
for i = 3 : 2: n ;
x(i-1) = -wsave(i);
x(i) = x(i-2) + wsave(i-1);
end; i = fix(n +1);
if( modn~=0 )
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
wsave_shape=zeros(wsave_shape);wsave_shape(:)=wsave(1:numel(wsave_shape));wsave=wsave_shape;
return;
end;
x(n) = -wsave(n+1);
end;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
wsave_shape=zeros(wsave_shape);wsave_shape(:)=wsave(1:numel(wsave_shape));wsave=wsave_shape;
end
%DECK SINTI