o
    :Î®cÖ  ã                   @   s   d d„ Z dS )c                    s    |   ¡ }d| ‰ ‡ fdd„}|S )a  
    Compute the Jacobi preconditioner function for the matrix A.

    Parameters
    -----------
    A: np.array
        Input matrix to compute the Jacobi preconditioner for.

    Returns
    ---------
    precondition_matvec: function
        Function which applies the Jacobi preconditioner to a vector

    Example
    -------
    >>> from pymatting import *
    >>> import numpy as np
    >>> A = np.array([[2, 3], [3, 5]])
    >>> preconditioner = jacobi(A)
    >>> preconditioner(np.array([1, 2]))
    array([0.5, 0.4])
    g      ð?c                    s   | ˆ  S )N© )Úx©Úinverse_diagonalr   úF/tmp/pip-target-vg8gfxp4/lib/python/pymatting/preconditioner/jacobi.pyÚprecondition_matvec   s   z#jacobi.<locals>.precondition_matvec)Údiagonal)ÚAr   r   r   r   r   Újacobi   s   r	   N)r	   r   r   r   r   Ú<module>   s    