求解线性方程,其中每个矩阵元素本身是矩阵 (2D),每个变量都是一维向量

Solving linear equations where each matrix element itself is matrix (2D) and each variables are 1D vectors

问题的简单例子是:

就我而言:

非常感谢idea/suggestion。

只要尺寸符合,A 实际上是 "just" 矩阵,即使它是由更小的矩阵构建而成。这是一个相对通用的示例,显示了尺寸必须如何变化:

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)