% This generate tests

tol = 1e-4;
repeats = 10;
randn('seed',0);
fprintf(' this uses covariance matrices\n')


fid = fopen('cond_poly.txt','w');

for n = [50 60]
  for m = [80 100 120]
    
    condQ = 0;
    iptime = 0;
    iptime2 = 0;
    ipcond = 0;
    admtime = 0;
    admcond = 0;
    admiter = 0;
    
    for s = 1:repeats
      
      M = zeros(n^2,m);
      % generate random covariance matrices
      tmp = inf;
      for i = 1:m
        A = randn(n,n);
        A = A*A';
        tmp = min(tmp,cond(A));
        M(:,i) = reshape(A,n^2,1);
      end
      condQ = condQ + tmp;
      
      time0 = clock;
      [t,X,time] = condition_se_dual2(M);
      time2 = etime(clock,time0);
      iptime2 = iptime2 + time2;
      fprintf(' sedumi_total_time = %g\n', time2)
      iptime = iptime + time;
      ipcond = ipcond + t;
      
      [t,X,time,iter] = condno_adm(M,1e-4,inf);
      admtime = admtime + time;
      admcond = admcond + t;
      admiter = admiter + iter;
      
    end
    
    condQ = condQ/repeats;
    iptime2 = iptime2/repeats;
    iptime = iptime/repeats;
    ipcond = ipcond/repeats;
    admtime = admtime/repeats;
    admcond = admcond/repeats;
    admiter = admiter/repeats;
    
    fprintf(fid,' %3d & %3d & %4.3e & %5.2f(%5.2f) & %5.2f(%5.0f) & %5.2f & %5.2f \n', n, m, condQ, iptime, iptime2, admtime, admiter, ipcond, admcond)
    
  end
end
