% P3
% Test Polyvec
clc
randn('seed',0)
n = 100; p = 4; d = 10;
A = randn(n,n); A = triu(A,-p);
c = randn(d,1);

y = Polyvec(c,A,p);

% Naive method...
e1 = zeros(n,1); e1(1) = 1;
z = e1;
y0 = zeros(n,1);
for k=1:d
y0 = y0 + c(k)*z;
z = A*z;
end

% Compare...
err = norm(y-y0)/norm(y0)