Python numpy.linalg 模块,matrix_power() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用numpy.linalg.matrix_power()

项目:flurs    作者:takuti    | 项目源码 | 文件源码
def __verify_spectral(self, C, p_failure):
        d = C.shape[0]
        c = 1  # some constant

        if not hasattr(self, 'i_verify'):
            self.i_verify = 0

        self.i_verify += 1
        p_failure_i = p_failure / (2 * (self.i_verify ** 2))

        # pick a point uniformly at ranom from the d-dimensional unit sphere
        # http://stackoverflow.com/questions/15880367/python-uniform-distribution-of-points-on-4-dimensional-sphere
        normal_deviates = np.random.normal(size=(d, 1))
        radius = np.sqrt((normal_deviates ** 2).sum(axis=0))
        x = normal_deviates / radius

        return ln.norm(np.dot(ln.matrix_power(C, int(c * np.log(d / p_failure_i))), x)) <= 1
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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
项目:radar    作者:amoose136    | 项目源码 | 文件源码
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
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:radar    作者:amoose136    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
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
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:krpcScripts    作者:jwvanderbeck    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:graph_cnn    作者:hechtlinger    | 项目源码 | 文件源码
def generate_Q(n,q_power):
    ''' 
    Generate Q^{q_power} for n variables.
    '''
    transition_matrix = generate_grid_transition_matrix(n)
    q_tmp = tr_0 =  np.identity(n**2)
    for k in range(1,q_power+1):
        q_tmp += LA.matrix_power(transition_matrix, k) 
    return np.array(normalize(q_tmp, norm='l1', axis=1),dtype = 'float32')
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
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
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
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
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda    作者:SignalMedia    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
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
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:aws-lambda-numpy    作者:vitolimandibhrata    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
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
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:lambda-numba    作者:rlhotovy    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
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
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))
项目:deliver    作者:orchestor    | 项目源码 | 文件源码
def test_square(self):
        A = array([[True, False], [True, True]])
        assert_equal(matrix_power(A, 2), A)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_large_power(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5 + 1), self.R90)
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_large_power_trailing_zero(self):
        assert_equal(
            matrix_power(self.R90, 2 ** 100 + 2 ** 10 + 2 ** 5), identity(2))
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
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
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def testip_two(self):
        def tz(M):
            mz = matrix_power(M, 2)
            assert_equal(mz, dot(M, M))
            assert_equal(mz.dtype, M.dtype)
        for M in [self.Arb22, self.arbfloat, self.large]:
            yield tz, M
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def test_invert_noninvertible(self):
        import numpy.linalg
        assert_raises(numpy.linalg.linalg.LinAlgError,
                      lambda: matrix_power(self.noninv, -1))