clc beta1=0.3; beta2=0.45; epsilon=1e-10; file=fopen('mainprogramoutput','w'); for n=5:15 fprintf(file,'Size of matrices involved in problem = %d\n',n); ntilde=n*(n+1)/2; counter=0; totaliterations=0; totalduration=0; for (j=1:100) U=RandOrthMat(ntilde); V=RandOrthMat(ntilde); DiagA=eye(ntilde); DiagB=eye(ntilde); for (i=1:ntilde) randomnumber=randperm(ntilde,1); if (randomnumber<=ntilde/2) DiagA(i,i)=0; else DiagA(i,i)=4*rand(1); end DiagB(i,i)=-(1+4*rand(1)); end Aoriginal=V*DiagA*U; Boriginal=V*DiagB*U; %ABoriginal=[Aoriginal,Boriginal]; %Index=randperm(2*ntilde); %AB=zeros(ntilde,2*ntilde); %for (i=1:(2*ntilde)) % AB(:,i)=ABoriginal(:,Index(i)); %end %A=AB(:,1:ntilde); %B=AB(:,ntilde+1:2*ntilde); A=zeros(ntilde); B=zeros(ntilde); for (i=1:ntilde) if (rand(1)<=0.5) A(:,i)=Aoriginal(:,i); B(:,i)=Boriginal(:,i); else A(:,i)=Boriginal(:,i); B(:,i)=Aoriginal(:,i); end end q=A*svec(eye(n))+B*svec(eye(n)); compare=0; for (i=1:ntilde) inner=max([(1+abs(q(i)))/(1+norm(A(i,:),2)),(1+abs(q(i)))/(1+norm(B(i,:),2))]); if (inner > compare) compare=inner; end end eta=max([10,sqrt(n),n*compare]); X0=eta*eye(n); Y0=eta*eye(n); tic; x=NTAlgorithm(A,B,q,X0,Y0,beta1,beta2,epsilon); elapsedtime=toc; if (isreal(x(2:2*ntilde+1))==1) totaliterations=totaliterations+x(1); totalduration=totalduration+elapsedtime; counter=counter+1; end end fprintf(file,'Number of admissible out of 100 = %d\n',counter); fprintf(file,'Average number of iterations = %f\n',totaliterations/counter); fprintf(file,'Average runtime = %f\n',totalduration/counter); fprintf(file,'\n'); end fclose(file);