%%%%% Create Instance of Levent's Bad Example
%
% r         := level of Lasserre's approximation
% svind     := to speed up svec

function [A,b,X0] = MakeProblemWaMu(r,svind)

n = 3*r+1;
tn = n*(n+1)/2;
m = 2*r;
A = zeros(m,tn);

%construct Henkel matrices for constraints
EE = zeros(r+1,r+1,m+1);
for k=1:r
    EE(:,:,k) = flipud(diag(ones(k,1),-(r+1)+k));
    EE(:,:,m+2-k) = flipud(diag(ones(k,1),(r+1)-k));
end
EE(:,:,r+1) = flipud(diag(ones(r+1,1)));

FF = zeros(r,r,m+1);
for k=1:r-1
    FF(:,:,k) = flipud(diag(ones(k,1),-r+k));
    FF(:,:,m-k) = flipud(diag(ones(k,1),r-k));
end
FF(:,:,r) = flipud(diag(ones(r,1)));
FF(:,:,m) = zeros(r);
FF(:,:,m+1) = zeros(r);

%construct constraint matrices and transform to vectors
A(1,:) = ssvec(blkdiag(EE(:,:,2),FF(:,:,1),-FF(:,:,2)),svind);
for k=3:(2*r-1)
    A(k-1,:) = ssvec(blkdiag(EE(:,:,k),FF(:,:,k-1),FF(:,:,k-2)-FF(:,:,k)),svind);
end
A(2*r-1,:) = ssvec(blkdiag(EE(:,:,2*r),FF(:,:,2*r-1),FF(:,:,2*r-2)),svind);
A(2*r,:) = ssvec(blkdiag(EE(:,:,2*r+1),zeros(r),FF(:,:,2*r-1)),svind);
b = [1;zeros(m-1,1)];
X0 = blkdiag(EE(:,:,1),FF(:,:,1),zeros(r));

end     %end function










