Matrix quadratic form

I am trying to minimize the function f(Z)=v^TZZ^Tv, for a given vector v. It is easy to check that this function is convex. My cvx code looks as follows

cvx_begin
    cvx_precision best
    variable Zopt(D,n);
    minimize quad_form(vin,Zopt*Zopt');
cvx_end

I got the error: “Disciplined convex programming error: Only scalar quadratic forms can be specified in CVX”
. Since v is a vector the result of v^TZZ^Tv is indeed a scalar. So it is not clear to me, why I get the above error. I guess my code is not in the DCP form, but after going through the cvx guide, I could not come up with a better way.

How about sum_square(Zopt'*vin)?

In fact, there’s no reason to use a quadratic here. An even better choice is norm(Zopt'*vin). See this section for more information.

The reason you get the error is that CVX is not a parser. It cannot evaluate the quad_form expression in total; it must evaluate each expression as it is encountered. Yes, v^TZZ^Tv is a scalar, but what it is seeing at that point is ZZ^T, which is not.

Thanks for the quick reply. So sum_square(Zopt’*vin) will work, but norm(Zopt’*vin) will not work. Instead, one can also do pow_pos(norm(Zopt’*vin),2).

Why doesn’t norm(Zopt'*vin) work? It is true that will give you a different objective value. But it’s just the square root of the value you’re seeking. The optimal point it will return is identical. Of course, if you’re adding other terms to the objective it is not equivalent.

oops. I forgot to mention that the above term is one term in a sum of two terms, and hence, would not work on the whole. Sorry I forgot to mention this.