# Efficient way to have non negative elements in a matrix in CVX

Dear CVX Team,

I am solving a problem which constraints on its positive semidefinite matrix variable X of components x_{i,j} require that all of such components are non negative that is:

At the moment I am modelling these constraints with the following code

     for i=1:n
for j=1:n
X(i,j)>=0
end
end


but knowing the inefficiencies that matlab has when it comes to for cycles, I was wondering if there is a better way to give these constraints in input to cvx.

Regards,

V. L.

The following choices will work:
X(:) >= 0 (always works)
or
vec(X) >= 0 (always works, presuming you have the vec which comes with CVX)
or
X >= 0 (if not in sdp mode)

Thank you it works. It is a pity that it did not get any faster though.

V. L.