o
    i 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   b/var/www/myenv/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   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   )axisN)trilr   r   is_positive_definiter   )r   r   r   r   r   r   r#   r   expand_dimsr   sign	diag_partr"   r   r   )r   left_op	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   sqrtdiag)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_rowsr0   r1   identity_operatorr   r   r   _cholesky_identitys   s   r6   c                 C   s    t j| jt| jdddddS )NT)r/   
multiplierr   r   r#   r   )r
   LinearOperatorScaledIdentityr3   r   r+   r7   r4   r   r   r   _cholesky_scaled_identity   s   
r9   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   )block_diag_operatorr   r   r   _cholesky_block_diag   s   rE   c                 C   r:   )Nc                 S   r;   r   r<   r=   r   r   r   r@      rA   z'_cholesky_kronecker.<locals>.<listcomp>TrB   )r   LinearOperatorKroneckerr   )kronecker_operatorr   r   r   _cholesky_kronecker   s   rH   N) __doc__tensorflow.python.opsr   r   r   tensorflow.python.ops.linalgr   r   r   r   r	   r
   r   r   r   r   RegisterCholeskyLinearOperatorr   r   LinearOperatorCompositionr)   r*   r.   r2   r6   r8   r9   rC   rE   rF   rH   r   r   r   r   <module>   sT   

	
0
	




