Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVX blkdiag bug #23

Open
JBurniston opened this issue Apr 23, 2024 · 0 comments
Open

CVX blkdiag bug #23

JBurniston opened this issue Apr 23, 2024 · 0 comments

Comments

@JBurniston
Copy link

Copying Issue over from the forms.

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)

cvx_end

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant