403Webshell
Server IP : 35.80.110.71  /  Your IP : 216.73.216.221
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/sympy/tensor/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/sympy/tensor/__pycache__/toperators.cpython-312.pyc
�

M�Zd�"��n�ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZm
Z
mZGd�de�Zy	)
�)�permutedims)�Number)�S)�Symbol)�sympify)�Tensor�TensExpr�TensAdd�TensMulc��eZdZdZd�Zed��Zed��Zed��Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zed��Zed
��Zd�Zy)�PartialDerivativea�

    Partial derivative for tensor expressions.

    Examples
    ========

    >>> from sympy.tensor.tensor import TensorIndexType, TensorHead
    >>> from sympy.tensor.toperators import PartialDerivative
    >>> from sympy import symbols
    >>> L = TensorIndexType("L")
    >>> A = TensorHead("A", [L])
    >>> B = TensorHead("B", [L])
    >>> i, j, k = symbols("i j k")

    >>> expr = PartialDerivative(A(i), A(j))
    >>> expr
    PartialDerivative(A(i), A(j))

    The ``PartialDerivative`` object behaves like a tensorial expression:

    >>> expr.get_indices()
    [i, -j]

    Notice that the deriving variables have opposite valence than the
    printed one: ``A(j)`` is printed as covariant, but the index of the
    derivative is actually contravariant, i.e. ``-j``.

    Indices can be contracted:

    >>> expr = PartialDerivative(A(i), A(i))
    >>> expr
    PartialDerivative(A(L_0), A(L_0))
    >>> expr.get_indices()
    [L_0, -L_0]

    The method ``.get_indices()`` always returns all indices (even the
    contracted ones). If only uncontracted indices are needed, call
    ``.get_free_indices()``:

    >>> expr.get_free_indices()
    []

    Nested partial derivatives are flattened:

    >>> expr = PartialDerivative(PartialDerivative(A(i), A(j)), A(k))
    >>> expr
    PartialDerivative(A(i), A(j), A(k))
    >>> expr.get_indices()
    [i, -j, -k]

    Replace a derivative with array values:

    >>> from sympy.abc import x, y
    >>> from sympy import sin, log
    >>> compA = [sin(x), log(x)*y**3]
    >>> compB = [x, y]
    >>> expr = PartialDerivative(A(i), B(j))
    >>> expr.replace_with_arrays({A(i): compA, B(i): compB})
    [[cos(x), 0], [y**3/x, 3*y**2*log(x)]]

    The returned array is indexed by `(i, -j)`.

    Be careful that other SymPy modules put the indices of the deriving
    variables before the indices of the derivand in the derivative result.
    For example:

    >>> expr.get_free_indices()
    [i, -j]

    >>> from sympy import Matrix, Array
    >>> Matrix(compA).diff(Matrix(compB)).reshape(2, 2)
    [[cos(x), y**3/x], [0, 3*y**2*log(x)]]
    >>> Array(compA).diff(Array(compB))
    [[cos(x), y**3/x], [0, 3*y**2*log(x)]]

    These are the transpose of the result of ``PartialDerivative``,
    as the matrix and the array modules put the index `-j` before `i` in the
    derivative result. An array read with index order `(-j, i)` is indeed the
    transpose of the same array read with index order `(i, -j)`. By specifying
    the index order to ``.replace_with_arrays`` one can get a compatible
    expression:

    >>> expr.replace_with_arrays({A(i): compA, B(i): compB}, [-j, i])
    [[cos(x), y**3/x], [0, 3*y**2*log(x)]]
    c���t|t�r|j|z}|j}|j	t|�|�\}}}}t
j|g|���}||_||_	||_
|S�N)�
isinstancer
�	variables�expr� _contract_indices_for_derivativerr	�__new__�_indices�_free�_dum)�clsrr�args�indices�free�dum�objs        �9/usr/lib/python3/dist-packages/sympy/tensor/toperators.pyrzPartialDerivative.__new__`sy���d�-�.�����2�I��9�9�D�#&�#G�#G�
�d�G�Y�$ � ��g�t�S����s�*�T�*�������	�����
�c�"�tjSr)r�One��selfs r�coeffzPartialDerivative.coeffqs���u�u�rc��|Sr�r"s r�nocoeffzPartialDerivative.nocoeffus���rc
�.�g}|D]u}t|t�rA|j�}|j|j	|D�cic]}||��c}���Tt|t
�s�e|j|��wt
j|g|zd��\}}}	}
tdt|��D]R}||}t|t�s�||j�}||j	|D�cic]}||��c}�||<�T|||	|
fScc}wcc}w)NT)�replace_indices�)
rr�get_free_indices�append�xreplacerr�_tensMul_contract_indices�range�len)
rrr�variables_opposite_valence�i�i_free_indices�krrrr�args_i�	i_indicess
             rrz2PartialDerivative._contract_indices_for_derivativeys%��%'�"��	5�A��!�V�$�!"�!3�!3�!5��*�1�1��
�
�>�#B�a�A��r�E�#B�C�E��A�v�&�*�1�1�!�4�
	5�$+�#D�#D�
�F�/�/��$G� ��g�t�S��q�#�d�)�$�	G�A��!�W�F��&�&�)� ��G�4�4�6�	��q�'�*�*�9�+E�a�A��r�E�+E�F��Q��		G��W�d�C�'�'��$C��,Fs�D
�0D
c��|j|j|j�\}}}}|j|�}||_||_||_|Sr)rrr�funcrrr)r#�hintsrrrrrs       r�doitzPartialDerivative.doit�sR��#'�#H�#H����TX�Tb�Tb�#c� ��g�t�S��d�i�i���������	�����
rc	�V�|j|j|j�\}}}}|j|�}||_||_||_|}|djstjSt|jt�rf|jj|jjD�cgc]-}|j|g|j���j���/c}�}|St|jt��rt|j�dk(r�g}t!|jj�}	t#t|	��D]t}
tt%|	|
�t&�r� |j|	|
g|j���j�}|j)t|	d|
|gz|	|
dzdz���vtj*|�}|S|j}|jD]"}|j||�j�}�$|Scc}w)Nrr*)rrrr8rrr�free_symbolsr�Zerorr
r�_expand_partial_derivativerr0�listr/rrr,�fromiter)
r#rrrrr�result�a�terms�mulargs�ind�d�vs
             rr>z,PartialDerivative._expand_partial_derivative�s���#'�#H�#H����TX�Tb�Tb�#c� ��g�t�S��d�i�i���������	�������A�w�#�#��6�6�M�
����'�
*�"�S�X�X�]�]�#�[�[�-�-�%/���D�I�I�a�0�#�-�-�0�K�K�M�%/�0�F�8�
�3����'�
*��3�=�=�!�Q�&����s�x�x�}�}�-�� ��W��.�H�C�%�g�g�c�l�&;�V�D�&�D�I�I�g�c�l�C�S�]�]�C�^�^�`�����W�w�t��}�23��05�18�#��'��1D�0E�&G�H�H�!�)�)�%�0���
��������O�A�!�Y�Y�v�q�1�L�L�N�F�O��
��9%/s�92H&c���|j}|jD]R}t|t�r|j	|�}�%|j
r|j
|�}�Ctj}�T|Sr)	rrrr	�_eval_partial_derivative�	_diff_wrt�_eval_derivativerr=)r#rArGs   r�_perform_derivativez%PartialDerivative._perform_derivative�s_���������	$�A��&�(�+��8�8��;���;�;�#�4�4�Q�7�F��V�V�F�	$��
rc��|jSr)rr"s r�get_indiceszPartialDerivative.get_indices�s���}�}�rc�b�t|jd���}|D�cgc]}|d��	c}Scc}w)Nc��|dS�Nr*r&)�xs r�<lambda>z4PartialDerivative.get_free_indices.<locals>.<lambda>�s
���!��r)�keyr)�sortedr)r#rr2s   rr+z"PartialDerivative.get_free_indices�s*���d�j�j�n�5��"�#���!��#�#��#s�,c��|jj|�}|j�D��cic]
\}}||��}}}|jD�cgc]}|j|���}}|j|g|���Scc}}wcc}wr)rr-�itemsrr8)r#�replrr4rG�mirroredr2rs        r�_replace_indicesz"PartialDerivative._replace_indices�sy���y�y�!�!�$�'��'+�z�z�|�4�t�q�!�Q�B���F�4��4�37�>�>�B�a�Q�Z�Z��)�B�	�B��t�y�y��*�	�*�*��5��Bs�A<�Bc� �|jdS)Nr�rr"s rrzPartialDerivative.expr�s���y�y��|�rc� �|jddSrQr\r"s rrzPartialDerivative.variables�s���y�y���}�rc
��ddlm}m}|jj	|�\}}|j
D�]|}|j	|�\}}|D�	cgc]}	|	��}}	t
|D�	cgc]}	|	j���c}	�\}
}t|j�}|||�}t|j�}||z
}
t|t|�D�	cgc]}	|	|
z��	c}	tt|
��z�}|j�}|d}dgtt|��D�	cgc]
}	td���c}	z}t|
�D] \}	}|	|d<|t!|�xx|zcc<�"||vr3|j#|�}||d|dzf�}|j%|���l|j'|���||fScc}	wcc}	wcc}	wcc}	w)Nr*)�derive_by_array�tensorcontractionr)�arrayr_r`r�
_extract_datar�zip�as_coeff_Mulr0�shaperr/r?�
as_mutable�slice�	enumerate�tuple�index�popr,)r#�replacement_dictr_r`rra�variable�var_indices�	var_arrayr2�coeff_array�
dim_before�	dim_after�dim_increase�varindex�coeff_indexr$�poss                  rrbzPartialDerivative._extract_data�s���=����0�0�1A�B�������	)�H�%-�%;�%;�<L�%M�"�K��'2�3�!�A�2�3�K�3�%(�Y�*O��1�>�>�+;�*O�%P�"�K���U�[�[�)�J�#�E�9�5�E��E�K�K�(�I�$�z�1�L���%�
�BS�'T�Q��L�(8�'T�W[�\a�bn�\o�Wp�'p�q�E��$�$�&�E�"�1�~�H��#�e�C��L�6I� J���t�� J�J�K�%�k�2�
3���5�!"��A���e�K�(�)�U�2�)�
3��y�G�#��m�m�X�I�.��)�%�!�S��U��<�����C� ����x�(�+	)�,��~���)4��*O��
(U��!Ks�
F7�$F<
�
G�"GN)�__name__�
__module__�__qualname__�__doc__r�propertyr$r'�classmethodrr:r>rLrNr+rZrrrbr&rrr
r
	s���T�l�"���������(��(�,�*�X
��$�+���������rr
N)�sympyr�sympy.core.numbersr�sympy.core.singletonr�sympy.core.symbolr�sympy.core.sympifyr�sympy.tensor.tensorrr	r
rr
r&rr�<module>r�s(���%�"�$�&�B�B�w��wr

Youez - 2016 - github.com/yon3zu
LinuXploit