Exemplo n.º 1
0
def solve(a, b):
    '''
    Solve a linear matrix equation, or system of linear scalar equations.
    
    Computes the "exact" solution, ``x``, of the well-determined, i.e., full
    rank, linear matrix equation ``ax = b``.
    
    ``Parameters``

    a : (M, M) array_like
        Coefficient matrix.
    b : {(M), (M, K)}, array_like
        Ordinate or "dependent variable" values.
        
    ``Returns``

    x : {(M), (M, K)} ndarray
        Solution to the system a x = b.  Returned shape is identical to ``b``.
    '''
    _assert_2d(a)
    r_2d = False
    if b.ndim == 2:
        b = b.flatten()
        r_2d = True
    x = LinalgUtil.solve(a.asarray(), b.asarray())
    r = NDArray(x)
    if r_2d:
        r = r.reshape((len(r), 1))
    return r
Exemplo n.º 2
0
def solve(a, b):
    '''
    Solve a linear matrix equation, or system of linear scalar equations.
    
    Computes the "exact" solution, ``x``, of the well-determined, i.e., full
    rank, linear matrix equation ``ax = b``.
    
    ``Parameters``

    a : (M, M) array_like
        Coefficient matrix.
    b : {(M), (M, K)}, array_like
        Ordinate or "dependent variable" values.
        
    ``Returns``

    x : {(M), (M, K)} ndarray
        Solution to the system a x = b.  Returned shape is identical to ``b``.
    '''
    x = LinalgUtil.solve(a.asarray(), b.asarray())
    return MIArray(x)
Exemplo n.º 3
0
def solve_triangular(a, b, lower=False):
    '''
    Solve the equation `a x = b` for `x`, assuming a is a triangular matrix.

    Parameters
    --------------
    a : (M, M) array_like
        A triangular matrix.
    b : {(M), (M, K)}, array_like
        Right-hand side matrix in `a x = b`
    lower : bool, optional
        Use only data contained in the lower triangle of `a`.
        Default is to use upper triangle.

    ``Returns``

    x : {(M), (M, K)} ndarray
        Solution to the system a x = b.  Returned shape is identical to ``b``.
    '''
    x = LinalgUtil.solve(a.asarray(), b.asarray())
    return NDArray(x)
Exemplo n.º 4
0
def solve(a, b):
    '''
    Solve a linear matrix equation, or system of linear scalar equations.
    
    Computes the "exact" solution, ``x``, of the well-determined, i.e., full
    rank, linear matrix equation ``ax = b``.
    
    ``Parameters``

    a : (M, M) array_like
        Coefficient matrix.
    b : {(M), (M, K)}, array_like
        Ordinate or "dependent variable" values.
        
    ``Returns``

    x : {(M), (M, K)} ndarray
        Solution to the system a x = b.  Returned shape is identical to ``b``.
    '''
    x = LinalgUtil.solve(a.asarray(), b.asarray())
    return MIArray(x)