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

How to represent the frobenius norm in QCML? #55

Open
dgrnbrg opened this issue May 22, 2017 · 2 comments
Open

How to represent the frobenius norm in QCML? #55

dgrnbrg opened this issue May 22, 2017 · 2 comments

Comments

@dgrnbrg
Copy link
Contributor

dgrnbrg commented May 22, 2017

I'd like to represent this CVX model in QCML:

n = size(A,1);
cvx_begin sdp
    variable B(n,n)
    minimize(norm(A-B,'Fro'))
    subject to
        B+B' >= 0
cvx_end

But I'm not sure what the best way to express the norm(A-B,'Fro') component is.

@dgrnbrg
Copy link
Contributor Author

dgrnbrg commented May 31, 2017

I believe I ported the model to QCML correctly, however, I am getting an error in the generated code. The QCML model I'm using is:

dimensions n
variable B(n,n)
parameter A(n,n)
minimize norm2(A - B)
subject to
  B + B' >= 0

but when I try to compile the generated C code, I get this error:

psd.c:81:81: error: assigning to 'double' from incompatible type 'qc_matrix' (aka 'struct coo')
    for(i = 0; i < dims->n * dims->n; ++i) data->h[i + (1 + dims->n * dims->n)] = params->A[i];
                                                                                ^ ~~~~~~~~~~~~
psd.c:119:13: warning: incompatible pointer types assigning to 'qc_matrix *' (aka 'struct coo *') from 'const double *' [-Wincompatible-pointer-types]
    vars->B = x + 0;  /* length dims->n * dims->n */
            ^ ~~~~~
1 warning and 1 error generated.
make: *** [psd.o] Error 1

It looks like the issue is that the A and B matrices are of type qc_matrix * in the generated code, but the way I've declared them is making the system think that they're scalar, possibly? Could you let me know if I'm expressing something in an obviously incorrect way?

@echu
Copy link
Collaborator

echu commented May 31, 2017 via email

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

2 participants