I received a disciplined convex programming error: invalid quadratic form, product is complex.

Below is generally how I’m using CVX:

cvx_begin
variable w(N,1)
variable x
minimize(x)
subject to
H=h*h';
w'*H*w - w2'*H*(w-w2) <= constant;
w'*w <= x;
cvx_end

h is a know column vector, and w2 is known as well. H is Hermitian for sure, as it’s the product of a vector and its transpose. Is it the way of constructing H that makes it an error?

Actually there’s a loop inside CVX, and I need to construct matrix H each time from vector h, so I can’t write it before CVX. Is there any way to get rid of this error? Thanks for your response ahead!

Let H = [1 i;-i 1], which is Hermitian semidefinite.
Let w2 be the real vector [1;1].
Then w2'*H = [1-i 1+i]
Therefore,w2'*H*w is a linear function of w, but is complex, not real. As mentioned in response to one of your previous questions DCP error: {complex affine} >= {constant} , you can not have complex expressions in an inequality in CVX.

O.k., I don’t know what’s going on with that. You’ll have to wait for someone more knowledgeable than me in that area to assess that.

However, if H is not being recognized as Hermitiam, perhaps you could try “Hermitianizing” it. H = 0.5*(H+H');
However, if H was formed as a result of H = h*h'; that looks fairly “innocent” to me. But then again, i am not an expert in thee matters.

If that works, then perhaps (w'*h)*(w'*h)' will work.
The MATLAB editor provides hints to use parentheses in order to make matrix expressions which would be symmetric in exact arithmetic come out symmetric in MATLAB double precision.

When I wrote this line, the hint was to parenthesize the multiplication of vector h and its transpose. Parenthesizing w and h is the actually correct one. Thank you!