I want to generate a (diagonal) block matrix (preferably sparse) in CVXPY.
Some blocks can be eye(m)
or anything but I have a block which is:
from cvxopt import *
import cvxpy as cvx
import numpy as np
import scipy
W = cvx.Variable(m,1)
W_diag = cvx.diag(W)
Then I tried to form the block diagonal matrix with W_diag
as a block, for instance, by:
T = scipy.sparse.block_diag((scipy.sparse.eye(m1).todense(), cvx.diag(W))
and I got the following error:
TypeError: no supported conversion for types: (dtype('float64'), dtype('O'))
What can I do? Other ways? I want to use matrix T
in a constraint for CVXPY later on.