view m-toolbox/test/new_ltf_code/test_ltpda_ltf_plan.m @ 12:86aabb42dd84 database-connection-manager

Use utils.repository utilities
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

function test_ltpda_ltf_plan

% A test script for ltpda_ltf_plan
% 
% M Hewitson 19-02-08
% 
% $Id: test_ltpda_ltf_plan.m,v 1.2 2008/02/20 07:25:49 hewitson Exp $
% 

%% Read C-code results
in = load('results.txt');

% 	  printf ("%4d %10g %10g %10g %7d %7d %5.3f %5.3f %10g ", j,
% 		  p1->f, p1->fres, p1->bin, p1->nseg, p1->dftlen,
% 		  dfdown / p1->fres, dfup / p1->fres, logres);

rf = in(:,2)';
rr = in(:,3)';
rb = in(:,4)';
rL = in(:,6)';
rK = in(:,5)';


%% Run MATLAB code

% values taken from C-code
Ndata = 1000000;
fs    = 10;
olap  = 75;
bmin  = 5.3;
Lmin  = 100;
Jdes  = 200;
Kdes  = 100;


[f, r, b, L, K] = ltpda_ltf_plan(Ndata, fs, olap, bmin, Lmin, Jdes, Kdes);

%% Test values
disp('------------------------')
disp(sprintf('* Test f: %d', vequal(f, rf)))
disp(sprintf('* Test r: %d', vequal(r, rr)))
disp(sprintf('* Test b: %d', vequal(b, rb)))
disp(sprintf('* Test L: %d', vequal(L, rL)))
disp(sprintf('* Test K: %d', vequal(K, rK)))
disp('------------------------')


%% Compare to old scheduler

[f, r, b, L, K] = ltpda_ltf_plan(Ndata, fs, olap, bmin, 0, Jdes, Kdes);
[of,or,ob,oL,rr,rrr] = ltpda_compute_f(fs, Ndata, Kdes, 2, Jdes, olap,0);

figure
plot(of, or, f, r)

% Test if two vectors are nearly equal
function res = vequal(v1,v2)

smallNum = 1e-12;

if max(abs(v1-v2)) < smallNum
  res = 1;
else
  res = 0;
end


% END