# How to constraint every element of a vector?

cvx_begin quiet
variable v(N+1) complex
variable t
dual variables y

``````                numerator = Pt(i)*(v0'*G2*G2'*v0)*(v0'*G1*G1'*v0)^2-r2*sigma*(v0'*G1*G1'*v0)^2;
numerator_first = Pt(i)*2*G2*G2'*v0*(v0'*G1*G1'*v0)^2+(v0'*G2*G2'*v0)*2*(v0'*G1*G1'*v0)*2*G1*G1'*v0-r2*sigma*2*(v0'*G1*G1'*v0)*2*G1*G1'*v0;
denominator = r2*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0)+(v0'*G1*G1'*v0)*(v0'*G2*G2'*v0);
denominator_first = r2*((G1*G2'+G2*G1')*v0*(v0'*G2*G1'*v0)+(v0'*G1*G2'*v0)*(G2*G1'+G1*G2')*v0)+2*G1*G1'*v0*(v0'*G2*G2'*v0)+(v0'*G1*G1'*v0)*2*G2*G2'*v0;
f = numerator/denominator;
f_first = (numerator_first*denominator-numerator*denominator_first)/denominator^2;

numerator2 = Pt(i)*r2*((v0'*G1*G2'*v0)*(v0'*G2*G1'*v0))^2+r2*sigma*(v0'*G1*G1'*v0)*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0);
numerator2_first = Pt(i)*r2*2*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0)*((G1*G2'+G2*G1')*v0*(v0'*G2*G1'*v0)+(v0'*G1*G2'*v0)*(G2*G1'+G1*G2')*v0)...
+r2*sigma*(2*G1*G2'*v0*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0)+(v0'*G1*G1'*v0)*((G1*G2'+G2*G1')*v0*(v0'*G2*G1'*v0)+(v0'*G1*G2'*v0)*(G2*G1'+G1*G2')*v0));
denominator2 = r2*(v0'*G2*G2'*v0)*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0)+(v0'*G1*G1'*v0)*(v0'*G2*G2'*v0)^2;
denominator2_first = r2*(2*G1*G2'*v0*(v0'*G1*G2'*v0)*(v0'*G2*G1'*v0)+(v0'*G2*G2'*v0)*((G1*G2'+G2*G1')*v0*(v0'*G2*G1'*v0)+(v0'*G1*G2'*v0)*(G2*G1'+G1*G2')*v0))...
+2*G1*G2'*v0*(v0'*G2*G2'*v0)^2+(v0'*G1*G1'*v0)*2*(v0'*G2*G2'*v0)*2*G2*G2'*v0;
f2 = numerator2/denominator2;
f2_first = (numerator2_first*denominator2-numerator2*denominator2_first)/denominator2^2;

maximize (t)
subject to
real((f+f_first'*(v-v0))/sigma)>=t;
real((f+f_first'*(v-v0))/sigma)>=r1*sigma;
real(f2-r2*f+(f2_first-r2*f_first)'*(v-v0))>=r2*sigma
for e=1:N
norm(v(e))==1;
end
v(N+1)==1;

cvx_end
``````

Disciplined convex programming error: Invalid constraint: {positive convex} == {1}

I tried in another programme, it is work in a matrix like this:
for e=1:N+1
norm(V(e,e))==1;
end

Rule number number 1 is you cannot have nonlinear equalities in your model if it is going to be convex. To me it seems you violate that rule.

So, if I want to limit every element of my variable ‘v’ what should I do?
Many thanks!

You can do `norm(v(e))<=1`, but an equality here makes a nonconvex constraint and CVX cannot be used for that.

ok, actually I have tried norm(v(e))<=1, but the result was “inaccurate/solved”.

If you disable `quiet` and paste the full log output then maybe it will be possible to say more about the numerical issues leading to `inaccurate`.