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


Python Matrix.jordan_form方法代码示例

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


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

示例1: _show_jordan_blocks

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import jordan_form [as 别名]
def _show_jordan_blocks(R):
    assert_equal(len(R.shape), 2)
    assert_equal(R.shape[0], R.shape[1])
    n = R.shape[0]
    entries = R.flatten().tolist()
    m = Matrix(n, n, entries)
    P, J = m.jordan_form()
    print('rate matrix:')
    print(m)
    print('jordan blocks:')
    print(J)
开发者ID:argriffing,项目名称:jsonctmctree,代码行数:13,代码来源:test_latent_variable.py

示例2: test_jordan_form

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import jordan_form [as 别名]
def test_jordan_form():

    m = Matrix(3,2,[-3, 1, -3, 20, 3, 10])
    raises(NonSquareMatrixError, 'm.jordan_form()')

    # diagonalizable
    m = Matrix(3, 3, [7, -12, 6, 10, -19, 10, 12, -24, 13])
    Jmust = Matrix(3, 3, [1, 0, 0, 0, 1, 0, 0, 0, -1])
    (P, J) = m.jordan_form()
    assert Jmust == J
    assert Jmust == m.diagonalize()[1]

    #m = Matrix(3, 3, [0, 6, 3, 1, 3, 1, -2, 2, 1])
    #m.jordan_form() # very long
    # m.jordan_form() #

    # diagonalizable, complex only

    # Jordan cells
    # complexity: one of eigenvalues is zero
    m = Matrix(3, 3, [0, 1, 0, -4, 4, 0, -2, 1, 2])
    Jmust = Matrix(3, 3, [2, 0, 0, 0, 2, 1, 0, 0, 2])
    assert Jmust == m.jordan_form()[1]
    (P, Jcells) = m.jordan_cells()
    assert Jcells[0] == Matrix(1, 1, [2])
    assert Jcells[1] == Matrix(2, 2, [2, 1, 0, 2])

    #complexity: all of eigenvalues are equal
    m = Matrix(3, 3, [2, 6, -15, 1, 1, -5, 1, 2, -6])
    Jmust = Matrix(3, 3, [-1, 0, 0, 0, -1, 1, 0, 0, -1])
    (P, J) = m.jordan_form()
    assert Jmust == J

    #complexity: two of eigenvalues are zero
    m = Matrix(3, 3, [4, -5, 2, 5, -7, 3, 6, -9, 4])
    Jmust = Matrix(3, 3, [1, 0, 0, 0, 0, 1, 0, 0, 0])
    (P, J) = m.jordan_form()
    assert Jmust == J

    m = Matrix(4, 4, [6, 5, -2, -3, -3, -1, 3, 3, 2, 1, -2, -3, -1, 1, 5, 5])
    Jmust = Matrix(4, 4, [2, 1, 0, 0, 0, 2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2])
    (P, J) = m.jordan_form()
    assert Jmust == J

    m = Matrix(4, 4, [6, 2, -8, -6, -3, 2, 9, 6, 2, -2, -8, -6, -1, 0, 3, 4])
    Jmust = Matrix(4, 4, [2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 0, -2])
    (P, J) = m.jordan_form()
    assert Jmust == J

    m = Matrix(4, 4, [5, 4, 2, 1, 0, 1, -1, -1, -1, -1, 3, 0, 1, 1, -1, 2])
    assert not m.is_diagonalizable()
    Jmust = Matrix(4, 4, [1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 4, 1, 0, 0, 0, 4])
    (P, J) = m.jordan_form()
    assert Jmust == J
开发者ID:robotment,项目名称:sympy,代码行数:56,代码来源:test_matrices.py

示例3: print

# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import jordan_form [as 别名]
#coding--utf-8
import numpy as np
from sympy import Matrix

f=open("/home/alber/experiment/20140721/topic_matric_30.txt",'r')
topic=[]
for line in f.readlines():
	line_list=line.split()
	topic.append(line_list[1:])
print (len(topic))
print (len(topic[1]))

m=Matrix(topic)
(p,j)=m.jordan_form()
print (len(j))
开发者ID:KAI-YIP,项目名称:nlp,代码行数:17,代码来源:matrix_jordon_normal.py


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