% Antti Hannukainen
%
% Evaluate polynomial presented in multi_index - type basis
%
% G = coefficients 
% X = points in a Matrix : each row = 1 point 
% 
% deg = degree of G
%

function Y=mpolyeval(G,X,deg)

dim = size(X,2);
A = [];


for m=0:deg
  
  u = multi_index(dim,m);
  coeff = multinomalc(u);

  for k=1:size(u,1)

    abu = 1;
    
    for i=1:size(u,2)
      abu = abu.*X(:,i).^u(k,i);
    end
    
    abu = abu*sqrt(coeff(k));
    A = [A  abu];
    
  end
end

Y = A*G