o
    i ep&                     @   s  d 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	 dd
lm
Z
 ddlmZ eejejdd Zeejejdd Zeejejdd Zeejejdd Zeeje
jdd Zee
jejdd Zeejejdd Zeejejdd Zeejejdd Zeeje	jdd Zee	jejd d! Zeejejd"d# Zeej ej d$d% Z!d&S )'z(Registrations for LinearOperator.matmul.    )linear_operator)linear_operator_algebra)linear_operator_block_diag)linear_operator_circulant)linear_operator_composition)linear_operator_diag)linear_operator_identity) linear_operator_lower_triangular)linear_operator_zeros)registrations_utilc                 C   sV   t | |}d}d}d}|rt | |}n
|du rd}d}d}tj| |g||||dS )z(Generic matmul of two `LinearOperator`s.NF	operatorsis_non_singularis_self_adjointis_positive_definite	is_square)r   r   combined_non_singular_hintr   LinearOperatorComposition)linop_alinop_br   r   r   r    r   `/var/www/myenv/lib/python3.10/site-packages/tensorflow/python/ops/linalg/matmul_registrations.py_matmul_linear_operator   s&   r   c                 C   s   ~ |S Nr   )identitylinopr   r   r   %_matmul_linear_operator_identity_left:      r   c                 C   s   ~| S r   r   )r   r   r   r   r   &_matmul_linear_operator_identity_rightB   r   r   c              	   C   s:   t j|  | j|j t| |t| |t| |ddS )z/Matmul of two ScaledIdentity `LinearOperators`.T)num_rows
multiplierr   r   r   r   )r   LinearOperatorScaledIdentitydomain_dimension_tensorr    r   r   $combined_commuting_self_adjoint_hint)combined_commuting_positive_definite_hintr   r   r   r   r   '_matmul_linear_operator_scaled_identityJ   s   
r&   c                 C   s   |j r| j s
td|S NzhMatmul with non-square `LinearOperator`s or non-square `LinearOperatorZeros` not supported at this time.r   
ValueError)r   zerosr   r   r   #_matmul_linear_operator_zeros_right_      r+   c                 C   s   | j r|j s
td| S r'   r(   )r*   r   r   r   r   "_matmul_linear_operator_zeros_lefti   r,   r-   c                 C   s4   t j| j|j t| |t| |t| |ddS NT)diagr   r   r   r   )r   LinearOperatorDiagr/   r   r   r#   r$   r%   r   r   r   _matmul_linear_operator_diagv   s   
r1   c                 C   s4   t j| j|j t| |t| |t| |ddS r.   r   r0   r/   r    r   r   r#   r$   )
linop_diaglinop_scaled_identityr   r   r   2_matmul_linear_operator_diag_scaled_identity_right      
r5   c                 C   s4   t j|j| j t|| t|| t|| ddS r.   r2   )r4   r3   r   r   r   1_matmul_linear_operator_diag_scaled_identity_left   r6   r7   c                 C   s2   t j| jd |  t| |t| |d ddS )N).NTtrilr   r   r   r   )r	   LinearOperatorLowerTriangularr/   to_denser   r   r#   )r3   linop_triangularr   r   r   !_matmul_linear_operator_diag_tril   s   r=   c                 C   s.   t j|  |j t|| t|| d ddS )NTr8   )r	   r:   r;   r/   r   r   r#   )r<   r3   r   r   r   !_matmul_linear_operator_tril_diag   s   r>   c                 C   sJ   t | |jst| |S | j| j|j t| |t| |t| |ddS )NT)spectrumr   r   r   r   )
isinstance	__class__r   r?   r   r   r#   r$   r%   r   r   r   +_matmul_linear_operator_circulant_circulant   s   

rB   c                 C   s0   t jdd t| j|jD t| |d d ddS )Nc                 S   s   g | ]	\}}| |qS r   )matmul).0o1o2r   r   r   
<listcomp>   s    zA_matmul_linear_operator_block_diag_block_diag.<locals>.<listcomp>Tr   )r   LinearOperatorBlockDiagzipr   r   r   r%   r   r   r   -_matmul_linear_operator_block_diag_block_diag   s   rJ   N)"__doc__tensorflow.python.ops.linalgr   r   r   r   r   r   r   r	   r
   r   RegisterMatmulLinearOperatorr   LinearOperatorIdentityr   r   r!   r&   LinearOperatorZerosr+   r-   r0   r1   r5   r7   r:   r=   r>   _BaseLinearOperatorCirculantrB   rH   rJ   r   r   r   r   <module>   s   












