�
��gn3 � �� � d dl mZ d dlmZ ddlmZmZmZ ddlm Z d� Z
d� Zd� Zdd
�Z
e fd�Ze fd�Ze fd
�Ze fd�Ze fd�Ze fd�Ze fd�Zdd�Zd� Zdd�Ze fd�Zde dfd�ZdS )� )�DMNonInvertibleMatrixError)�EX� )�MatrixError�NonSquareMatrixError�NonInvertibleMatrixError��_iszeroc �N � | j r| j S | j | j k rD| j � | � � � � � � | j � � S | j � | � | j � � � � � � � S )a Subroutine for full row or column rank matrices.
For full row rank matrices, inverse of ``A * A.H`` Exists.
For full column rank matrices, inverse of ``A.H * A`` Exists.
This routine can apply for both cases by checking the shape
and have small decision.
)�is_zero_matrix�H�rows�cols�multiply�inv)�Ms �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/sympy/matrices/inverse.py�_pinv_full_rankr s � � �� ��s�
��v������s�|�|�A���"�"�$�$�-�-�a�c�2�2�2��s�|�|�A�J�J�q�s�O�O�/�/�1�1�2�2�2� c � � | j r| j S | � � � \ }}t |� � }t |� � }|� |� � S )z�Subroutine for rank decomposition
With rank decompositions, `A` can be decomposed into two full-
rank matrices, and each matrix can take pseudoinverse
individually.
)r r
�rank_decompositionr r )r �B�C�Bp�Cps r �_pinv_rank_decompositionr sU � � �� ��s�
����!�!�D�A�q� �� � �B� �� � �B�
�;�;�r�?�?�r c � � | j r| j S | }| j } | j | j k r�|� |� � � d�� � \ }}|� d� � � }|� |� � � |j � � � |� � S |� |� � � d�� � \ }}|� d� � � }|� |� � � |� � � |j � � S # t $ r t d� � �w xY w)z�Subroutine using diagonalization
This routine can sometimes fail if SymPy's eigenvalue
computation is not reliable.
T)� normalizec �. � t | � � rdnd| z S �Nr r r ��xs r �<lambda>z'_pinv_diagonalization.<locals>.<lambda><