# Error using * (line 126) Disciplined convex programming error: Only scalar quadratic forms can be specified in CVX

Hi,I’m trying to solve a convex optimization problem in cvx. the following is my code:
cvx_begin sdp
variable Wk(Nm,Nm) complex symmetric
minimize(real(trace(Wk*Dk)))
subject to
real(trace(Wk))<=(Pth/Nm)

real(trace(Wk* CHMB_MU(kk,:)’* CHMB_MU(kk,:)- gama_min* temp))>=gama_min* sigma2
Wk>=0
cvx_end
cvx_begin
variable Ek(M-1,Nm) complex
minimize(real(trace(Wk* Hk_tilt’* Hk_tilt+ Wk* Hk_tilt’* Ek+ Wk* Ek’* Hk_tilt+ Wk* Ek’* Ek))+lambda* Ltwoone_norm(Ek))
cvx_end

but i get the fallowing errors:
Error using * (line 126)
Disciplined convex programming error:
Only scalar quadratic forms can be specified in CVX.
where (Wk,Hk_tilt,temp,Dk) are complex matrix and (pth,gama_min,sigma2,lambda) are non-negative constant and CHMB_MU is complex vector.
thanks

The non-DCP-compliant term is `trace(Wk* Ek’* Ek)`

If `Ek` were real and `Wk` symmetric psd, then it could be rewritten as
`trace(Wk*Ek’*Ek) = trace(chol(Wk)'*chol(Wk)*Ek'*Ek) = trace(chol(Wk)*Ek'*Ek*chol(Wk)') = sum(vec(Ek*chol(Wk)').*vec(Ek*chol(Wk)'))`
with the latter-most expression being accepted by CVX.

For general `W`, this is not convex. For instance, in one dimension, if `Wk = -1` and `Ek` is real, then `trace(Wk*Ek'*Ek) = -Ek^2` which is not convex.

I sincerely appreciate your guidance and time. But the Wk, Ek matrix are PSD and complex ,respectively. How i get rid of this errors?
Also, in the case I want Wk to be dp and symmetric matrix not sdp. Is my code in first part cvx correct? If not how to write this variable in cvx .

When Wk is symmetric psd and E is complex (but not real), then
`trace(Wk*Ek’*Ek) = trace(chol(Wk)'*chol(Wk)*Ek'*Ek) = trace(chol(Wk)*Ek'*Ek*chol(Wk)')`
is still valid, but this does not generally equal
`sum(vec(Ek*chol(Wk)').*vec(Ek*chol(Wk)'))`

I leave it to you and others to check the correctness of the following (especially considering Ek is complex, so maybe the Schur complement formulation in my referenced answer is not correct for this usage), so use at your own peril:
Presuming `Wk` is symmetric positive definite, so that its inverse exists, I think you can re-write as
`trace(Wk*Ek’*Ek) = trace(Ek * inv(inv(Wk)) * Ek')`
then use my solution at Generalizing "trace_inv" for matrix quadratic forms, with `inv(Wk)` in place of `X` and `Ek` in place of `C`, and with the requisite variable declarations.