library("CVXR");
A <- Variable(3,3);
D <- matrix(c(A[1,1],0,0,0,A[2,2],0,0,0,A[3,3]),nrow=3);
A-D
Here, we have a matrix of variables, A (I am not sure if this is how to call the object correctly), and D as a matrix of variables, in which the diagonal consists of the diagonal of A, and everything else is 0.00.
I would like to be able to set constraints such as (A-D)%*%x == y,
as one would normally do, e.g. A%*%x == y would work fine.
However, R does not seem to like A-D -- "s4 object is not subtractable". How to go about this?
I think you can do:
and add the constraints
B[1,1] == 0,B[2,2] == 0,B[3,3] == 0,B %*% x == y.