答案 0 :(得分:2)
只要维数一致,即使A是由较小的矩阵构建而成的,它实际上也是“仅”一个矩阵。这是一个比较普通的示例,显示了尺寸必须如何变化:
import numpy
import numpy.linalg
l, m, n, k = 2, 3, 4, 5
# if these are known, obviously just define them here.
A11 = numpy.random.random((l, m))
A12 = numpy.random.random((l, n))
A21 = numpy.random.random((k, m))
A22 = numpy.random.random((k, n))
x1 = numpy.random.random((m,))
x2 = numpy.random.random((n,))
A = numpy.bmat([[A11, A12],
[A21, A22]])
x = numpy.concatenate([x1, x2])
b = numpy.linalg.solve(A, x)