o
    ?e                     @   s2  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 ddlmZ ddlmZ ejZeejdd Zdd Zee	jdd Zee
jdd Zeejdd Zeejdd Zeejdd Zeejdd ZdS )z*Registrations for LinearOperator.cholesky.    )	array_ops)
linalg_ops)math_ops)linear_operator)linear_operator_algebra)linear_operator_block_diag)linear_operator_composition)linear_operator_diag)linear_operator_identity)linear_operator_kronecker) linear_operator_lower_triangular)linear_operator_utilc                 C   s   t t|  ddddS )NTFis_non_singularis_self_adjoint	is_square)LinearOperatorLowerTriangularr   choleskyto_denselinop r   t/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/ops/linalg/cholesky_registrations.py_cholesky_linear_operator$   s   r   c                 C   s2   t | jdkr	dS t| jsdS t| jd tS )zDDetermines if linop = L @ L.H for L = LinearOperatorLowerTriangular.   Fr   )len	operatorsr   Zis_aat_form
isinstancer   r   r   r   r   _is_llt_product-   s
   r   c                 C   sz   t | stt|  ddddS | jd }|jr|S tjt	
| dd}t|j| |j|j|jr8dddS dddS )	z-Computes Cholesky(LinearOperatorComposition).TFr   r   )ZaxisN)trilr   r   is_positive_definiter   )r   r   r   r   r   r   r!   r   Zexpand_dimsr   signZ	diag_partr    r   r   )r   Zleft_opZ	diag_signr   r   r   %_cholesky_linear_operator_composition6   s*   

r#   c                 C   s   t jt| jdddddS )NT)r   r   r!   r   )r	   LinearOperatorDiagr   sqrtZdiag)Zdiag_operatorr   r   r   _cholesky_diagh   s   
r&   c              	   C   s   t j| j| j| jdddddS )NT)num_rowsbatch_shapedtyper   r   r!   r   )r
   LinearOperatorIdentity	_num_rowsr(   r)   Zidentity_operatorr   r   r   _cholesky_identitys   s   r-   c                 C   s    t j| jt| jdddddS )NT)r'   
multiplierr   r   r!   r   )r
   LinearOperatorScaledIdentityr+   r   r%   r.   r,   r   r   r   _cholesky_scaled_identity   s   
r0   c                 C      t jdd | jD dd ddS )Nc                 S      g | ]}|  qS r   r   .0operatorr   r   r   
<listcomp>       z(_cholesky_block_diag.<locals>.<listcomp>Tr   r   r   r   )r   LinearOperatorBlockDiagr   )Zblock_diag_operatorr   r   r   _cholesky_block_diag   s   r;   c                 C   r1   )Nc                 S   r2   r   r3   r4   r   r   r   r7      r8   z'_cholesky_kronecker.<locals>.<listcomp>Tr9   )r   LinearOperatorKroneckerr   )Zkronecker_operatorr   r   r   _cholesky_kronecker   s   r=   N) __doc__Ztensorflow.python.opsr   r   r   Ztensorflow.python.ops.linalgr   r   r   r   r	   r
   r   r   r   r   ZRegisterCholeskyZLinearOperatorr   r   ZLinearOperatorCompositionr#   r$   r&   r*   r-   r/   r0   r:   r;   r<   r=   r   r   r   r   <module>   sT   

	
0
	




