% Measures the minimum execution time of direct Carleman Bilinearization,
% using sparsity, of filters + loudspeaker A
%

% CBVK Toolbox
% JHMG, PMSB 2016


clear

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

arq='mCB_sp_AfiltA_P4';  % Ouput file

warning('off','cbvk:mtredsp');
warning('off','cbvk:carlbidirsp');
%------------------------------------------


% Literal model
[f,g,h,x,names,values]=dloudAfiltA_lit;      % Regenerate model to be sure


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

[F1i,F1c,F11] = mtredsp(f,x,P);
[G1i,G1c,G11] = mtredsp(g,x,P-1);

% Numerical evaluation
m=length(x);
[F1cn,F11n,G1cn,G11n]=evtredsp(m,F1c,F11,G1c,G11,names,values);


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

dt=zeros(1,rep);

for r=1:rep
  tic
  [Fi,Fc,Gi,Gc] = carlbidirsp(F1i,F1cn,G1i,G1cn,G11n,P);
  dt(r)=toc;
  fprintf('%g\n ', dt(r));
end

min(dt)
%save(arq,'dt');
warning('on','cbvk:mtredsp');
warning('on','cbvk:carlbidirsp');

