CVX blkdiag bug

The CVX override for Matlab’s blkdiag function has a crippling bug. Using blkdiag seems to create some sort of corrupted expression. Attempting to use many different types of basic operations on this expression causes errors in a reshape step. Here is a minimum working example.

dim1 = 2;
dim2 = 8;

cvx_begin sdp
variable rho1(dim1,dim1) Hermitian semidefinite;
variable rho2(dim2,dim2) Hermitian semidefinite;

expression rho(dim1+dim2,dim1+dim2)

%version 1 works
% rho(1:dim1,1:dim1) = rho1;
% rho(dim1+1:end,dim1+1:end) = rho2;

%version 2 cvx fails
rho = blkdiag(rho1,rho2);

identity = eye(dim1+dim2);
rho = rho*identity; % <-- error here

minimize trace(rho)


and the error:

Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically
calculate the appropriate size for that dimension.

Error in cvx_reshape (line 52)
        x = reshape( x, s );

Error in  *  (line 173)
    z2 = cvx_reshape( xA, [ nA * sx( 1 ), sx( 2 ) ] );

Error in cvxBlkDiagTest (line 19)
rho = rho*identity; % <-- error here

It is likely linked to About”blkdiag”. Dimensions with subscripts do not match. Considering how old the other post, is CVX no longer in development?

CVX is not under active development.

However, see Announcement: CVX for Apple Silicon - #8 by Michal_Adamaszek regarding possibility of CVX being open-sourced in the future.

Updated information:

1 Like