% Measures the  minimum execution time of literal redundant Taylor expansion
% (using sparsity) of integrator + loudspeaker A and its numerical
% evaluation

%   CBVK Toolbox
%   JHMG, PMSB 2016


clear

P=3;        % Expansion order
rep1=50;   % Number of repetitions for greater precision of execution
            % time measurement
rep2=100;

arq1='mtaylor_sp_Aitgr_P3';  % Ouput F1ile
arq2='mtaylor_esp_Aitgr_P3'; % Ouput F1ile
% --------------------------------------------------------------------

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

dt=zeros(1,rep1);
warning('off','cbvk:mtredsp');

for r=1:rep1
tic
[F1i,F1c,F11] = mtredsp(f,x,P);
[G1i,G1c,G11] = mtredsp(g,x,P-1);
dt(r)=toc;
fprintf('%g\n ', dt(r));
end

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



dt=zeros(1,rep2);

% Numerical evaluation
m=length(x);
for r=1:rep2
tic
[F1cn,F11n,G1cn,G11n]=evtredsp(m,F1c,F11,G1c,G11,names,values);
dt(r)=toc;
fprintf('%g\n ', dt(r))
end

min(dt)
%%save(arq2,'dt');

