Kronecker product of sparse matrices
When taking the kronecker product of a two Biaffine expressions, the matrices are converted to dense numpy matrices and the kronecker product is taken using numpy.kron:
def _kron(A, B):
A_B = load_data(numpy.kron(cvx2np(A), cvx2np(B)), typecode=tc)[0]
Kab = cvxopt_K(A.size[1], B.size[1])
return In_Kqm_Ip*A_B*Kab
In my case, I run out of memory because of this. I replaced the code with the following:
def _kron(A, B):
if isinstance(A, cvxopt.spmatrix) or isinstance(B, cvxopt.spmatrix):
A_B = load_data(scipy.sparse.kron(cvx2csc(A), cvx2csc(B), format='csc'), typecode=tc, sparse=True)[0]
else:
A_B = load_data(numpy.kron(cvx2np(A), cvx2np(B)), typecode=tc)[0]
Kab = cvxopt_K(A.size[1], B.size[1])
return In_Kqm_Ip*A_B*Kab
Edited by Thomas Dubach