%assume we already have an x setup.

K=zeros(size(x,2));
for i=1:size(K,1)
    for j=1:size(K,2)
        K(i,j)=x(:,i)'*x(:,j);
    end;
end;
C=inv(LAMBDA*double(eye(size(K)))+K)*y';

r = zeros(1,size(u,2));
for i=1:size(u,2)
    for j=1:size(x,2)
        r(i)=r(i)+C(j)*x(:,j)'*u(:,i);
    end;
end;
