o
    ?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   ZLinearOperatorComposition)linop_alinop_br   r   r   r    r   r/home/www/facesmatcher.com/pyenv/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)Znum_rows
multiplierr   r   r   r   )r   LinearOperatorScaledIdentityZ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   
r.   c                 C   s4   t j| j|j t| |t| |t| |ddS r+   r   r-   r,   r   r   r   r    r!   )
linop_diaglinop_scaled_identityr   r   r   2_matmul_linear_operator_diag_scaled_identity_right      
r2   c                 C   s4   t j|j| j t|| t|| t|| ddS r+   r/   )r1   r0   r   r   r   1_matmul_linear_operator_diag_scaled_identity_left   r3   r4   c                 C   s2   t j| jd |  t| |t| |d ddS )N).NTZtrilr   r   r   r   )r	   LinearOperatorLowerTriangularr,   to_denser   r   r    )r0   linop_triangularr   r   r   !_matmul_linear_operator_diag_tril   s   r9   c                 C   s.   t j|  |j t|| t|| d ddS )NTr5   )r	   r6   r7   r,   r   r   r    )r8   r0   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   

r>   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).0Z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   rE   N)"__doc__Ztensorflow.python.ops.linalgr   r   r   r   r   r   r   r	   r
   r   ZRegisterMatmulZLinearOperatorr   ZLinearOperatorIdentityr   r   r   r#   ZLinearOperatorZerosr(   r*   r-   r.   r2   r4   r6   r9   r:   Z_BaseLinearOperatorCirculantr>   rC   rE   r   r   r   r   <module>   s   












