Ë
    7^(hÝG  ã                   ó¾   — d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d d	lmZmZ d d
lmZ d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Z G d„ de«      Zy)é    N)ÚIterable)Ú	Printable)ÚTuple)Údiff)ÚS)Ú_sympify©Ú	NDimArray)ÚDenseNDimArrayÚImmutableDenseNDimArray©ÚSparseNDimArrayc                 ó„   — ddl m} t        | t        «      r| S t        | |t        t
        t        f«      rt        | «      S | S )Nr   ©Ú
MatrixBase)Úsympy.matricesr   Ú
isinstancer
   ÚlistÚtupler   r   )Úar   s     úX/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/sympy/tensor/array/arrayop.pyÚ_arrayfyr      s7   € Ý)ä�!”YÔØˆÜ�!�j¤$¬¬uÐ5Ô6Ü& qÓ)Ð)Ø€Hó    c            
      ó¶  ‡‡‡— ddl m}m} t        | «      dk(  rt        j
                  S t        | «      dk(  rt        | d   «      S ddlmŠ ddlm	} ddlm
Š ddlmŠ t        ˆˆˆfd„| D «       «      r || Ž S t        | «      d	kD  rt        t        | d   | d   «      g| d	d
 ¢­Ž S t        t        | «      \  }}t!        |t"        «      rt!        |t"        «      s||z  S t!        ||«      r“t!        ||«      r‡t        |«      }|j$                  j'                  «       D ���	�
ci c]3  \  }}|j$                  j'                  «       D ]  \  }	}
||z  |	z   ||
z  “Œ Œ5 }}	}}}
 |||j(                  |j(                  z   «      S t+        |«      D ��cg c]  }t+        |«      D ]  }||z  ‘Œ	 Œ }}}t-        ||j(                  |j(                  z   «      S c c}
}	}}w c c}}w )a”  
    Tensor product among scalars or array-like objects.

    The equivalent operator for array expressions is ``ArrayTensorProduct``,
    which can be used to keep the expression unevaluated.

    Examples
    ========

    >>> from sympy.tensor.array import tensorproduct, Array
    >>> from sympy.abc import x, y, z, t
    >>> A = Array([[1, 2], [3, 4]])
    >>> B = Array([x, y])
    >>> tensorproduct(A, B)
    [[[x, y], [2*x, 2*y]], [[3*x, 3*y], [4*x, 4*y]]]
    >>> tensorproduct(A, x)
    [[x, 2*x], [3*x, 4*x]]
    >>> tensorproduct(A, B, B)
    [[[[x**2, x*y], [x*y, y**2]], [[2*x**2, 2*x*y], [2*x*y, 2*y**2]]], [[[3*x**2, 3*x*y], [3*x*y, 3*y**2]], [[4*x**2, 4*x*y], [4*x*y, 4*y**2]]]]

    Applying this function on two matrices will result in a rank 4 array.

    >>> from sympy import Matrix, eye
    >>> m = Matrix([[x, y], [z, t]])
    >>> p = tensorproduct(eye(3), m)
    >>> p
    [[[[x, y], [z, t]], [[0, 0], [0, 0]], [[0, 0], [0, 0]]], [[[0, 0], [0, 0]], [[x, y], [z, t]], [[0, 0], [0, 0]]], [[[0, 0], [0, 0]], [[0, 0], [0, 0]], [[x, y], [z, t]]]]

    See Also
    ========

    sympy.tensor.array.expressions.array_expressions.ArrayTensorProduct

    r   )r   ÚImmutableSparseNDimArrayé   ©Ú_CodegenArrayAbstract)ÚArrayTensorProduct©Ú
_ArrayExpr©ÚMatrixSymbolc              3   ó<   •K  — | ]  }t        |‰‰‰f«      –— Œ y ­w©N)r   )Ú.0Úargr#   r!   r   s     €€€r   ú	<genexpr>z tensorproduct.<locals>.<genexpr>F   s!   øè ø€ Ò
^ÐRUŒ:�c˜JÐ(=¸|ÐL×MÑ
^ùs   ƒé   N)Úsympy.tensor.arrayr   r   Úlenr   ÚOner   Ú0sympy.tensor.array.expressions.array_expressionsr   r   r!   Ú"sympy.matrices.expressions.matexprr#   ÚanyÚtensorproductÚmapr   r
   Ú_sparse_arrayÚitemsÚshapeÚFlattenr   )Úargsr   r   r   r   ÚbÚlpÚk1Úv1Úk2Úv2Ú	new_arrayÚiÚjÚproduct_listr#   r!   r   s                  @@@r   r0   r0      sž  ú€ ÷F Mä
ˆ4ƒy�A‚~Ü�u‰uˆÜ
ˆ4ƒy�A‚~Ü˜˜Q™Ó Ð ÝVÝSÝKÝ?Ü
Õ
^ÐY]Ô
^Ô^Ù! 4Ð(Ð(Ü
ˆ4ƒy�1‚}Üœ]¨4°©7°D¸±GÓ<ÐH¸tÀAÀB¸xÒHÐHô Œx˜Ó�D€A€qä�aœÔ#¬:°a¼Ô+CØ�‰sˆ
ä�!�_Ô%¬*°Q¸Ô*HÜ�‹VˆØ56·_±_×5JÑ5JÓ5L×sÑs©6¨2¨rÐ[\×[jÑ[j×[pÑ[pÓ[rÒsÑQWÐQSÐUW�R˜‘U˜R‘Z  B¡Ñ&Ðs�ZÐsˆ	ÓsÙ'¨	°1·7±7¸Q¿W¹WÑ3DÓEÐEä!(¨£×@˜A´W¸Q³ZÒ@°�A�a“CÐ@�CÐ@€LÑ@Ü" <°·±¸1¿7¹7Ñ1BÓCÐCùõ	 tùó As   Ä 8G
ÆGc           	      óž  ‡‡— t        | «      } t        «       }|D ]s  }t        |t        «      st	        d«      ‚| j
                  |d      }|D ]?  }||v rt	        d«      ‚|| j
                  |   k7  rt	        d«      ‚|j                  |«       ŒA Œu | j                  «       }t        | j
                  «      D ��cg c]  \  }}||vsŒ|‘Œ }}}dg|z  Šd}	t        |«      D ].  }|	‰||z
  dz
  <   |	t        | j
                  ||z
  dz
     «      z  }	Œ0 t        |«      D ��
cg c]2  }||vr,t        | j
                  |   «      D �
cg c]
  }
‰|   |
z  ‘Œ c}
‘Œ4 }}}
g }|D ]Y  }g }t        | j
                  |d      «      D ]&  Š|j                  t        ˆˆfd„|D «       «      «       Œ( |j                  |«       Œ[ | |||fS c c}}w c c}
w c c}
}w )Nz1collections of contraction/diagonal axes expectedr   z"dimension specified more than oncezBcannot contract or diagonalize between axes of different dimensionr   c              3   ó.   •K  — | ]  }‰|   ‰z  –— Œ y ­wr%   © )r&   ÚigÚ	cum_shapeÚjss     €€r   r(   z-_util_contraction_diagonal.<locals>.<genexpr>„   s   øè ø€ ÒD°2˜I b™M¨BÕ.ÑDùs   ƒ)r   Úsetr   r   Ú
ValueErrorr4   ÚaddÚrankÚ	enumerateÚrangeÚintÚappendÚsum)ÚarrayÚcontraction_or_diagonal_axesÚ
taken_dimsÚ
axes_groupÚdimÚdrJ   r>   Úremaining_shapeÚ_cumulr?   Úremaining_indicesÚsummed_deltasÚlidxrE   rF   s                 @@r   Ú_util_contraction_diagonalr[   Z   sô  ù€ Ü�U‹O€Eô “€JØ2ò ˆ
Ü˜*¤hÔ/ÜÐPÓQÐQà�k‰k˜* Q™-Ñ(ˆàò 	ˆAØ�J‰Ü Ð!EÓFÐFØ�e—k‘k !‘nÒ$Ü Ð!eÓfÐfØ�N‰N˜1Õñ	ðð �:‰:‹<€Dä)2°5·;±;Ó)?×W™v˜q #À1ÈJÒCV’sÐW€OÑWØ��D‘€IØ€FÜ�4‹[ò 1ˆØ"(ˆ	�$˜‘(˜Q‘,ÑØ”#�e—k‘k $¨¡(¨Q¡,Ñ/Ó0Ñ0‰ð1ô #(¨£+÷FØ°¸*Ñ1Dô 38¸¿¹ÀA¹Ó2GÖH¨Q˜) A™, q›.ÔHð FÐñ Fð €MØ2ò #ˆ
ØˆÜ˜Ÿ™ J¨q¡MÑ2Ó3ò 	FˆBØ�K‰KœÔD¸ÔDÓDÕEð	Fà×Ñ˜TÕ"ð	#ð Ð# _°mÐCÐCùó3 Xùò Iùó Fs$   Â8F>ÃF>Ä#G	ÅGÅG	ÇG	c                 óð  — ddl m} ddl m} ddl m} ddlm} t        | |||f«      r	 || g|¢­Ž S t        | g|¢­Ž \  } }}}g }	t        j                  |Ž D ]j  }
t        |
«      }t        j                  }t        j                  |Ž D ]'  }| j                  |t        |«      z   «      }|| |   z  }Œ) |	j                  |«       Œl t        |«      dk(  rt        |	«      dk(  sJ ‚|	d   S  t!        | «      |	|«      S )añ  
    Contraction of an array-like object on the specified axes.

    The equivalent operator for array expressions is ``ArrayContraction``,
    which can be used to keep the expression unevaluated.

    Examples
    ========

    >>> from sympy import Array, tensorcontraction
    >>> from sympy import Matrix, eye
    >>> tensorcontraction(eye(3), (0, 1))
    3
    >>> A = Array(range(18), (3, 2, 3))
    >>> A
    [[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]], [[12, 13, 14], [15, 16, 17]]]
    >>> tensorcontraction(A, (0, 2))
    [21, 30]

    Matrix multiplication may be emulated with a proper combination of
    ``tensorcontraction`` and ``tensorproduct``

    >>> from sympy import tensorproduct
    >>> from sympy.abc import a,b,c,d,e,f,g,h
    >>> m1 = Matrix([[a, b], [c, d]])
    >>> m2 = Matrix([[e, f], [g, h]])
    >>> p = tensorproduct(m1, m2)
    >>> p
    [[[[a*e, a*f], [a*g, a*h]], [[b*e, b*f], [b*g, b*h]]], [[[c*e, c*f], [c*g, c*h]], [[d*e, d*f], [d*g, d*h]]]]
    >>> tensorcontraction(p, (1, 2))
    [[a*e + b*g, a*f + b*h], [c*e + d*g, c*f + d*h]]
    >>> m1*m2
    Matrix([
    [a*e + b*g, a*f + b*h],
    [c*e + d*g, c*f + d*h]])

    See Also
    ========

    sympy.tensor.array.expressions.array_expressions.ArrayContraction

    r   )Ú_array_contractionr   r    r"   r   )r-   r]   r   r!   r.   r#   r   r[   Ú	itertoolsÚproductrO   r   ÚZeroÚ_get_tuple_indexrN   r+   Útype)rP   Úcontraction_axesr]   r   r!   r#   rX   rV   rY   Úcontracted_arrayÚicontribÚindex_base_positionÚisumÚsum_to_indexÚidxs                  r   Útensorcontractionrj   Š   s  € õV TÝVÝKÝ?Ü�%˜*Ð&;¸\ÐJÔKÙ! %Ð;Ð*:Ò;Ð;ä?YÐZ_Ð?sÐbrÒ?sÑ<€EÐ˜o¨}ð ÐÜ×%Ñ%Ð'8Ð9ò &ˆÜ! (›mÐÜ�v‰vˆÜ%×-Ñ-¨}Ð=ò 	ˆLØ×(Ñ(Ð)<¼sÀ<Ó?PÑ)PÓQˆCØ�E˜#‘JÑ‰Dð	ð 	×Ñ Õ%ð&ô ÐÓ Ò"ÜÐ#Ó$¨Ò)Ð)Ð)Ø Ñ"Ð"àŒ4�‹;Ð'¨Ó9Ð9r   c                 ó†  — t        d„ |D «       «      rt        d«      ‚ddlm} ddlm} ddlm}m} ddlm} t        | |||f«      r	 || g|¢­Ž S  |j                  | g|¢­Ž  t        | g|¢­Ž \  } }}}	g }
|	D �cg c]  }t        |«      ‘Œ }}t        j                  |Ž D ]†  }t        |«      }g }t        j                  |	Ž D ]3  }| j!                  |t        |«      z   «      }|j#                  | |   «       Œ5   t%        | «      |«      j&                  |Ž }|
j#                  |«       Œˆ  t%        | «      |
||z   «      S c c}w )aP  
    Diagonalization of an array-like object on the specified axes.

    This is equivalent to multiplying the expression by Kronecker deltas
    uniting the axes.

    The diagonal indices are put at the end of the axes.

    The equivalent operator for array expressions is ``ArrayDiagonal``, which
    can be used to keep the expression unevaluated.

    Examples
    ========

    ``tensordiagonal`` acting on a 2-dimensional array by axes 0 and 1 is
    equivalent to the diagonal of the matrix:

    >>> from sympy import Array, tensordiagonal
    >>> from sympy import Matrix, eye
    >>> tensordiagonal(eye(3), (0, 1))
    [1, 1, 1]

    >>> from sympy.abc import a,b,c,d
    >>> m1 = Matrix([[a, b], [c, d]])
    >>> tensordiagonal(m1, [0, 1])
    [a, d]

    In case of higher dimensional arrays, the diagonalized out dimensions
    are appended removed and appended as a single dimension at the end:

    >>> A = Array(range(18), (3, 2, 3))
    >>> A
    [[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]], [[12, 13, 14], [15, 16, 17]]]
    >>> tensordiagonal(A, (0, 2))
    [[0, 7, 14], [3, 10, 17]]
    >>> from sympy import permutedims
    >>> tensordiagonal(A, (0, 2)) == permutedims(Array([A[0, :, 0], A[1, :, 1], A[2, :, 2]]), [1, 0])
    True

    See Also
    ========

    sympy.tensor.array.expressions.array_expressions.ArrayDiagonal

    c              3   ó8   K  — | ]  }t        |«      d k  –— Œ y­w)r   N)r+   )r&   r>   s     r   r(   z!tensordiagonal.<locals>.<genexpr>  s   è ø€ Ò
.˜1Œ3ˆq‹6�Q�;Ñ
.ùs   ‚z%need at least two axes to diagonalizer   r    r   )ÚArrayDiagonalÚ_array_diagonalr"   )r/   rH   r-   r!   r   rm   rn   r.   r#   r   Ú	_validater[   r+   r^   r_   rO   ra   rN   rb   Úreshape)rP   Údiagonal_axesr!   r   rm   rn   r#   rX   rV   Údiagonal_deltasÚdiagonalized_arrayr>   Údiagonal_shapere   rf   rg   rh   ri   s                     r   Útensordiagonalru   ×   sX  € ô\ Ñ
. Ô
.Ô.ÜÐ@ÓAÐAåKÝVß_Ý?Ü�%˜*Ð&;¸\ÐJÔKÙ˜uÐ5 }Ò5Ð5à€M×Ñ˜EÐ2 MÓ2äA[Ð\aÐArÐdqÒArÑ>€EÐ˜o¨ð ÐØ&5Ö6 ”c˜!•fÐ6€NÐ6Ü×%Ñ%Ð'8Ð9ò (ˆÜ! (›mÐØˆÜ%×-Ñ-¨Ð?ò 	$ˆLØ×(Ñ(Ð)<¼sÀ<Ó?PÑ)PÓQˆCØ�K‰K˜˜c™
Õ#ð	$ð )ˆ{Œt�E‹{˜4Ó ×(Ñ(¨.Ð9ˆØ×!Ñ! $Õ'ð(ð Œ4�‹;Ð)¨?¸^Ñ+KÓLÐLùò 7s   Á:D>c           
      ó  — ddl m} ddlm} t        |t
        f}t        ||«      r)t        |«      }|D ]  }|j                  rŒt        d«      ‚ t        | |«      �r,t        | t
        «      r| j                  «       } nt        | «      } t        ||«      rãt        | |«      rnt        | «      }t        t        |«      «      D ����	ci c]?  \  }}| j                  |«      j                  j!                  «       D ]  \  }}	|||z  z   |	“Œ ŒA }
}}}}	n@t        |«      D ��cg c]*  }t        | «      D �cg c]  }|j                  |«      ‘Œ c}‘Œ, }
}} t#        | «      |
|j$                  | j$                  z   «      S | j                  |«      S t'        | «      } t        ||«      r<t        t        |«      D �cg c]  }| j                  |«      ‘Œ c}|j$                  «      S t'        |«      }t        | |«      S c c}	}}}w c c}w c c}}w c c}w )a  
    Derivative by arrays. Supports both arrays and scalars.

    The equivalent operator for array expressions is ``array_derive``.

    Explanation
    ===========

    Given the array `A_{i_1, \ldots, i_N}` and the array `X_{j_1, \ldots, j_M}`
    this function will return a new array `B` defined by

    `B_{j_1,\ldots,j_M,i_1,\ldots,i_N} := \frac{\partial A_{i_1,\ldots,i_N}}{\partial X_{j_1,\ldots,j_M}}`

    Examples
    ========

    >>> from sympy import derive_by_array
    >>> from sympy.abc import x, y, z, t
    >>> from sympy import cos
    >>> derive_by_array(cos(x*t), x)
    -t*sin(t*x)
    >>> derive_by_array(cos(x*t), [x, y, z, t])
    [-t*sin(t*x), 0, 0, -x*sin(t*x)]
    >>> derive_by_array([x, y**2*z], [[x, y], [z, t]])
    [[[1, 0], [0, 2*y*z]], [[0, y**2], [0, 0]]]

    r   r   r   zcannot derive by this array)r   r   r*   r   r   r
   r   r   Ú	_diff_wrtrH   Úas_immutabler+   rK   r5   r   r2   r3   rb   r4   r   )ÚexprÚdxr   r   Úarray_typesr>   r8   ÚxÚkÚvr=   Úys               r   Úderive_by_arrayr€   *  sÐ  € õ8 *Ý2Ü˜Z¬Ð3€Kä�"�kÔ"Ü$ RÓ(ˆØò 	@ˆAØ—;“;Ü Ð!>Ó?Ð?ð	@ô �$˜Õ$Ü�dœIÔ&Ø×$Ñ$Ó&‰Dä*¨4Ó0ˆDä�b˜+Ô&Ü˜$ Ô0Ü˜“Y�ä)2´7¸2³;Ó)?÷Mñ MÙ!%  AØ)-¯©°1«×)CÑ)C×)IÑ)IÓ)KòMá!%  Að   2¡™X q™[ð M˜Xð M�	ô Mô JQÐQSË×UÀA´¸³Ö?¨A˜aŸf™f Q�iÔ?ÐU�	ÑUØ”4˜“:˜i¨¯©°D·J±JÑ)>Ó?Ð?à—9‘9˜R“=Ð ä˜‹~ˆÜ�b˜+Ô&Ü*Ä'È"Ã+Ö+N¸Q¨D¯I©I°a­LÒ+NÐPR×PXÑPXÓYÐYä˜"“ˆBÜ˜˜b“>Ð!ùõMùò @ùÓUùò ,Os%   ÃAG2
ÄG?Ä.G:ÅG?Æ1HÇ:G?c                 ó�  — ddl m} ddlm} ddlm} ddlm} ddlm} ddlm	}	 ddlm
}
 |	j                  ||| |
| «      «      }t        | |||f«      r	 || |«      S t        | t        «      st        | «      } dd	lm} t        ||«      s |t#        |«      «      }|j$                  | j'                  «       k7  rt)        d
«      ‚| } || j*                  «      }t        | |«      r\ t-        | «      | j.                  j1                  «       D ��ci c]&  \  }}t3         || j5                  |«      «      «      |“Œ( c}}|«      S  || j*                  D �cg c]  }t7        |«      ‘Œ c}«      }dgt9        | «      z  }t;        t=        j>                  |Ž «      D ]  \  }} ||«      }| |   ||<   Œ  t-        | «      ||«      S c c}}w c c}w )a?  
    Permutes the indices of an array.

    Parameter specifies the permutation of the indices.

    The equivalent operator for array expressions is ``PermuteDims``, which can
    be used to keep the expression unevaluated.

    Examples
    ========

    >>> from sympy.abc import x, y, z, t
    >>> from sympy import sin
    >>> from sympy import Array, permutedims
    >>> a = Array([[x, y, z], [t, sin(x), 0]])
    >>> a
    [[x, y, z], [t, sin(x), 0]]
    >>> permutedims(a, (1, 0))
    [[x, t], [y, sin(x)], [z, 0]]

    If the array is of second order, ``transpose`` can be used:

    >>> from sympy import transpose
    >>> transpose(a)
    [[x, t], [y, sin(x)], [z, 0]]

    Examples on higher dimensions:

    >>> b = Array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
    >>> permutedims(b, (2, 1, 0))
    [[[1, 5], [3, 7]], [[2, 6], [4, 8]]]
    >>> permutedims(b, (1, 2, 0))
    [[[1, 5], [2, 6]], [[3, 7], [4, 8]]]

    An alternative way to specify the same permutations as in the previous
    lines involves passing the *old* and *new* indices, either as a list or as
    a string:

    >>> permutedims(b, index_order_old="cba", index_order_new="abc")
    [[[1, 5], [3, 7]], [[2, 6], [4, 8]]]
    >>> permutedims(b, index_order_old="cab", index_order_new="abc")
    [[[1, 5], [2, 6]], [[3, 7], [4, 8]]]

    ``Permutation`` objects are also allowed:

    >>> from sympy.combinatorics import Permutation
    >>> permutedims(b, Permutation([1, 2, 0]))
    [[[1, 5], [2, 6]], [[3, 7], [4, 8]]]

    See Also
    ========

    sympy.tensor.array.expressions.array_expressions.PermuteDims

    r   r   r    r   )Ú_permute_dimsr"   )ÚPermuteDims)Úget_rank)ÚPermutationzwrong permutation sizeN) r*   r   r-   r!   r   r‚   r.   r#   Úsympy.tensor.array.expressionsrƒ   r„   Ú_get_permutation_from_argumentsr   r
   r   Úsympy.combinatoricsr…   r   ÚsizerJ   rH   r4   rb   r2   r3   r   ra   rL   r+   rK   r^   r_   )ry   ÚpermÚindex_order_oldÚindex_order_newr   r!   r   r‚   r#   rƒ   r„   r…   ÚipermÚ	new_shaper}   r~   r>   Úindices_spanr=   ri   Úts                        r   Úpermutedimsr‘   j  s©  € õp 3åKÝVÝNÝ?Ý:ÝIØ×6Ñ6°t¸_ÈoÑ_gÐhlÓ_mÓn€DÜ�$˜Ð%:¸LÐIÔJÙ˜T 4Ó(Ð(ä�dœIÔ&Ü& tÓ,ˆå/Ü�d˜KÔ(Ùœ4 ›:Ó&ˆà‡y�y�D—I‘I“KÒÜÐ1Ó2Ð2ð ˆE€EÙ�T—Z‘ZÓ €Iä�$˜Ô(ØŒt�D‹zØ'+×'9Ñ'9×'?Ñ'?Ó'A÷CÙ#˜q !ô !¡ d×&;Ñ&;¸AÓ&>Ó!?Ó@À!ÑCó CØDMóOð 	Oñ ¨4¯:©:Ö6 aœ˜q�Ò6Ó7€Là�”s˜4“yÑ €IÜœI×-Ñ-¨|Ð<Ó=ò ‰ˆˆ3Ù�#‹JˆØ˜A‘wˆ	�!Šðð Œ4�‹:�i Ó+Ð+ùóCùò 7s   Ä+F=
ÅGc                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)r5   aO  
    Flatten an iterable object to a list in a lazy-evaluation way.

    Notes
    =====

    This class is an iterator with which the memory cost can be economised.
    Optimisation has been considered to ameliorate the performance for some
    specific data types like DenseNDimArray and SparseNDimArray.

    Examples
    ========

    >>> from sympy.tensor.array.arrayop import Flatten
    >>> from sympy.tensor.array import Array
    >>> A = Array(range(6)).reshape(2, 3)
    >>> Flatten(A)
    Flatten([[0, 1, 2], [3, 4, 5]])
    >>> [i for i in Flatten(A)]
    [0, 1, 2, 3, 4, 5]
    c                 ó¢   — ddl m} ddlm} t	        |t
        |f«      st        d«      ‚t	        |t        «      r ||«      }|| _        d| _	        y )Nr   r   r	   zData type not yet supported)
Úsympy.matrices.matrixbaser   r*   r
   r   r   ÚNotImplementedErrorr   Ú_iterÚ_idx)ÚselfÚiterabler   r
   s       r   Ú__init__zFlatten.__init__à  sE   € Ý8Ý0ä˜(¤X¨zÐ$:Ô;Ü%Ð&CÓDÐDä�h¤Ô%Ù  Ó*ˆHàˆŒ
Øˆ�	r   c                 ó   — | S r%   rC   ©r˜   s    r   Ú__iter__zFlatten.__iter__í  s   € Øˆr   c                 ó¼  — ddl m} t        | j                  «      | j                  kD  �rt        | j                  t        «      r$| j                  j                  | j                     }nßt        | j                  t        «      rI| j                  | j                  j                  v r$| j                  j                  | j                     }nd}n|t        | j                  |«      r| j                  | j                     }nLt        | j                  d«      rt        | j                  «      }n | j                  | j                     }nt        ‚| xj                  dz  c_        |S )Nr   r   Ú__next__r   )r”   r   r+   r–   r—   r   r   Ú_arrayr   r2   ÚhasattrÚnextÚStopIteration)r˜   r   Úresults      r   rŸ   zFlatten.__next__ð  sê   € Ý8äˆt�z‰z‹?˜TŸY™YÓ&Ü˜$Ÿ*™*¤nÔ5ØŸ™×*Ñ*¨4¯9©9Ñ5‘ä˜DŸJ™J¬Ô8Ø—9‘9 §
¡
× 8Ñ 8Ñ8Ø!ŸZ™Z×5Ñ5°d·i±iÑ@‘Fà‘Fä˜DŸJ™J¨
Ô3ØŸ™ D§I¡IÑ.‘ä˜Ÿ™ ZÔ0Ü˜dŸj™jÓ)‘ð Ÿ™ D§I¡IÑ.‘ô  Ðà�	Š	�Q‰�	Øˆr   c                 ó"   — | j                  «       S r%   )rŸ   rœ   s    r   r¢   zFlatten.next  s   € Ø�}‰}‹Ðr   c                 óp   — t        | «      j                  dz   |j                  | j                  «      z   dz   S )Nú(ú))rb   Ú__name__Ú_printr–   )r˜   Úprinters     r   Ú	_sympystrzFlatten._sympystr  s.   € Ü�D‹z×"Ñ" SÑ(¨7¯>©>¸$¿*¹*Ó+EÑEÈÑKÐKr   N)	r©   Ú
__module__Ú__qualname__Ú__doc__rš   r�   rŸ   r¢   r¬   rC   r   r   r5   r5   Ê  s!   „ ñò*òòò8óLr   r5   )NNN)r^   Úcollections.abcr   Úsympy.core._print_helpersr   Úsympy.core.containersr   Úsympy.core.functionr   Úsympy.core.singletonr   Úsympy.core.sympifyr   Úsympy.tensor.array.ndim_arrayr
   Ú#sympy.tensor.array.dense_ndim_arrayr   r   Ú$sympy.tensor.array.sparse_ndim_arrayr   r   r0   r[   rj   ru   r€   r‘   r5   rC   r   r   ú<module>r¹      sb   ðÛ Ý $å /Ý 'Ý $Ý "Ý 'å 3ß WÝ @òò>DòB-Dò`J:òZPMòf="ó@],ô@FLˆiõ FLr   