本文整理汇总了Python中sympy.Matrix.berkowitz_charpoly方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.berkowitz_charpoly方法的具体用法?Python Matrix.berkowitz_charpoly怎么用?Python Matrix.berkowitz_charpoly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Matrix
的用法示例。
在下文中一共展示了Matrix.berkowitz_charpoly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: automaton_growth_func
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import berkowitz_charpoly [as 别名]
def automaton_growth_func( automaton, initial_state, variable='z' ):
"""Returns Z-transform of the growth function of this automaton
Uses SYmpy for calculations"""
from sympy import Symbol, Matrix, eye, cancel
z = variable if isinstance(variable,Symbol) else Symbol(variable)
n = automaton.num_states()
a_,b_,c_ = growth_matrices(automaton, initial_state)
#a.print_nonzero()
c = Matrix( 1, n, c_)
b = Matrix( n, 1, b_)
a = Matrix( a_)
del a_, b_, c_
#(z*eye(n)-a).inv().print_nonzero()
if False: #naiive implementation
q = z*eye(n)-a
f = c * q.LUsolve(b) * z
assert f.shape == (1,1)
return f[0,0]
if True:
#use trick...
den = a.berkowitz_charpoly(z)
#print("#### charpoly:", den)
num = (a - b*c).berkowitz_charpoly(z) - den
#print("#### numerator:", num)
return num/den
示例2: test_Matrix_berkowitz_charpoly
# 需要导入模块: from sympy import Matrix [as 别名]
# 或者: from sympy.Matrix import berkowitz_charpoly [as 别名]
def test_Matrix_berkowitz_charpoly():
x, UA, K_i, K_w = symbols('x UA K_i K_w')
A = Matrix([[-K_i - UA + K_i**2/(K_i + K_w), K_i*K_w/(K_i + K_w)],
[ K_i*K_w/(K_i + K_w), -K_w + K_w**2/(K_i + K_w)]])
assert A.berkowitz_charpoly(x) == \
Poly(x**2 + (K_i*UA + K_w*UA + 2*K_i*K_w)/(K_i + K_w)*x + K_i*K_w*UA/(K_i + K_w), x, domain='ZZ(K_i,K_w,UA)')