# Dealing with complex matrix, vector. CVX returns error msg

Hi all,

I normally solve the below equation manually(eigenvalue problem) (using MATLAB).
Now I would like to use cvx, for further flexibility.

The equation which I am dealing with is as the below:

What I want to get is the optimal w_{opt} based on

Maximize w^HAw subject to k = w^HBw

where, k is scalar constant, w is complex vector, A, B are Hermitian matrix which means positive semidefinite. The size of A, B are both N \times N usually N < 50 .
I have read this The DCP ruleset. The DCP ruleset mentions that “a convex scalar quadratic form”.
Then, can’t this be solvable through cvx?

I typed in cvx as the below, cvx returns the error message.

>> A = "pre-calculated Hermitian matrix";, B = pre-calculated "Hermitian matrix";
>> cvx_begin sdp
>> variables wopt(10) complex


>> maximize( quad_form(wopt, A) )
Error using type
Too many output arguments.

Error in cvx_pushobj (line 64)
cvx_dcp_error( type, 'unary', cvx_fastref( x, ~vx ) );

Error in maximize (line 15)
cvx_pushobj( 'maximize', x );


>> maximize( wopt'*A*wopt)
Error using  *  (line 155)
Disciplined convex programming error:


>> quad_form(wopt,A)
ans = cvx: positive convex
ans = cvx: positive convex


I’ve tried the example, “closest_toeplitz_psd.m”, it works but the above does not work.

It seems that it is hard to find the relative topics with this, I post this.

1 Like

I don’t know why the error is occurring, but you can reformulate, as discussed in http://cvxr.com/cvx/doc/advanced.html#eliminating-quadratic-forms .

Your constraint k = w'*B*w is non-convex and will not be accepted by CVX.

Note that you should have declared

variable wopt(10) complex

By usingvariables rather than variable you actually declared the real vector wopt and the real scalar complex

1 Like

I will try to re-formulate the above things.

Hi Mark,

It seems that it worked, let me attached what I did.
It gives the same result with the eigenvalue problem.
Since
$$w^H Aw = \text{ trace}(w^H Aw) = \text{ trace}(Aww^H) \equiv \text{ trace}(AW) \text{,}$$

I converted the above equation into trace form.

cvx_begin
variable W(N,N) hermitian
maximize(trace(A*W));
subject to
trace(B*W) <= k;
W == semidefinite(N,N);
cvx_end


However, I need to solve the eigenvalue problem about W.
Is there another way to get the w from W without using eigenvalue problem method?

Besides, the below also helped a lot.

I will leave it to Michael Grant (mcg) to offer you any further guidance on this.

1 Like

At this point is seems like we’re talking about general convex optimization modeling issues, better suited for a more general forum like Math StackExchange.

Thank you Michael, I will post this issue on the Math StackExchange.

Hello,

I still don’t understand why we need to use “trace” instead of “norm”.
Actually, “norm” is one of the CVX function. So, where is the issue?

What mathematical problem are you trying to solve? Please be specific and explicit.

Whether or not acceptable to CVX, what are the norm and trace formulations you are talking about?

Please note that the argument of norm must be affine.

help cvx/norm

Disciplined convex programming information:
norm is convex, except when P<1, so an error will result if
these non-convex "norms" are used within CVX expressions. norm
is nonmonotonic, so its input must be affine.


Also, because norm is nonlinear, it can’t be used in an equality constraint.