  function [A,TA,b,c,xs,zs,ys,trind] = pgenprob(m,n);
% generate a random SDP with m matrices each of size n by n
%  max CX s.t. AX=b  X>=0   min yb s.t. A^*y-Z = C, Z>=0
%  INPUT: m and n
%         functions:  pgenort
%  the matrices are stored in the rows of the  m by n^2  matrix  A
%  The b vector and C matrix are also output. The optimum is stored
%  as Xs and Zs and ys. I.e. Xs*Zs=0 and feasible.
%   OUTPUT: A
%           b,c,xs,zs,ys
%             where c,xs,zs are vectors with upper triang parts
5           trind      index for upper triang part of n by n matrix
%
%   Call: function [A,b,c,Xs,Zs,ys] = pgenprob(m,n);
rand('seed',sum(100*clock));
n2=n^2;
[A,TA,trind]=pgenort(m,n);   % get m orthogonal matrices in rows of A
ys=(1/rand)*rand(m,1);
[q1,r]=qr(randn(n));
[q2,r]=qr(randn(n));
dx= (1/rand)*rand(1,n) ;
dz= (1/rand)*rand(1,n) ;
%  To generate problems with known optimum solution use ...
%t=max(1,floor(rand*m));
%dz=[zeros(1,t) ( (1/rand)*rand(1,(n-t)) )  ];
%dx=[ ( (1/rand)*rand(1,(t)) )  zeros(1,(n-t)) ];
%  To generate problems with Slater point use.....
Zs=q1*diag(dz)*q1';
zs=Zs(trind);
Xs=q2*diag(dx)*q2';
xs=Xs(trind);
C=reshape((A'*ys),n,n)-Zs;
c=C(trind);
x=reshape(Xs,n2,1);
b=A*x;
