Exemplo n.º 1
0
Arquivo: expm.py Projeto: qqchen/pyla
def matrix_powers(m):
    """Generates infinite sequence of matrix powers, starting from m^0"""
    yield eye(len(m))  # m^0
    yield m  # m^1
    m_i = mmul(m, m)
    while True:
        yield m_i
        m_i = mmul(m_i, m)
Exemplo n.º 2
0
Arquivo: expm.py Projeto: Rambood/pyla
def matrix_powers(m):
    """Generates infinite sequence of matrix powers, starting from m^0"""
    yield eye(len(m)) # m^0
    yield m           # m^1 
    m_i = mmul( m, m )
    while True:
        yield m_i
        m_i = mmul( m_i, m )
Exemplo n.º 3
0
def qr_inverse(M, context=FloatContext, eps=1e-14):
    """Matrix inverse, using QR transformation"""
    n, n_ = shape_mat(M)
    assert (n == n_)
    IQ, R = qrl_givens(M, context=context, eps=eps, inverse_q=True)
    IR = ltri_inverse(R, context=context)
    return mmul(IR, IQ)
Exemplo n.º 4
0
def qr_inverse( M, context=FloatContext, eps=1e-14):
    """Matrix inverse, using QR transformation"""
    n,n_ = shape_mat(M)
    assert(n==n_)
    IQ,R = qrl_givens(M, context=context, eps=eps, inverse_q = True)
    IR = ltri_inverse(R, context=context)
    return mmul( IR, IQ )