% Measures the minimum execution time of direct Carleman Bilinearization of
% integrator + loudspeaker A

clear

P=2;        % Expansion order
rep=100;      % Number of repetitions for greater precision of execution
            % time measurement

arq='mCB_Aitgr_P2';  % Ouput file


% Numerical model
[f,g,h,x]=dloudAitgr_num;      % Regenerate model to be sure

warning('off','cbvk:carlbidir');
warning('off','cbvk:mtred');


% ----------------------------------------------------
% Taylor expansion


x0=zeros(1,length(f));
F1 = mtred(f,x,x0,P);
G1 = mtred(g,x,x0,P-1);


%----------------------------------------------------
% Carleman Bilinearization

dt=zeros(1,rep);

for r=1:rep
  tic
  [F,G,b] = carlbidir(F1,G1,P);
  dt(r)=toc;
  fprintf('%g\n ', dt(r));
end

min(dt)
%save(arq,'dt');
warning('on','cbvk:mtred');
warning('on','cbvk:carlbidir');


