# Invalid quadratic form(s): not a square error

(Kazi Tanzeem Shahid) #1

Hi, so I was creating this script on cvx

function [D,E] = DEcvx(cxx_final,cyy_final,cxy_final,Dw,lambdas1)

[rows columns] = size(Dw);

cvx_begin quiet

variable D(rows,columns) nonnegative
variable E(columns,rows) nonnegative

expressions val1 val2 val3 val4

for i=1:columns
for j=1:columns
summ = 0;
for k=1:rows
summ = summ + E(i,k)*D(k,j);
end
val1(i,j) = summ;
% val1(i,j) =E(i,:)*D(:,j);
end
end

for i=1:columns
for j=1:columns
val2(i,j) = val1(i,:)*cxy_final(:,j);
end
end

for i=1:columns
for j=1:columns
val3(i,j) = val1(i,:)*cxx_final(:,j);
end
end

val1_t = val1’;

for i=1:columns
for j=1:columns
val4(i,j) = val3(:,j)*val1_t(i,:);
end
end

minimize trace(cyy_final - 2val2 + val4)+lambdas1sum(E(:))+lambdas1*sum(D(:))

subject to

D >= 0
E >= 0

for i=1:columns
sum(D(:,i))==1;
sum(E(i,:))==1;
end

cvx_end

As you can see, I am trying to multiply some matrices, but using for loops as a workaround since cvx can only take scalar quadratic forms. but I get the error “Invalid quadratic form(s): not a square.” in line “summ = summ + E(i,k)*D(k,j);” in the 1st for loop.

Any help would be greatly appreciated. Thanks

(Michael C. Grant) #2

(Mark L. Stone) #3

Your workaround doesn’t work around the fact that your scalar quadratic form, being the product of 2 CVX variables, is not convex, and is not allowed by CVX. Why isn’t CVX accepting my model? READ THIS FIRST!

Have you proved that your overall optimization problem is convex? If so, how? Barring that, I’ll presume it is non-convex.