ó
    ‹*£hH  ã                   ó”   • S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr   " S S	\5      r\S
 5       r " S S\5      rg)é    )ÚIterable)Úsingledispatch)ÚExpr)ÚMul)ÚS)Úsympify)Úglobal_parametersc                   óD   • \ rS rSrSrSrS rS rS r\	S 5       r
S rS	rg
)ÚTensorProducté   z$
Generic class for tensor products.
Fc                 óv  • SSK JnJnJn  SSKJn  SSKJn  SSKJ	n  U V	s/ s H  n	[        U	5      PM     nn	UR                  S[        R                  5      n
U
(       d  [        R                  " U /UQ76 nU$ / n/ n[         R"                  nU H[  n	[%        U	[&        Xs45      (       a  UR)                  U" U	5      5        M3  [%        X–45      (       a  UR)                  U	5        MW  Xé-  nM]     Xä" U6 -  n[+        U5      S:X  a  U$ US:w  a  U/U-   nOUn[        R                  " U /UQ70 UD6nU" U5      $ s  sn	f )Nr   )Ú	NDimArrayÚtensorproductÚArray)Ú
MatrixExpr)Ú
MatrixBase)ÚflattenÚevaluateé   )Úsympy.tensor.arrayr   r   r   Ú"sympy.matrices.expressions.matexprr   Úsympy.matrices.matrixbaser   Úsympy.strategiesr   r   Úgetr	   r   r   Ú__new__r   ÚOneÚ
isinstancer   ÚappendÚlen)ÚclsÚargsÚkwargsr   r   r   r   r   r   Úargr   ÚobjÚarraysÚotherÚscalarÚcoeffÚnewargss                    ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/tensor/functions.pyr   ÚTensorProduct.__new__   s  € ßFÑFÝAÝ8Ý,á(,Ó-ª ”˜–©ˆÐ-Ø—:‘:˜jÔ*;×*DÑ*DÓEˆæÜ—,’,˜sÐ* TÒ*ˆCØˆJàˆØˆÜ—‘ˆÛˆCÜ˜#¤¨*Ð@×AÑAØ—‘™e C›jÖ)Ü˜C ×/Ñ/Ø—‘˜SÖ!à‘’ñ ð �} fÐ-Ñ-ˆÜˆu‹:˜‹?ØˆLØ�A‹:Ø�g ‘o‰GàˆGÜ�lŠl˜3Ð3 Ò3¨FÑ3ˆÙ�s‹|Ðùò5 .s   ¡D6c                 ó,   • [        U R                  5      $ ©N)r   Úshape)Úselfs    r*   ÚrankÚTensorProduct.rank3   s   € Ü�4—:‘:‹Ðó    c                 ó¬   • SSK Jn  U R                   Vs/ s H2  n[        US5      (       a  UR                  OU" U5      R                  PM4     sn$ s  snf )Nr   )r   r.   )r   r   r!   Úhasattrr.   )r/   r   Úis      r*   Ú_get_args_shapesÚTensorProduct._get_args_shapes6   s>   € Ý,ØLPÏIÊIÓVÊIÀqœ7 1 g×.Ñ.�—’±E¸!³H·N±NÒBÉIÑVÐVùÒVs   •9Ac                 ó:   • U R                  5       n[        US5      $ )N© )r6   Úsum)r/   Ú
shape_lists     r*   r.   ÚTensorProduct.shape:   s   € à×*Ñ*Ó,ˆ
Ü�:˜rÓ"Ð"r2   c                 óž   ^• [        T5      m[        R                  " U4S j[        U R                  U R                  5       5       5       5      $ )Nc              3   óp   >#   • U  H+  u  pUR                  [        U4S  jU 5       5      5      v •  M-     g7f)c              3   ó:   >#   • U  H  n[        T5      v •  M     g 7fr-   )Únext)Ú.0r5   Úindexs     €r*   Ú	<genexpr>Ú6TensorProduct.__getitem__.<locals>.<genexpr>.<genexpr>B   s   øé € Ð!;²s°!¤$ u§+ +²sùs   ƒN)Ú__getitem__Útuple)rA   r#   ÚshprB   s      €r*   rC   Ú,TensorProduct.__getitem__.<locals>.<genexpr>A   s1   øé € ð 
âC‘�ð �O‰OœEÔ!;±sÓ!;Ó;×<Ð<ÚCùs   ƒ36)Úiterr   ÚfromiterÚzipr!   r6   )r/   rB   s    `r*   rE   ÚTensorProduct.__getitem__?   s>   ø€ Ü�U“ˆÜ�|Š|ô 
ä §	¡	¨4×+@Ñ+@Ó+BÔCó
ó 
ð 	
r2   r9   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú	is_numberr   r0   r6   Úpropertyr.   rE   Ú__static_attributes__r9   r2   r*   r   r      s8   † ñð €Iò òDòWð ñ#ó ð#õ
r2   r   c                 óX   • [        U S5      (       a  U R                  $ [        SU -  5      e)a0  
Return the shape of the *expr* as a tuple. *expr* should represent
suitable object such as matrix or array.

Parameters
==========

expr : SymPy object having ``MatrixKind`` or ``ArrayKind``.

Raises
======

NoShapeError : Raised when object with wrong kind is passed.

Examples
========

This function returns the shape of any object representing matrix or array.

>>> from sympy import shape, Array, ImmutableDenseMatrix, Integral
>>> from sympy.abc import x
>>> A = Array([1, 2])
>>> shape(A)
(2,)
>>> shape(Integral(A, x))
(2,)
>>> M = ImmutableDenseMatrix([1, 2])
>>> shape(M)
(2, 1)
>>> shape(Integral(M, x))
(2, 1)

You can support new type by dispatching.

>>> from sympy import Expr
>>> class NewExpr(Expr):
...     pass
>>> @shape.register(NewExpr)
... def _(expr):
...     return shape(expr.args[0])
>>> shape(NewExpr(M))
(2, 1)

If unsuitable expression is passed, ``NoShapeError()`` will be raised.

>>> shape(Integral(x, x))
Traceback (most recent call last):
  ...
sympy.tensor.functions.NoShapeError: shape() called on non-array object: Integral(x, x)

Notes
=====

Array-like classes (such as ``Matrix`` or ``NDimArray``) has ``shape``
property which returns its shape, but it cannot be used for non-array
classes containing array. This function returns the shape of any
registered object representing array.

r.   zA%s does not have shape, or its type is not registered to shape().)r4   r.   ÚNoShapeError)Úexprs    r*   r.   r.   G   s3   € ôz ˆt�W×ÑØ�z‰zÐÜ
ØKÈdÑRóTð Tr2   c                   ó   • \ rS rSrSrSrg)rV   éŠ   aB  
Raised when ``shape()`` is called on non-array object.

This error can be imported from ``sympy.tensor.functions``.

Examples
========

>>> from sympy import shape
>>> from sympy.abc import x
>>> shape(x)
Traceback (most recent call last):
  ...
sympy.tensor.functions.NoShapeError: shape() called on non-array object: x
r9   N)rM   rN   rO   rP   rQ   rT   r9   r2   r*   rV   rV   Š   s   † ñò 	r2   rV   N)Úcollections.abcr   Ú	functoolsr   Úsympy.core.exprr   Úsympy.core.mulr   Úsympy.core.singletonr   Úsympy.core.sympifyr   Úsympy.core.parametersr	   r   r.   Ú	ExceptionrV   r9   r2   r*   Ú<module>rb      sJ   ðÝ $Ý $å  Ý Ý "Ý &Ý 3ô9
�Dô 9
ðx ñ?Tó ð?TôD	�9õ 	r2   