function y=ddtheta(x)
%y=ddtheta(x)
%
%y = f(x) + 1/2*rho*alpha'*alpha,
%kde f(x) = x(1)^2 + x(2)^2 + m*x(2),
%    h1(x) = -x(1) - x(2) - 1
%    h2(x) = x(1) - x(2) - 3
%    alpha(x)=max{0,h(x)}

global rho m

f = x(1)^2 + x(2)^2 + m*x(2);
h(1,1) = -x(1) - x(2) - 1;
h(2,1) = x(1) - x(2) - 3;

alpha=max(zeros(2,1), h);

Hf = [2 0;
      0 2];

if alpha(1,1)==0 && alpha(2,1)==0
   Ha=zeros(2,2);
elseif alpha(1,1)>0 && alpha(2,1)==0
   Ha=[1 1;
       1 1];
elseif alpha(1,1)==0 && alpha(2,1)>0
   Ha=[1 -1;
       -1 1];
else
   Ha=[2 0;
       0 2];
end;

y = Hf + rho*Ha;

% konec
