當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。