clear all;
close all;

dur=3000;
theta=20*pi/180;
signal = zeros(8,dur);
signal(1,:)=vcircN(dur,2);
signal(2,:)=vcircN(dur,2);
signal(3,:)=vcircN(dur,2);
signal(4,:)=vcircN(dur,2);
signal(5,:)=vcircN(dur,2);
signal(6,:)=vcircN(dur,2);
signal(7,:)=vcircN(dur,2);
signal(8,:)=vcircN(dur,2);

A=(randn(8)+i*randn(8))*signal;
S=A;
w=-1;
r=8;

fprintf('Matlab\');
if r==2,K=1;else,K=1+round(sqrt(r));end;  %%% K= NBRE MAXI DE BALAYAGES
tic
Rot=eye(r);
K=K+2;
for k=1:K,                         %%%%%% DEBUT BALAYAGES
Q=eye(r);
  for i=1:r-1,
  for j= i+1:r,
    S1ij=[S(i,:);S(j,:)];
    [qij,theta]=tfuni1(S1ij,w);  %%%%%% ROTATION PLANE SEPARANTE
    Sij=qij*S1ij;                  %%%%%% TRAITEMENT D'UNE PAIRE
    S(i,:)=Sij(1,:);S(j,:)=Sij(2,:);
    Qij=eye(r);Qij(i,i)=qij(1,1);Qij(i,j)=qij(1,2);
    Qij(j,i)=qij(2,1);Qij(j,j)=qij(2,2);
    Q=Qij*Q;                       %%%%%% CUMUL DE LA ROTATION SUR LE BALAY
  end;
  end;
  Rot=Rot*Q';                        %%%%%% CUMUL DE TOUTES LES ROTATIONS
end;
toc
Rot
fprintf('\n');

w=-1;
r=8;
S=A;

fprintf('Programme C\n');
if r==2,
   K=1;
else,
   K=1+round(sqrt(r));
end;  %%% K= NBRE MAXI DE BALAYAGES
tic;
[Rot2]=b11(S,r,K,w);
toc
Rot2

plot(Rot*A,'h');


