Python:将numpy矩阵映射到矩阵

时间:2015-12-01 18:19:09

标签: python numpy dictionary matrix

我需要一些结构,如:

from numpy import *

myDict = {
    matrix([ 0,0,0 ]): matrix([ 0,0,0 ]),
    matrix([ 0,0,1 ]): matrix([ 0,1,0 ]),
    matrix([ 0,1,0 ]): matrix([ 0,1,1 ]),
    matrix([ 0,1,1 ]): matrix([ 1,0,0 ]),
    matrix([ 1,0,0 ]): matrix([ 1,0,1 ]),
    matrix([ 1,0,1 ]): matrix([ 1,1,0 ]),
    matrix([ 1,1,0 ]): matrix([ 0,0,1 ]),
    matrix([ 1,1,1 ]): matrix([ 1,1,1 ]),
}

但是,当我调用 myDict [matrix([0,1,1])] 时,它会引发KeyError。 那么,如何在Python中实现矩阵到矩阵的映射?

0 个答案:

没有答案