[我在这里关注答案]
我正在尝试在 CVXOPT 中提供稀疏矩阵。考虑以下最小示例:
import numpy
import cvxopt
import scipy.sparse
K = 10
n = 36
g_0 = numpy.random.randn(n, K)
d_0 = numpy.zeros(n) + 1.0
g_2 = scipy.sparse.dia_matrix(([d_0], [0]), shape=(n, n))
g_3 = scipy.sparse.dia_matrix(([-d_0], [0]), shape=(n, n))
g_1 = scipy.sparse.coo_matrix(g_0)
g_4 = scipy.sparse.hstack([g_1, g_2, g_3])
A = cvxopt.spmatrix(g_4.data.tolist(), g_4.col.tolist(), g_4.row.tolist(), size = g_4.shape)
我得到:
TypeError: dimension too small
这是一个错误还是(更有可能)我误解了这个答案?