
    \h                        S SK Jr  S SKJrJrJr  S SKJr  S SKJ	r	  S SK
Jr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 r\\\'   S r\\\'    " S S\\5      r " S S\\5      r\r " S S\\5      r\" \\5      S 5       r g)    )_matrix)BasicDictTuple)Integer)cacheit)_sympy_converter_sympify)DenseMatrix)
MatrixExpr)
MatrixBase)	RepMatrix)SparseRepMatrix)dispatchc                 "    U R                  5       $ N)as_immutable)args    P/var/www/auris/envauris/lib/python3.13/site-packages/sympy/matrices/immutable.pysympify_matrixr      s        c                     U  Vs/ s H  n[        U5      PM     nn[        U R                  U R                  U5      $ s  snf r   )r
   ImmutableDenseMatrixrowscols)r   xmats      r   sympify_mpmath_matrixr      s6     #
$18A;C
$#((C88 %s   =c                      ^  \ rS rSrSrS r\R                  rS r\	S 5       r
\	S 5       r\	S 5       rS rS	 rS
 rSU 4S jjr\R                   R                  \l        \" \5      rS rSrU =r$ )ImmutableRepMatrix   zWImmutable matrix based on RepMatrix

Uses DomainMAtrix as the internal representation.
c                 &    U R                   " U0 UD6$ r   )_new)clsargskwargss      r   __new__ImmutableRepMatrix.__new__*   s    xx(((r   c                     U $ r    selfs    r   copyImmutableRepMatrix.copy/       r   c                     U R                   $ r   )_colsr+   s    r   r   ImmutableRepMatrix.cols2       zzr   c                     U R                   $ r   )_rowsr+   s    r   r   ImmutableRepMatrix.rows6   r3   r   c                 2    U R                   U R                  4$ r   )r5   r1   r+   s    r   shapeImmutableRepMatrix.shape:   s    zz4::%%r   c                     U $ r   r*   r+   s    r   r   ImmutableRepMatrix.as_immutable>   r/   r   c                     XU4   $ r   r*   )r,   ijr&   s       r   _entryImmutableRepMatrix._entryA   s    qDzr   c                 J    [        SR                  U R                  5      5      e)NzCannot set values of {})	TypeErrorformat	__class__)r,   r%   s     r   __setitem__ImmutableRepMatrix.__setitem__D   s    188HIIr   c                 (   > [         TU ]  " SSU0UD6$ )N
reals_onlyr*   )superis_diagonalizable)r,   rH   r&   rD   s      r   rJ   $ImmutableRepMatrix.is_diagonalizableG   s%    w( -!-%+- 	-r   c                 \    U R                  5       R                  X5      R                  5       $ r   )
as_mutableanalytic_funcr   )r,   fr   s      r   rN    ImmutableRepMatrix.analytic_funcN   s#     ..q4AACCr   r*   )F)__name__
__module____qualname____firstlineno____doc__r'   r   __hash__r-   propertyr   r   r8   r   r?   rE   rJ   r   r   rN   __static_attributes____classcell__)rD   s   @r   r    r       s    ) ""H     & &J- !0 A A I I 12D Dr   r    c                   D    \ rS rSrSrSrSrSr\S 5       r	\S 5       r
Srg	)
r   R   a  Create an immutable version of a matrix.

Examples
========

>>> from sympy import eye, ImmutableMatrix
>>> ImmutableMatrix(eye(3))
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> _[0, 0] = 42
Traceback (most recent call last):
...
TypeError: Cannot set values of ImmutableDenseMatrix
T   gn $@c                 J   [        U5      S:X  a  [        US   [        5      (       a  US   $ UR                  SS5      SL a   [        U5      S:w  a  [	        S5      eUu  p4nO U R
                  " U0 UD6u  p4n[        U5      nU R                  X4U5      nU R                  U5      $ )N   r   r-   TF   zA'copy=False' requires a matrix be initialized as rows,cols,[list])	len
isinstancer   getrB   _handle_creation_inputslist_flat_list_to_DomainMatrix_fromrep)r$   r%   r&   r   r   	flat_listreps          r   r#   ImmutableDenseMatrix._newj   s    t9>ja2FGG7N::fd#u,4yA~ cdd$(!D	$'$?$?$P$P!D	YI,,TC||C  r   c           
          UR                   u  p#UR                  5       R                  5       n[        R                  " U [        U5      [        U5      [        USS065      nX%l        X5l        Xl	        U$ )NsympifyF)
r8   to_sympyto_list_flatr   r'   r   r   r5   r1   _rep)r$   rh   r   r   rg   objs         r   rf   ImmutableDenseMatrix._fromrepz   sb    YY
LLN//1	mmCDMDM9,e,. 		
r   r*   N)rQ   rR   rS   rT   rU   	_iterable_class_priority_op_priorityclassmethodr#   rf   rX   r*   r   r   r   r   R   s>    & IOL! ! 
 
r   r   c                   @    \ rS rSrSrSrSr\S 5       r\S 5       r	Sr
g)	ImmutableSparseMatrix   au  Create an immutable version of a sparse matrix.

Examples
========

>>> from sympy import eye, ImmutableSparseMatrix
>>> ImmutableSparseMatrix(1, 1, {})
Matrix([[0]])
>>> ImmutableSparseMatrix(eye(3))
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
>>> _[0, 0] = 42
Traceback (most recent call last):
...
TypeError: Cannot set values of ImmutableSparseMatrix
>>> _.shape
(3, 3)
T	   c                 r    U R                   " U0 UD6u  p4nU R                  X4U5      nU R                  U5      $ r   )rc   _smat_to_DomainMatrixrf   )r$   r%   r&   r   r   smatrh   s          r   r#   ImmutableSparseMatrix._new   s=    66GGD''D9||C  r   c                     UR                   u  p#UR                  5       R                  5       n[        R                  " U [        U5      [        U5      [        U5      5      nX%l        X5l        Xl	        U$ r   )
r8   rl   to_dokr   r'   r   r   r5   r1   rn   )r$   rh   r   r   r{   ro   s         r   rf   ImmutableSparseMatrix._fromrep   sU    YY
||~$$&mmCtDzJ		
r   r*   N)rQ   rR   rS   rT   rU   	is_Matrixrr   rt   r#   rf   rX   r*   r   r   rv   rv      s9    ( IO! !  r   rv   c                 T    U R                   UR                   :w  a  gX-
  R                  $ )av  Helper method for Equality with matrices.sympy.

Relational automatically converts matrices to ImmutableDenseMatrix
instances, so this method only applies here.  Returns True if the
matrices are definitively the same, False if they are definitively
different, and None if undetermined (e.g. if they contain Symbols).
Returning None triggers default handling of Equalities.

F)r8   is_zero_matrix)lhsrhss     r   _eval_is_eqr      s%     yyCIII%%%r   N)!mpmath.matrices.matricesr   
sympy.corer   r   r   sympy.core.numbersr   sympy.core.cacher   sympy.core.sympifyr	   sympify_converterr
   sympy.matrices.denser   sympy.matrices.expressionsr   sympy.matrices.matrixbaser   sympy.matrices.repmatrixr   sympy.matrices.sparser   sympy.multipledispatchr   r   r   r    r   ImmutableMatrixrv   r   r*   r   r   <module>r      s    , ) ) & $ N , 1 0 . 1 + !/ * 9
 3 ' 1DJ 1Dh3;(: 3n '(O-? (V 

 45& 6&r   