# How can I express the matrix equality as constraint in cvx?

My matlab code:

function chi = Solve_chi(eps,y,n,AllPau,Phi)
d = 2^n;

cvx_begin

variable chi(d^2,d^2) hermitian;
chi == hermitian_semidefinite(d^2);

minimize(norm(vec(chi),1));

subject to
norm(y-Phi*vec(chi),2) <= eps;
chi >= 0;
E2 = zeros(d);
for i=1:16
for j=1:16
E2 = E2+chi(i,j)*AllPau{j}'*AllPau{i};
end
end
E2 == eye(d);

cvx_end

end

What I get for chi is a 16*16 matrix with all element NaN + NaNi. It is wrong clearly. While I know using for-loop may cause problem, but I don’t know other method to express \sum_{\alpha, \beta} \chi_{\alpha \beta} \Gamma_\beta^{\dagger} \Gamma_\alpha=I_d.

I think you want to declare
expression E2(d,d) instead of zeros(d) . See The Basics — CVX Users' Guide .
All elements of E2 will be initialized to zero, so there is no need to do that explicitly.

As to whether it will then be correct, I don’t know because I don’t understand the notation and conventions in the image.

Thanks, I changed the “chi>=0” to “chiE == semidefinite( d^2 )” and deleted “norm(y-Phi*vec(chi),2) <= eps;”, it worked. Then I will make further changes.