%% definition of approximation value
function [value] = Avalue ( x )

global points
global rbfrad
global weights
global regr
global beta

% value = 0;
% for i=1:size(weights,1)
%     delta = sum((points(i,:)-x(:)').^2);
%     value = value + exp( -delta/rbfrad)*weights(i);
% end

x = x';
nw = size(weights,1);
nxp = size(x,1);
value = zeros(nxp,1);
for j = 1:nxp
    delta = sum( (points(1:nw,:) - repmat(x(j,:),nw,1)).^2,2);
    value(j) = (sum(exp( -delta./rbfrad).*weights))';
end

%% Regression part
Fmatrix = feval(regr,x);
value = value + Fmatrix*beta;

%% author: Anicka Kucerova, Czech Technical University in Prague
%% version 0.1.0
%% 17 Sep 2013