clear all

stepX = 3;
stepY = 3;
width = 16*2;
height = 9*2;
width = 640;
height = 480;
x = 1:stepX:width; if x(end)<width; x(end+1) = width;end
y = 1:stepY:height; if y(end)<height; y(end+1) = height;end
[X,Y] = meshgrid(x,y);
Fx = X + rand(size(X))*stepX/4-stepX/8;
Fy = Y + rand(size(Y))*stepY/4-stepY/8;

s.f1= zeros(size(X)-1);
s.f12 = zeros(size(X)-1);
s.f41 = zeros(size(X)-1);
s.f1324 = zeros(size(X)-1);
s.g1 = zeros(size(X)-1);
s.g12 = zeros(size(X)-1);
s.g41 = zeros(size(X)-1);
s.g1324 = zeros(size(X)-1);
s.c1 = zeros(size(X)-1);
s.c2 = zeros(size(X)-1);
s.c3 = zeros(size(X)-1);

% t = zeros(1,1000);
% for i = 1:1000
% Fx = X + rand(size(X))*stepX/4-stepX/8;
% Fy = Y + rand(size(Y))*stepY/4-stepY/8;
%  tic
%[dd,s.f1,s.f12,s.f41,s.f1324, s.g1,s.g12,s.g41,s.g1324, s.c1,s.c2,s.c3] = MLS_applyDeform2(x,y,X,Y,Fx,Fy,s.f1,s.f12,s.f41,s.f1324, s.g1,s.g12,s.g41,s.g1324, s.c1,s.c2,s.c3);
%  t(i) = toc;
% end
% fprintf('%f\n',mean(t))

gg = 9*6;

tic
for i = 1:numel(X)   
    r1 = rand(1,1)*50;
    y = nonPersistent_test_call(r1,X);
end
toc


tic
r1 = rand(1,1)*50;
y = test_call(r1,X);
for i = 1:numel(X)-1   
    r1 = rand(1,1)*50;
    y = test_call(r1,X);
end
toc

% tic
% for i = 1:numel(X)   
%     r1 = rand(gg,1)*50;
%     y = test_call_mex(r1);
% end
% toc