Beispiel #1
0
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)
Beispiel #2
0
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 )
Beispiel #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)
Beispiel #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 )