 # Logarithm of matrix

I have a Hermitian semi-definite matrix optimizataion. The problem is in fact a matrix entropy maximization with some other constraints which I don’t mention for simplicity.

\min_{N} \quad Tr\{N \ln(N/q_0)\} + Tr\{(\rho - N) \ln(\frac{\rho - N}{1 - q_0})\}

where 0 \leq q_0 \leq 1 and \rho (a Hermitian semi-definite matrix) are the
given parameters of optimization. And N is also a Hermitian semi-definite matrix which is variable of optimization. Note that the ln(X) is the matrix logarithm which is different from the element-wise logarithm applied to matrices. So matlab has a built-in function logm() which calculates this. But cvx does not support this logm function:

cvx_begin
variable N(2,2) hermitian semidefinite
minimize(-trace(rho *logm(rho)) + trace(N*logm(N./q0)) +  trace((rho - N)*logm((rho - N)./(1 - q0))))


gives the following error

Error using logm (line 33)
Expected input to be one of these types:

double, single


Install CVXQUAD https://github.com/hfawzi/cvxquad . Then use its quantum_entr function. There is no need to install CVXQUAD’s exponential.m replacement.