# SDP problem about using real function

Hi. i wrote this code:
cvx_begin
variables W_1(M,M);
variable W_2(M,M);
maximize(eta**real((trace(H_01_cvxW_1+trace(H_01_cvxW_2)))))
subject to
W_1==semidefinite(M);
W_2==semidefinite(M);
(trace(W_1) + trace(W_2)) <= P_w_max;
real(trace(H_cu_1W_2)) + sigma2_w <= real(trace(H_cu_1W_1))/(saai_w);
real(trace(H_cu_2W_1)) + sigma2_w <= real(trace(H_cu_2W_2))/(saai_w);
cvx_end

and i use real in the objective func. is it true? is there any other way to write this code? i think i lost some information when i use real function.

It’s your problem and your input data, so how are we supposed to know? Use `real` id you want to extract the real part, or it there is an expression which would be exactly real in exact arithmetic, but may have a roundoff level imaginary term if double precision arithmetic. Given that you haven’t declared any variables as `complex`, everything in your program will already be real, unless some input data is complex. So is the input data complex? Do you want the CVX variables to be complex?

1 Like

thanks a lot for your reply. its my first time i use cvx and this problem is part of a sub problem in an article. yes i want that my variables be complex. in the objective func the H_01_cvx is a complex matrix and in subject, H_cu_1 and H_cu_2 is complex also.
i wrote again this code and this time i wrote variabe W_1(M,M) complex; and variabe W_2(M,M) complex;
i dont know is it true or not.