我有依据:
>>> m = 6
>>> basis = np.zeros((m, m))
>>> np.fill_diagonal(basis, 1)
array([[1. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0.]
[0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 1. 0.]
[0. 0. 0. 0. 0. 1.]]
如何访问向量的叠加?让我们说:
vec = [0, 1, 1, 0, 1, 0]
所以我想要输出:
array([[0. 1. 0. 0. 0. 0.]
[0. 0. 1. 0. 0. 0.]
[0. 0. 0. 0. 1. 0.]]