//
// Input parameter:
//   N-number point
//   x,y- Massiv data x[0]..x[N-1], x for BPF, x and y for OBPF
//   I - =1-BPF, =-1 -OBPF
// Output:
//   x-Re
//   y-Im

var x,y:array[0..2048] of extended;
     N, I:integer;

procedure BPF;
var c,s,t1,t2,t3,t4,u1,u2,u3: real;
     i,j,p,l,L,M,M1,K: integer;
begin
 L:=N;
 M:=N/2;
 M1:=N-1;
 while(L>=2)do
  begin
   l:=L/2; u1:=1; u2:=0; t1:=PI/l;
   c:=cos(t1); s:=-I*sin(t1);
   j:=0;
   while j<l do
    begin
     i:=j;
     while i<N do
      begin
       p:=i+l;
       t1:=x[i] + x[p];
       t2:=y[i] + y[p];
       t3:=x[i] - x[p];
       t4:=y[i] - y[p];
       x[p]:=t3*u1-t4*u2;
       y[p]:=t4*u1+t3*u2;
       x[i]:=t1;
       y[i]:=t2;
       i:=i+L;
      end;
     u3:=u1*c-u2*s;
     u2:=u2*c+u1*s; u1:=u3;
     j:=j+1;
   end;
  L:=L/2;
 end;
 j:=0;
 i:=0;
 while i<M1 do
  begin
   if(i > j) then
    begin
     t1:=x[j]; t2:=y[j];
     x[j]:=x[i]; y[j]:=y[i];
     x[i]:=t1; y[i]=t2;
    end;
   K:=M;
   while( j >=K)
    begin
     j:=j-K; K:=K/2;
    end;
   j:=j+K;
   i:=i+1;
  end;
end;