% evalvecpoly(x,d,lambda) returns the vector p obtained by
% evaluating the vector polynomial x of degree d at the
% value lambda.

function p = evalvecpoly(x,d,lambda)

nx = length(x);
if (rem(nx,d+1) ~= 0)
  error('length of x must be divisible by d+1');
end
n = nx/(d+1);
p = zeros(n,1);

lambda_raisedto_j = 1;
for j=0:d
  p = p+lambda_raisedto_j*x(j*n+1:(j+1)*n);
  lambda_raisedto_j = lambda_raisedto_j*lambda;
end
