a
    7Sic
                     @   s   d Z ddlmZ ddlZddlmZmZ dd Zdd Zee eed	d
dZdd Z	dd Z
dd Zeee eedddZee edddZdd Zd"eee eeef dddZddeeeeef dd d!ZdS )#z:Various linear algebra utility methods for internal use.

    )TensorN)OptionalTuplec                 C   sD   t | tjr| jtjkS d}tj s8|dt| 7 }t	|dS )z$Check if tensor A is a sparse tensorzexpected Tensorz but got {}N)

isinstancetorchr   layout
sparse_coojitis_scriptingformattype	TypeError)AZ	error_str r   O/var/www/html/django/DPS/env/lib/python3.9/site-packages/torch/_linalg_utils.py	is_sparse   s    
r   c                 C   s$   | j }|tjtjtjfv r|S tjS )zTReturn the floating point dtype of tensor A.

    Integer types map to float32.
    )dtyper   float16float32float64)r   r   r   r   r   get_floating_dtype   s    r   )r   Breturnc                 C   s.   | du r|S t | r"tj| |S t| |S )ziMultiply two matrices.

    If A is None, return B. A can be sparse or dense. B is always
    dense.
    N)r   r   sparsemmmatmul)r   r   r   r   r   r       s
    r   c                 C   s   |   r|  S | S )z]Return conjugate of tensor A.

    .. note:: If A's dtype is not complex, A is returned.
    )
is_complexconjr   r   r   r   	conjugate-   s    r   c                 C   s   t | j}| |d |d S )z9Return transpose of a matrix or batches of matrices.
          )lenshape	transpose)r   ndimr   r   r   r$   7   s    
r$   c                 C   s   t t| S )zCReturn transpose conjugate of a matrix or batches of matrices.
    )r   r$   r   r   r   r   transjugate>   s    r&   )Xr   Yr   c                 C   s   t t| t ||S )z7Return bilinear form of matrices: :math:`X^T A Y`.
    )r   r$   )r'   r   r(   r   r   r   bformD   s    r)   r   Sc                 C   s   t || |S )z+Return quadratic form :math:`S^T A S`.
    )r)   r*   r   r   r   qformJ   s    r,   c                 C   s*   | j rtj| j}ntjt|  }|S )z*Return orthogonal basis of A columns.
    )is_cudar   linalgqrQorgqrgeqrf)r   r0   r   r   r   basisP   s    r3   F)r   largestr   c                 C   sH   |du rd}t jj| dd\}}|r@t j|dd}t j|dd}||fS )z4Return eigenpairs of A with specified ordering.
    NFU)UPLO))dims)r   r.   eighflip)r   r4   EZr   r   r   symeig[   s    r=   )out)inputr   r   c                C   s   t dd S )NzxThis function was deprecated since version 1.9 and is now removed. Please use the `torch.linalg.solve` function instead.)RuntimeError)r?   r   r>   r   r   r   solvei   s    rA   )F)__doc__r   r   typingr   r   r   r   r   r   r$   r&   r)   r,   r3   boolr=   rA   r   r   r   r   <module>   s   

 