CVX says trace of hermitian matrix is complex

In my problem I define matrix W1 and W2 as complex hermitian and semidefinite, H1,H2 are complex hermitian, oW is double matrix constants and N is reel scalar constant. However, I get the error

Disciplined convex programming error:
   Illegal operation: {concave} + {complex affine}

for:
maximize( log(trace(H1*(W1+W2))+N)+log(trace(H2W2)+N) …
+( -log(trace(H1
oW)+N )-log(N)-trace(H1’(W2-oW)/(trace(H1oW)+N)) ) );

Does trace function should returns me reel values for hermitian matrixes. I am using iterative algorithm and the error does not occur in each iteration.

In debugging I get

K>> trace(H1'*(W2-oW))
 
ans =
 
    cvx complex affine expression (scalar)

which makes nonesense, because it should be definitely reel not complex.

another quetion, can I force W1 and W2 being reel variables?

I’m not clear on what you are doing, because the product of two hermitian matrices is not (necessarily) hermitian.

Nevertheless, if you have an expression, trace(X), which is theoretically real, and would be if there were not roundoff error, then you can use real(trace(X)) to eliminate the roundoff level imiaginary component.

If you want to force particular variables to be real, then do not declare them to be complex (you can declare them as symmetric or semidefinite, if that’s what you want).

1 Like

the product of two hermitian matrices is not (necessarily) hermitian.

That’s what I couldn’t see. Thanks a lot.