/// Funkcje interpolujące/aproksymujące/estymujące

function [y] = rect(x)    
    y = 1 *(x < 1/2 & x >= -1/2);
endfunction

function [y] = hat(x)    
    y = (1 - abs(x)) .* (abs(x) < 1);
endfunction

function [y] = Keys(x)   
    a = -0.5; 
    x = abs(x);
    
    y = ((a + 2)*x.^3 - (a + 3)*x.^2 + 1) .* (x < 1) ... 
      + ...
        (a*x.^3 - 5*a*x.^2 + 8*a*x - 4*a) .* (x >= 1 & x < 2);
endfunction

function [y] = sincpi(x)    
    y = (sinc(%pi * x));// .* (abs(x) < 32);
endfunction

function [y] = Epanechnikov(x)    
    y = (1 - x.^2) .* (abs(x) < 1);
endfunction

function [z] = sinc2D(x, y)    
    z = sincpi(x)*sincpi(y);
endfunction

function [z] = rect2D(x, y)    
    z = rect(x)*rect(y);
endfunction

function [z] = hat2D(x, y)    
    z = hat(x)*hat(y);
endfunction

function [z] = Keys2D(x, y)    
    z = Keys(x)*Keys(y);
endfunction

function [z] = lincub2D(x, y)    
    z = hat(x)*Keys(y);
endfunction
