function [A,a,b,beta,delta]=thirdclass(n,density)
% % This function generates third class of test problems of the form
%   min x'Ax+2*a'x
%       x'x<=delta
%       b'x<=beta

%===========================================================
global flag_con A a n delta
warning off
flag=1;
while flag
    A=sprandsym(n,density);
    v=full(sum(A))';
    opts.v0=v;
    opts.issym=1;
    [v,d]=eigs(A,2,'sa',opts);
    if (d(1,1)>=0)|| (abs(d(1,1)-d(2,2))<1e-4)
        flag=1;
    else
        flag=0;
      %  muu=-d(2,2)+(-d(1,1)+d(2,2))*rand;
      muu=-0.9*d(1,1)-0.1*d(2,2);
        C=A+muu*speye(n);
        xl=v(:,1);
        a=-C*xl;
        delta=norm(xl)^2;
        AAA=A-d(1,1)*speye(n);
        x=rand(n,1);
        b=AAA*x;
    end
end
%====================================================
beta=b'*xl+2;
