当前位置: 首页>>代码示例>>Python>>正文


Python Matrix.mult方法代码示例

本文整理汇总了Python中matrix.Matrix.mult方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.mult方法的具体用法?Python Matrix.mult怎么用?Python Matrix.mult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matrix.Matrix的用法示例。


在下文中一共展示了Matrix.mult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestMatrixMath

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import mult [as 别名]
class TestMatrixMath(TestCase):
    def setUp(self):
        self.am = [[0, -1, 2],[4, 11, 2]]
        self.a = Matrix(["a", "b", "c"], ["foo", "bar"], lol_to_dict(self.am))

        self.bm = [[3,-1],[1,2],[6,1]]
        self.b = Matrix(["baz", "batz"], ["l", "o", "l"], lol_to_dict(self.bm))
    
        self.cm = [[11,0],[35,20]]
        self.c = Matrix(["baz", "batz"], ["foo", "bar"], lol_to_dict(self.cm))

    
    def testMatrixMult(self):
        self.assertEquals(self.a.mult(self.b).__dict__, self.c.__dict__)


    def testMatrixMax(self):
        self.assertEquals(self.a.max, 11)
        self.assertEquals(self.b.max, 6)
        self.assertEquals(self.c.max, 35)
开发者ID:joshbohde,项目名称:red_app,代码行数:22,代码来源:tests.py

示例2: TestREDMath

# 需要导入模块: from matrix import Matrix [as 别名]
# 或者: from matrix.Matrix import mult [as 别名]
class TestREDMath(TestCase):
    def setUp(self):
        self.ecm = [[1, 1],[1, 0]]
        self.ec = Matrix(["Bearing", "Belt"], ["Import Mechanical", "Export Mechanical"]
                         , lol_to_dict(self.ecm))

        self.cfm = [[0,3],[1,0]]
        self.cf = Matrix(["Creep", "Fatigue"], ["Bearing", "Belt"], lol_to_dict(self.cfm))

        self.cfpm = [[1,2],[5,0]]
        self.cfp = Matrix(["Creep", "Fatigue"], ["Bearing", "Belt"], lol_to_dict(self.cfpm))

        self.efm = [[1,3],[0,3]]
        self.ef = Matrix(["Creep", "Fatigue"], ["Import Mechanical", "Export Mechanical"],
                         lol_to_dict(self.efm))

        self.l1m = [[2,5],[0,5]]
        self.l1 = Matrix(["Creep", "Fatigue"], ["Import Mechanical", "Export Mechanical"],
                          lol_to_dict(self.l1m))

        self.l2m = [[1,1],[0,1]]
        self.l2 = Matrix(["Creep", "Fatigue"], ["Import Mechanical", "Export Mechanical"],
                          lol_to_dict(self.l2m))

        self.c1m = [[5,2],[1,2]]
        self.c1 = Matrix(["Creep", "Fatigue"], ["Import Mechanical", "Export Mechanical"],
                          lol_to_dict(self.c1m))

        self.c2m = [[3,2],[1,2]]
        self.c2 = Matrix(["Creep", "Fatigue"], ["Import Mechanical", "Export Mechanical"],
                          lol_to_dict(self.c2m))


    def testMatrixMath(self):
        self.assertEquals(self.ec.mult(self.cf).matrix, self.ef.matrix)
    
    def testMatrixL1(self):
        self.assertEquals(self.ef.l1([0,1]).matrix, self.l1.matrix)

    def testMatrixAgg(self):
        self.assertEquals(self.ef.max, 3)

    def testMatrixL2(self):
        self.ef._max = 15
        self.assertEquals(self.ef.l2().matrix, self.l2.matrix)

    def testMatrixC1(self):
        self.assertEquals(self.ec.c1(self.cfp).matrix, self.c1.matrix)

    def testMatrixC2(self):
        self.assertEquals(self.ec.c2(self.cfp).matrix, self.c2.matrix)

    def testMaskRows(self):
        m = self.ef.mask([0])
        mat = [[1,3]]
        self.assertEquals(m.rows, ["Import Mechanical"])
        self.assertEquals(m.matrix, lol_to_dict(mat))

        m = self.ef.mask([1])
        mat = [[0,3]]
        self.assertEquals(m.rows, ["Export Mechanical"])
        self.assertEquals(m.matrix, lol_to_dict(mat))

        m = self.ef.mask([0,1])
        self.assertEquals(m.rows, self.ef.rows)
        self.assertEquals(m.matrix, self.ef.matrix)

        m = self.ef.mask([1,0])
        self.assertEquals(m.rows, self.ef.rows)
        self.assertEquals(m.matrix, self.ef.matrix)
开发者ID:joshbohde,项目名称:red_app,代码行数:72,代码来源:tests.py


注:本文中的matrix.Matrix.mult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。