§
    OŠtjÀ  ã                   óv   — d dl mZ ddlmZmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZ  G d„ d	e¦  «        Zd
S )é   )Ú
MatrixExpré    )ÚFunctionClassÚLambda)ÚDummy)Ú_sympifyÚsympify)ÚMatrix)ÚreÚimc                   ó`   ‡ — e Zd ZdZˆ fd„Zed„ ¦   «         Zed„ ¦   «         Zd„ Zd„ Z	d„ Z
ˆ xZS )ÚFunctionMatrixaö  Represents a matrix using a function (``Lambda``) which gives
    outputs according to the coordinates of each matrix entries.

    Parameters
    ==========

    rows : nonnegative integer. Can be symbolic.

    cols : nonnegative integer. Can be symbolic.

    lamda : Function, Lambda or str
        If it is a SymPy ``Function`` or ``Lambda`` instance,
        it should be able to accept two arguments which represents the
        matrix coordinates.

        If it is a pure string containing Python ``lambda`` semantics,
        it is interpreted by the SymPy parser and casted into a SymPy
        ``Lambda`` instance.

    Examples
    ========

    Creating a ``FunctionMatrix`` from ``Lambda``:

    >>> from sympy import FunctionMatrix, symbols, Lambda, MatPow
    >>> i, j, n, m = symbols('i,j,n,m')
    >>> FunctionMatrix(n, m, Lambda((i, j), i + j))
    FunctionMatrix(n, m, Lambda((i, j), i + j))

    Creating a ``FunctionMatrix`` from a SymPy function:

    >>> from sympy import KroneckerDelta
    >>> X = FunctionMatrix(3, 3, KroneckerDelta)
    >>> X.as_explicit()
    Matrix([
    [1, 0, 0],
    [0, 1, 0],
    [0, 0, 1]])

    Creating a ``FunctionMatrix`` from a SymPy undefined function:

    >>> from sympy import Function
    >>> f = Function('f')
    >>> X = FunctionMatrix(3, 3, f)
    >>> X.as_explicit()
    Matrix([
    [f(0, 0), f(0, 1), f(0, 2)],
    [f(1, 0), f(1, 1), f(1, 2)],
    [f(2, 0), f(2, 1), f(2, 2)]])

    Creating a ``FunctionMatrix`` from Python ``lambda``:

    >>> FunctionMatrix(n, m, 'lambda i, j: i + j')
    FunctionMatrix(n, m, Lambda((i, j), i + j))

    Example of lazy evaluation of matrix product:

    >>> Y = FunctionMatrix(1000, 1000, Lambda((i, j), i + j))
    >>> isinstance(Y*Y, MatPow) # this is an expression object
    True
    >>> (Y**2)[10,10] # So this is evaluated lazily
    342923500

    Notes
    =====

    This class provides an alternative way to represent an extremely
    dense matrix with entries in some form of a sequence, in a most
    sparse way.
    c                 ój  •— t          |¦  «        t          |¦  «        }}|                      |¦  «         |                      |¦  «         t          |¦  «        }t          |t          t
          f¦  «        s"t          d                     |¦  «        ¦  «        ‚d|j        vr"t          d                     |¦  «        ¦  «        ‚t          |t
          ¦  «        s:t          d¦  «        t          d¦  «        }}t          ||f |||¦  «        ¦  «        }t          ¦   «                              | |||¦  «        S )Nz4{} should be compatible with SymPy function classes.é   z({} should be able to accept 2 arguments.ÚiÚj)r   Ú
_check_dimr	   Ú
isinstancer   r   Ú
ValueErrorÚformatÚnargsr   ÚsuperÚ__new__)ÚclsÚrowsÚcolsÚlamdar   r   Ú	__class__s         €úc/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/matrices/expressions/funcmatrix.pyr   zFunctionMatrix.__new__P   s  ø€ Ý˜d‘^”^¥X¨d¡^¤^ˆdˆØ�Š�tÑÔÐØ�Š�tÑÔÐå˜‘”ˆÝ˜%¥-µÐ!8Ñ9Ô9ð 	 ÝØFß’˜‘”ñ ô  ð  ð �E”KÐÐÝØ:×AÒAÀ%ÑHÔHñJô Jð Jõ ˜%¥Ñ(Ô(ð 	0Ý˜‘:”:�u S™zœzˆqˆAÝ˜A˜q˜6 5 5¨¨A¡;¤;Ñ/Ô/ˆEå‰wŒw�Š˜s D¨$°Ñ6Ô6Ð6ó    c                 ó    — | j         dd…         S )Nr   r   ©Úargs©Úselfs    r   ÚshapezFunctionMatrix.shapee   s   € àŒy˜˜1˜Œ~Ðr    c                 ó   — | j         d         S )Nr   r"   r$   s    r   r   zFunctionMatrix.lamdai   s   € àŒy˜Œ|Ðr    c                 ó.   — |                       ||¦  «        S ©N)r   )r%   r   r   Úkwargss       r   Ú_entryzFunctionMatrix._entrym   s   € Ø�zŠz˜!˜QÑÔÐr    c                 óz   — ddl m} ddlm}  || ¦  «                             |¦  «                             ¦   «         S )Nr   )ÚTrace)ÚSum)Ú sympy.matrices.expressions.tracer-   Úsympy.concrete.summationsr.   ÚrewriteÚdoit)r%   r-   r.   s      r   Ú_eval_tracezFunctionMatrix._eval_tracep   sN   € Ø:Ð:Ð:Ð:Ð:Ð:Ø1Ð1Ð1Ð1Ð1Ð1Øˆu�T‰{Œ{×"Ò" 3Ñ'Ô'×,Ò,Ñ.Ô.Ð.r    c                 ór   — t          t          | ¦  «        ¦  «        t          t          | ¦  «        ¦  «        fS r)   )r   r
   r   r$   s    r   Ú_eval_as_real_imagz!FunctionMatrix._eval_as_real_imagu   s)   € Ý•6˜$‘<”<Ñ Ô ¥"¥V¨D¡\¤\Ñ"2Ô"2Ð3Ð3r    )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr&   r   r+   r3   r5   Ú__classcell__)r   s   @r   r   r   	   s¨   ø€ € € € € ðEð EðL7ð 7ð 7ð 7ð 7ð* ðð ñ „Xðð ðð ñ „Xðð ð  ð  ð/ð /ð /ð
4ð 4ð 4ð 4ð 4ð 4ð 4r    r   N)Úmatexprr   Úsympy.core.functionr   r   Úsympy.core.symbolr   Úsympy.core.sympifyr   r	   Úsympy.matricesr
   Ú$sympy.functions.elementary.complexesr   r   r   © r    r   ú<module>rC      sÁ   ðØ Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø #Ð #Ð #Ð #Ð #Ð #Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø !Ð !Ð !Ð !Ð !Ð !Ø 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7ðm4ð m4ð m4ð m4ð m4�Zñ m4ô m4ð m4ð m4ð m4r    