%%%%% Create Instance of Tanigawa's Example
%
% n := dimension

function [P,A,b,X0] = MakeProblemTanigawa(n,m)

tn = n*(n+1)/2;
In=eye(n);
A = zeros(m,tn);
b = zeros(m,1);

%construct the gram matrix from which to construct b 
P1 = sort(rand(n-3,1));
P2 = sqrt(ones(n-3,1)-P1.^2);
P = [1 0; 1 0;P1 P2;0 1];
X0 = P*P';

m = 2*n;   % number of constraints
A = zeros(m,tn);
b = zeros(m,1);
In=eye(n);
for ii=1:n-1,       %all the constraints except the (1,n) element
    temp=In(:,ii)*In(:,ii)';        %elements on the diagonal
    A(ii,:)=ssvec(temp)';
    b(ii) = X0(ii,ii);
    temp=In(:,ii)*In(:,ii+1)';      %elements on the off-diagonal
	temp=temp+temp';
    A(ii+n,:)=ssvec(temp)';
    b(ii+n) = 2*X0(ii,ii+1);
end

temp=In(:,n)*In(:,n)';        %the (n,n) element
A(n,:)=ssvec(temp)';
b(n) = X0(n,n);
temp=In(:,1)*In(:,n)';      %the (n,1) element
temp=temp+temp';
A(2*n,:) = ssvec(temp)';
b(2*n) = 2*X0(n,1);


end     %end function










