function  [A,b,C]=input_ex2(n,flag);
% input:  n ... problem size,
%	  flag~=0... more degenerate problem 
% output  A ... A contains A_i i=1,...,m rowwise
%	  b ... right hand side
%         C ... symmetric random matrix of order n
% solves: generates input data
%	  We consider a special SDP-problem in standard form,
%         where neither the primal nor the dual has interior
%         feasible points.
%
% call:   [A,b,C]=input_ex2(n,flag);
  

      m=0; % initialize the number of constraints m
      m1=-1; % m1 additional constraints for more degenerate problems
      
      if flag==0
	while (m<=ceil(n/3)) | (m==n)
	  m=floor(rand(1)*n);
	end;
      else % more degenerate problem
	while (m<=ceil(n/3)) | (m>floor(2*n/3))
	  m=floor(rand(1)*n);
	end;
	while (m+m1<=floor(2*n/3)) | (m+m1>=n)
	  m1=floor(rand(1)*n);
	end;
      end;
      

      % evaluation of an orthogonal matrix Q of order n
      
      Q=rand(n)*rand(1)*100;
      Q=orth(Q);


      % matrix A containing the A_i´s
	
      A=zeros(m,n^2);
      for i=1:m;	 
	A(i,:)=reshape(Q(:,i)*Q(:,i)',1,n^2);
      end;

	
      % right hand side b

      b=ones(m,1);
      b(1)=0;


      % random vector c in R^n

      c=rand(n,1)*7;
      c=ceil(c);
      c(fix(n/3))=rand(1)*100000 ;
      c(fix(n/5))=rand(1)*1000;
      c(n)=rand(1)*10000;

      % interior of dual is empty

      c(n)=0;

      % matrix C

      C=zeros(n);
	
      for i=1:n;
	H=Q(:,i)*Q(:,i)';
	C=C+c(i)*H;
      end;

	
	
	
	
	
      if m1>0
	A1=zeros(m1,n^2);
	for i=1:m1
	  Ai=Q(:,1)*Q(:,i+1)' + Q(:,i+1)*Q(:,1)';
	  A1(i,:)=reshape(Ai,1,n^2);
	end;
	b1=zeros(m1,1);
	A=[A;A1];
	b=[b;b1];
      end;

%      if m1>0
%	A=[A;A1];
%	b=[b;b1];
%      end;	
	
	
	  
	
	
	