Dear all, I tried to add the following function to the atom library and got an error message.
f(x, y)=\begin{cases} y \cdot 2^{\frac{x}{y}}, & x > 0, y > 0\\ 0, & y = 0, x \geq 0\\ +\infty, & \text{otherwise} \end{cases}
The error message is given as:
Undefined function ‘newcnstr’ for input arguments of type ‘cvx’.
Error in < (line 22)
b = newcnstr( evalin( ‘caller’, ‘cvx_problem’, ‘’ ), x, y, ‘<’ );
Error in myfoo (line 8)
t1 = y < 0 | x <= 0;
I read the FAQ and instructions about adding functions to the atom library. Firstly, I tried to prove f(x, y) is (jointly) convex by verifing the Hessian semidefinite. The Hessian of f is given by
H(f)=\frac{\left(\ln 2\right)^2}{y} 2^{\frac{x}{y}}\begin{bmatrix} 1 & -\frac{x}{y}\\ -\frac{x}{y} & \frac{x^2}{y^2} \end{bmatrix}
Therefore it’s semidefinite. Thus, f(x, y) is convex. I imitated rel_entr
in cvx functions and wrote the self-defined function as follows:
function z = myfoo(x, y)
narginchk(2,2);
if ~isreal( x ) || ~isreal( y ),
error( 'Arguments must be real.' );
end
t1 = y < 0 | x <= 0;
t2 = y == 0 & x >= 0;
x = max( x, realmin );
y = max( y, realmin );
z = y .* 2.^( x ./ y );
z( t1 ) = +Inf;
z( t2 ) = 0;
I also tried to add this function under path cvx/functions
, however no difference.
Please enlighten me about this problem. Thanks in advance.
Regards,
Frank