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


Python linalg.matrix_power方法代码示例

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


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

示例1: __pow__

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def __pow__(self, other):
        return matrix_power(self, other) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:defmatrix.py

示例2: test_returntype

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_returntype(self):
        a = np.array([[0, 1], [0, 0]])
        assert_(type(matrix_power(a, 2)) is np.ndarray)
        a = mat(a)
        assert_(type(matrix_power(a, 2)) is matrix) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_defmatrix.py

示例3: test_list

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_list(self):
        assert_array_equal(matrix_power([[0, 1], [0, 0]], 2), [[0, 0], [0, 0]]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_defmatrix.py

示例4: test_large_power

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_large_power(self, dt):
        rshft = self.rshft_1.astype(dt)
        assert_equal(
            matrix_power(rshft, 2**100 + 2**10 + 2**5 + 0), self.rshft_0)
        assert_equal(
            matrix_power(rshft, 2**100 + 2**10 + 2**5 + 1), self.rshft_1)
        assert_equal(
            matrix_power(rshft, 2**100 + 2**10 + 2**5 + 2), self.rshft_2)
        assert_equal(
            matrix_power(rshft, 2**100 + 2**10 + 2**5 + 3), self.rshft_3) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_linalg.py

示例5: test_power_is_zero

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_power_is_zero(self, dt):
        def tz(M):
            mz = matrix_power(M, 0)
            assert_equal(mz, identity_like_generalized(M))
            assert_equal(mz.dtype, M.dtype)
        
        for mat in self.rshft_all:
            tz(mat.astype(dt))
            if dt != object:
                tz(self.stacked.astype(dt)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_linalg.py

示例6: test_power_is_two

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_power_is_two(self, dt):
        def tz(mat):
            mz = matrix_power(mat, 2)
            mmul = matmul if mat.dtype != object else dot
            assert_equal(mz, mmul(mat, mat))
            assert_equal(mz.dtype, mat.dtype)

        for mat in self.rshft_all:
            tz(mat.astype(dt))
            if dt != object:
                tz(self.stacked.astype(dt)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:13,代码来源:test_linalg.py

示例7: test_power_is_minus_one

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_power_is_minus_one(self, dt):
        def tz(mat):
            invmat = matrix_power(mat, -1)
            mmul = matmul if mat.dtype != object else dot
            assert_almost_equal(
                mmul(invmat, mat), identity_like_generalized(mat))

        for mat in self.rshft_all:
            if dt not in self.dtnoinv:
                tz(mat.astype(dt)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:12,代码来源:test_linalg.py

示例8: test_exceptions_bad_power

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_exceptions_bad_power(self, dt):
        mat = self.rshft_0.astype(dt)
        assert_raises(TypeError, matrix_power, mat, 1.5)
        assert_raises(TypeError, matrix_power, mat, [1]) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_linalg.py

示例9: test_exceptions_non_square

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_exceptions_non_square(self, dt):
        assert_raises(LinAlgError, matrix_power, np.array([1], dt), 1)
        assert_raises(LinAlgError, matrix_power, np.array([[1], [2]], dt), 1)
        assert_raises(LinAlgError, matrix_power, np.ones((4, 3, 2), dt), 1) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:6,代码来源:test_linalg.py

示例10: test_exceptions_not_invertible

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_exceptions_not_invertible(self, dt):
        if dt in self.dtnoinv:
            return
        mat = self.noninv.astype(dt)
        assert_raises(LinAlgError, matrix_power, mat, -1) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_linalg.py

示例11: test_large_power

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:test_linalg.py

示例12: test_large_power_trailing_zero

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2)) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:5,代码来源:test_linalg.py

示例13: testip_zero

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def testip_zero(self):
        def tz(M):
            mz = matrix_power(M, 0)
            assert_equal(mz, identity(M.shape[0]))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:9,代码来源:test_linalg.py

示例14: testip_one

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def testip_one(self):
        def tz(M):
            mz = matrix_power(M, 1)
            assert_equal(mz, M)
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:9,代码来源:test_linalg.py

示例15: testip_invert

# 需要导入模块: from numpy import linalg [as 别名]
# 或者: from numpy.linalg import matrix_power [as 别名]
def testip_invert(self):
        def tz(M):
            mz = matrix_power(M, -1)
            assert_almost_equal(identity(M.shape[0]), dot(mz, M))
        for M in [self.R90, self.Arb22, self.arbfloat, self.large]:
            yield tz, M 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,代码来源:test_linalg.py


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