+
    i                     p    ^RI Ht ^ RIHtHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht ^ RIHtHt  ! R R]4      tR	# )
   )
MatrixExpr)FunctionClassLambda)Dummy)_sympifysympify)Matrix)reimc                   h   a a ] tR t^	t oRtV 3R lt]R 4       t]R 4       tR t	R t
R tRtVtV ;t# )	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                  < \        V4      \        V4      r!V P                  V4       V P                  V4       \        V4      p\        V\        \
        34      '       g   \        R P                  V4      4      h^VP                  9  d   \        RP                  V4      4      h\        V\
        4      '       g)   \        R4      \        R4      rT\        WE3V! WE4      4      p\        SV `-  WW#4      # )z4{} 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   &&&&  څ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/matrices/expressions/funcmatrix.pyr   FunctionMatrix.__new__P   s    d^Xd^dtt%-!899F    EKK:AA%HJ J %((:uSzqA65;/Ews$66    c                (    V P                   R ,          # ):       Nargsselfs   &r   shapeFunctionMatrix.shapee   s    yy~r   c                (    V P                   ^,          # )r"   r#   r%   s   &r   r   FunctionMatrix.lamdai   s    yy|r   c                $    V P                  W4      # N)r   )r&   r   r   kwargss   &&&,r   _entryFunctionMatrix._entrym   s    zz!r   c                d    ^ RI Hp ^ RIHp V! V 4      P	                  V4      P                  4       # )r!   )Trace)Sum) sympy.matrices.expressions.tracer1   sympy.concrete.summationsr2   rewritedoit)r&   r1   r2   s   &  r   _eval_traceFunctionMatrix._eval_tracep   s&    :1T{""3',,..r   c                R    \        \        V 4      4      \        \        V 4      4      3# r,   )r
   r	   r   r%   s   &r   _eval_as_real_imag!FunctionMatrix._eval_as_real_imagu   s    6$< "VD\"233r    )__name__
__module____qualname____firstlineno____doc__r   propertyr'   r   r.   r7   r:   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r   r   	   sM     EL7*     /
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   r   <module>rM      s%     5 # 0 ! 7m4Z m4r   