def calculate_expm(t): num = zeros(n, n) den = zeros(n, n) s = 1 k = context.one # t^n is stored here for m_i, ai in m_a_list: aik = ai * k mat_combine_inplace(num, m_i, aik) mat_combine_inplace(den, m_i, s * aik) s = -s k *= t return solve(den, num)
def calculate_expm(t): num = zeros(n,n) den = zeros(n,n) s = 1 k = context.one # t^n is stored here for m_i, ai in m_a_list: aik = ai*k mat_combine_inplace( num, m_i, aik ) mat_combine_inplace( den, m_i, s*aik) s = -s k *= t return solve( den, num )
def expm(m, context=FloatContext, order=7): """Matrix exponent, using Pade approximation of given order """ a = _exp_pade_coeffs(order) n, n_ = shape_mat(m) assert (n == n_) num = zeros(n, n) den = zeros(n, n) s = 1 for m_i, ai in izip(matrix_powers(m), a): mat_combine_inplace(num, m_i, ai) mat_combine_inplace(den, m_i, s * ai) s = -s return solve(den, num)
def expm( m, context=FloatContext, order=7 ): """Matrix exponent, using Pade approximation of given order """ a = _exp_pade_coeffs( order ) n,n_ = shape_mat( m ) assert( n == n_ ) num = zeros(n,n) den = zeros(n,n) s = 1 for m_i, ai in izip( matrix_powers(m), a ): mat_combine_inplace( num, m_i, ai ) mat_combine_inplace( den, m_i, s*ai) s = -s return solve( den, num )