# (help)Error using CVX::Disciplined convex programming error: Invalid quadratic form(s): not a square

Error using .* (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.

Error using * (line 36 )
z = feval( oper, x, y );

Error using :

` v_3=x_dataCU(k,1)*(v_1+v_2+C_tot_blk_partial+C_DC_tot_blk+eye(leng*N)+(QC_tot_blk./a_m^2))\Hhatallj_active(:,k);`

``````This is part of my code
``````
``````
iter=0;
epsilon=1;
for k=1:K
servingAPs = find(MatA(:,k) == 1);
leng=length(servingAPs);
end
while(epsilon>=0.005)
iter=iter+1;
cvx_begin
cvx_solver mosek
expression sum_C_tot_blk(N*leng, N*leng);
expression sum_C_DC_tot_blk(N*leng, N*leng);
expression QC_tot_blk(N*leng,N*leng);
variable x_dataCU(K,1);
variable V_SINRCU(K,1);
variable X_SINRD(L,1);
%         maximize (prod(V_SINRCU)*prod(X_SINRD));
maximize (sum_log(V_SINRCU) + sum_log(X_SINRD))
subject to
for l = 1:M
temp_sum = zeros(N, N);% 用于保存 CVX 变量的临时和
for k=1:K
temp_sum = temp_sum + x_dataCU(k,1)*R_CU(:,:,l,k);
end
for k1=1:L
end
QC_tot(:,:,l) = a_m*(1-a_m)*diag(diag((temp_sum + eyeN)));
end
for n=1:numb0fRealization
for k=1:K
servingAPs = find(MatA(:,k) == 1);
leng=length(servingAPs);
servedUEs = sum(MatA(servingAPs,:),1)>=1;
Hhatallj_active = zeros(N*leng,K);
C_tot_blk_partial = zeros(N*leng,N*leng);
Hhat_DC_active = zeros(N*leng,L);
C_DC_tot_blk = zeros(N*leng,N*leng);
for l=1:leng
Hhatallj_active((l-1)*N+1:l*N,:) = reshape(Hhat_CU((servingAPs(l)-1)*N+1:servingAPs(l)*N,n,:),[N K]);
Hhat_DC_active((l-1)*N+1:l*N,:) = reshape(Hhat_DC((servingAPs(l)-1)*N+1:servingAPs(l)*N,n,:),[N L]);
sum_C_tot_blk((l-1)*N+1:l*N,(l-1)*N+1:l*N) = sum(x_dataCU'.*reshape(C_CU(:,:,servingAPs(l),:),1,K));
C_tot_blk_partial((l-1)*N+1:l*N,(l-1)*N+1:l*N) = sum(C_CU(:,:,servingAPs(l),servedUEs),4);
C_DC_tot_blk((l-1)*N+1:l*N,(l-1)*N+1:l*N) = sum(C_DC(:,:,servingAPs(l),:),4);
QC_tot_blk((l-1)*N+1:l*N,(l-1)*N+1:l*N) =sum(QC_tot(:,:,1:servingAPs(l)),3);
end
%检测矩阵
v_1=0;
for same_us=find(servedUEs==1)
v_1=v_1+x_dataCU(same_us,1)*(Hhatallj_active(:,same_us)*Hhatallj_active(:,same_us)');
end
v_2=0;
for l=1:L
end
v_3=x_dataCU(k,1)*(v_1+v_2+C_tot_blk_partial+C_DC_tot_blk+eye(leng*N)+(QC_tot_blk./a_m^2))\Hhatallj_active(:,k);
numerator_A = x_dataCU(k,1)*abs(v_3'*Hhatallj_active(:,k))^2;
s1=0;
for k_1=1:K
s1=s1+x_dataCU(k_1,1)*norm((v_3'*Hhatallj_active(:,k_1)))^2;
end
s2=0;
for l_1=1:L
end
op=1;%用于设置断点
denominator_B =s1+real(v_3'*(sum_C_tot_blk+eye(leng*N)+sum_C_DC_tot_blk+(QC_tot_blk/a_m^2))*v_3)+s2-numerator_A;
prod_inv([denominator_B V_SINRCU(k,1)])-numerator_A<=0;%
V_SINRCU(k,1)>=0;
end
for k=1:K
x_dataCU(k,1)>=0;
x_dataCU(k,1)<=p_sc;
end
for l=1:L
end
end
cvx_end
``````

The RHS of that assignment includes products of different variable, which violates CVX’s DCP rules.

if this is a convex optimization problem, perhaps you need gp (Geometric Programming) mode? I don 't know, because I don’t know what all those symbols are, and the relationships between them. But it is your job to know.

Thank you very much for your answer, I was wondering whether I should use gp model or QUAD?

What is QUAD? Do you mean CVXQUAD? That is only applicable to problems involving exponential cone related functions, which are not in your program (edit: see clarification in my next post), and only recommended if you do not have Mosek available as solver; or for quantum (matrix) log and entropy related functions, which are not in your program.

Oh yeah, got it, thanks a lot.

Let me clarify. CVXQUAD is applicable when gp mode is used, due to the log transformations CVX employs under the hood. If gp mode is used, Mosek is recommended as solver; and CVXQUAD’s exponential.m replacement is recommended if Mosek is not available to you as solver.

Okay, let me try it.