� ��g���>�ddlmZddlmZmZmZddlmZddlm Z ddl m Z m Z ddlmZddlmZddlmZdd lmZdd lmZdd lmZd �Zee e<d �Zee e<Gd�dee��ZGd�dee��ZeZGd�dee��Zeee��d���Z dS)�)�_matrix)�Basic�Dict�Tuple)�Integer)�cacheit)�_sympy_converter�_sympify)� DenseMatrix)� MatrixExpr)� MatrixBase)� RepMatrix)�SparseRepMatrix)�dispatchc�*�|���S�N)� as_immutable)�args �h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/matrices/immutable.py�sympify_matrixrs�� � � � � ��c�P�d�|D��}t|j|j|��S)Nc�,�g|]}t|����S�)r )�.0�xs r� <listcomp>z)sympify_mpmath_matrix.<locals>.<listcomp>s�� $� $� $�1�8�A�;�;� $� $� $r)�ImmutableDenseMatrix�rows�cols)r�mats r�sympify_mpmath_matrixr"s+�� $� $�� $� $� $�C� ���#�(�C� 8� 8�8rc����eZdZdZd�ZejZd�Zed���Z ed���Z ed���Z d�Z d�Z d �Zd �fd � Zejje_ee��Zd �Z�xZS)�ImmutableRepMatrixz_Immutable matrix based on RepMatrix Uses DomainMAtrix as the internal representation. c��|j|i|��Sr)�_new)�cls�args�kwargss r�__new__zImmutableRepMatrix.__new__*s���s�x��(��(�(�(rc��|Srr��selfs r�copyzImmutableRepMatrix.copy/���� rc��|jSr)�_colsr,s rr zImmutableRepMatrix.cols2� ���z�rc��|jSr)�_rowsr,s rrzImmutableRepMatrix.rows6r2rc��|j|jfSr)r4r1r,s r�shapezImmutableRepMatrix.shape:s���z�4�:�%�%rc��|Srrr,s rrzImmutableRepMatrix.as_immutable>r/rc ��|||fSrr)r-�i�jr)s r�_entryzImmutableRepMatrix._entryAs���A�q�D�z�rc�P�td�|j�����)NzCannot set values of {})� TypeError�format� __class__)r-r(s r� __setitem__zImmutableRepMatrix.__setitem__Ds!���1�8�8���H�H�I�I�IrFc �:��t��jdd|i|��S)N� reals_onlyr)�super�is_diagonalizable)r-rBr)r?s �rrDz$ImmutableRepMatrix.is_diagonalizableGs3���(�u�w�w�(�-�-�!�-�%+�-�-� -rc�v�|����||�����Sr)� as_mutable� analytic_funcr)r-�frs rrGz ImmutableRepMatrix.analytic_funcNs.����� � �.�.�q�!�4�4�A�A�C�C�Cr)F)�__name__� __module__� __qualname__�__doc__r*r �__hash__r.�propertyr rr6rr;r@rDrrrG� __classcell__)r?s@rr$r$s(���������)�)�)��"�H��������X������X���&�&��X�&�������J�J�J�-�-�-�-�-�-�!0� A� I����� 1�2�2��D�D�D�D�D�D�Drr$c�J�eZdZdZdZdZdZed���Zed���Z dS)raPCreate 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�g��n�$@c��t|��dkr#t|dt��r|dS|�dd��dur)t|��dkrt d���|\}}}n |j|i|��\}}}t |��}|�|||��}|�|��S)N�rr.TF�zA'copy=False' requires a matrix be initialized as rows,cols,[list]) �len� isinstancer�getr=�_handle_creation_inputs�list�_flat_list_to_DomainMatrix�_fromrep)r'r(r)rr � flat_list�reps rr&zImmutableDenseMatrix._newjs��� �t�9�9��>�>�j��a��2F�G�G�>���7�N� �:�:�f�d� #� #�u� ,� ,��4�y�y�A�~�~�� c�d�d�d�$(� !�D�$� � �$?�C�$?��$P��$P�$P� !�D�$� ��Y���I��,�,�T�4��C�C���|�|�C� � � rc ��|j\}}|������}tj|t |��t |��t |ddi���}||_||_||_ |S)N�sympifyF) r6�to_sympy� to_list_flatrr*rrr4r1�_rep)r'r]rr r\�objs rr[zImmutableDenseMatrix._fromrepzsw���Y� ��d��L�L�N�N�/�/�1�1� ��m�C� �D�M�M� �D�M�M� �9� ,�e� ,� ,�.�.���� ��� ����� rN) rIrJrKrL� _iterable�_class_priority� _op_priority� classmethodr&r[rrrrrRsc��������&�I��O��L�� !� !��[� !�� � ��[� � � rrc�F�eZdZdZdZdZed���Zed���ZdS)�ImmutableSparseMatrixa�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�|�|j|i|��\}}}|�|||��}|�|��Sr)rX�_smat_to_DomainMatrixr[)r'r(r)rr �smatr]s rr&zImmutableSparseMatrix._new�sI��6�3�6��G��G�G���d�D��'�'��d�D�9�9���|�|�C� � � rc� �|j\}}|������}tj|t |��t |��t |����}||_||_||_ |Sr) r6r`�to_dokrr*rrr4r1rb)r'r]rr rmrcs rr[zImmutableSparseMatrix._fromrep�sg���Y� ��d��|�|�~�~�$�$�&�&���m�C������� � �t�D�z�z�J�J���� ��� ����� rN) rIrJrKrL� is_Matrixrergr&r[rrrriri�s^��������(�I��O��!�!��[�!�����[���rric�:�|j|jkrdS||z jS)a�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)r6�is_zero_matrix)�lhs�rhss r� _eval_is_eqru�s%�� �y�C�I����u� �#�I� %�%rN)!�mpmath.matrices.matricesr� sympy.corerrr�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.multipledispatchrrr"r$r�ImmutableMatrixrirurrr�<module>r�s���,�,�,�,�,�,�)�)�)�)�)�)�)�)�)�)�&�&�&�&�&�&�$�$�$�$�$�$�N�N�N�N�N�N�N�N�,�,�,�,�,�,�1�1�1�1�1�1�0�0�0�0�0�0�.�.�.�.�.�.�1�1�1�1�1�1�+�+�+�+�+�+����!/��*��9�9�9� 3��'��1D�1D�1D�1D�1D��J�1D�1D�1D�h3�3�3�3�3�;�(:�3�3�3�n'��(�(�(�(�(�O�-?�(�(�(�V �� � 4�5�5� &� &�6�5� &� &� &r
Memory