o
    ?e!                     @   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d"S )#z'Registrations for LinearOperator.solve.    )linear_operator)linear_operator_algebra)linear_operator_block_diag)linear_operator_circulant)linear_operator_composition)linear_operator_diag)linear_operator_identity)linear_operator_inversion) linear_operator_lower_triangular)registrations_utilc                 C   s\   t | |}d}d}d}|rt | |}n
|du rd}d}d}tjt| |g||||dS )z'Generic solve of two `LinearOperator`s.NF	operatorsis_non_singularis_self_adjointis_positive_definite	is_square)r   r   combined_non_singular_hintr   ZLinearOperatorCompositionr	   LinearOperatorInversion)linop_alinop_br   r   r   r    r   q/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/linalg/solve_registrations.py_solve_linear_operator   s*   r   c                 C   s   | j |S )z+Solve inverse of generic `LinearOperator`s.)operatormatmulr   r   r   r   r   _solve_inverse_linear_operator;   s   r   c                 C   s   ~ |S Nr   )identitylinopr   r   r   $_solve_linear_operator_identity_leftD   s   r    c                 C   s
   ~|   S r   )Zinverse)r   r   r   r   r   %_solve_linear_operator_identity_rightL   s   r!   c              	   C   s:   t j|  |j| j t| |t| |t| |ddS )z.Solve 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_hintr   r   r   r   &_solve_linear_operator_scaled_identityT   s   
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   _solve_linear_operator_diagi   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   1_solve_linear_operator_diag_scaled_identity_righty      
r-   c                 C   s4   t j|j| j t|| t|| t|| ddS r'   )r   r)   r(   r"   r   r   r$   r%   )r,   r+   r   r   r   0_solve_linear_operator_diag_scaled_identity_left   r.   r/   c                 C   s2   t j| | jd  t| |t| |d ddS )N).NT)Ztrilr   r   r   r   )r
   LinearOperatorLowerTriangularZto_denser(   r   r   r$   )r+   Zlinop_triangularr   r   r    _solve_linear_operator_diag_tril   s   r1   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   r2   r   r   r$   r%   r   r   r   r   *_solve_linear_operator_circulant_circulant   s   

r5   c                 C   s0   t jdd t| j|jD t| |d d ddS )Nc                 S   s   g | ]	\}}| |qS r   )Zsolve).0Zo1o2r   r   r   
<listcomp>   s    z@_solve_linear_operator_block_diag_block_diag.<locals>.<listcomp>Tr   )r   LinearOperatorBlockDiagzipr   r   r   r   r   r   r   ,_solve_linear_operator_block_diag_block_diag   s   r;   N) __doc__Ztensorflow.python.ops.linalgr   r   r   r   r   r   r   r	   r
   r   ZRegisterSolveZLinearOperatorr   r   r   ZLinearOperatorIdentityr    r!   r#   r&   r)   r*   r-   r/   r0   r1   Z_BaseLinearOperatorCirculantr5   r9   r;   r   r   r   r   <module>   s   









