
    Ed                     <    d dl mZ d	dZdefdZd	dZddddZdS )
   )_iszeroFc                 T                           |d          \  }} fd|D             S )a  Returns a list of vectors (Matrix objects) that span columnspace of ``M``

    Examples
    ========

    >>> from sympy import Matrix
    >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])
    >>> M
    Matrix([
    [ 1,  3, 0],
    [-2, -6, 0],
    [ 3,  9, 6]])
    >>> M.columnspace()
    [Matrix([
    [ 1],
    [-2],
    [ 3]]), Matrix([
    [0],
    [0],
    [6]])]

    See Also
    ========

    nullspace
    rowspace
    Tsimplifywith_pivotsc                 :    g | ]}                     |          S  )col).0iMs     8lib/python3.11/site-packages/sympy/matrices/subspaces.py
<listcomp>z _columnspace.<locals>.<listcomp>#   s#    %%%AEE!HH%%%    )echelon_form)r   r   reducedpivotss   `   r   _columnspacer      s8    : nnhDnIIOGV%%%%f%%%%r   c                 \   
                       ||          \  }

fdt           j                  D             }g }|D ]^} j        g j        z  } j        ||<   t          
          D ]\  }}	||	xx         |||f         z  cc<   |                    |           _ fd|D             S )a  Returns list of vectors (Matrix objects) that span nullspace of ``M``

    Examples
    ========

    >>> from sympy import Matrix
    >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])
    >>> M
    Matrix([
    [ 1,  3, 0],
    [-2, -6, 0],
    [ 3,  9, 6]])
    >>> M.nullspace()
    [Matrix([
    [-3],
    [ 1],
    [ 0]])]

    See Also
    ========

    columnspace
    rowspace
    )
iszerofuncr   c                     g | ]}|v|	S r	   r	   )r   r   r   s     r   r   z_nullspace.<locals>.<listcomp>B   s"    ===qQf_====r   c                 H    g | ]}                     j        d |          S )r   )_newcols)r   br   s     r   r   z_nullspace.<locals>.<listcomp>P   s+    000QAFF161a  000r   )rrefranger   zeroone	enumerateappend)r   r   r   r   	free_varsbasisfree_varvecpiv_rowpiv_colr   s   `         @r   
_nullspacer(   &   s    4 ff
XfFFOGV====E!&MM===IE 	 	 16)H )& 1 1 	7 	7GWLLLGGX$566LLLLS0000%0000r   c                     |                      |d          \  }fdt          t          |                    D             S )aD  Returns a list of vectors that span the row space of ``M``.

    Examples
    ========

    >>> from sympy import Matrix
    >>> M = Matrix(3, 3, [1, 3, 0, -2, -6, 0, 3, 9, 6])
    >>> M
    Matrix([
    [ 1,  3, 0],
    [-2, -6, 0],
    [ 3,  9, 6]])
    >>> M.rowspace()
    [Matrix([[1, 3, 0]]), Matrix([[0, 0, 6]])]
    Tr   c                 :    g | ]}                     |          S r	   )row)r   r   r   s     r   r   z_rowspace.<locals>.<listcomp>f   s#    777qGKKNN777r   )r   r   len)r   r   r   r   s      @r   	_rowspacer-   S   sF    " nnhDnIIOGV7777E#f++$6$67777r   )	normalize	rankcheckc                   ddl m} |sg S |d         j        dk    }d |D             } | j        | } |||          \  }}|r'|j        t          |          k     rt          d          g }	t          |j                  D ]I}
|r | |dd|
f         j                  }n | |dd|
f                   }|		                    |           J|	S )a  Apply the Gram-Schmidt orthogonalization procedure
    to vectors supplied in ``vecs``.

    Parameters
    ==========

    vecs
        vectors to be made orthogonal

    normalize : bool
        If ``True``, return an orthonormal basis.

    rankcheck : bool
        If ``True``, the computation does not stop when encountering
        linearly dependent vectors.

        If ``False``, it will raise ``ValueError`` when any zero
        or linearly dependent vectors are found.

    Returns
    =======

    list
        List of orthogonal (or orthonormal) basis vectors.

    Examples
    ========

    >>> from sympy import I, Matrix
    >>> v = [Matrix([1, I]), Matrix([1, -I])]
    >>> Matrix.orthogonalize(*v)
    [Matrix([
    [1],
    [I]]), Matrix([
    [ 1],
    [-I]])]

    See Also
    ========

    MatrixBase.QRdecomposition

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
    r   )_QRdecomposition_optional    c                 6    g | ]}|                                 S r	   )r%   )r   xs     r   r   z"_orthogonalize.<locals>.<listcomp>   s     """AEEGG"""r   )r.   z0GramSchmidt: vector set not linearly independentN)
decompositionsr1   rowshstackr   r,   
ValueErrorr   Tr!   )clsr.   r/   vecsr1   all_row_vecsr   QRretr   r
   s               r   _orthogonalizer@   i   s   ` :99999 	GLA%L""T"""D
DA$$Q)<<<DAq MQVc$ii' MKLLL
C16]]   	#a1gi..CC#a1g,,C

3Jr   N)F)	utilitiesr   r   r(   r-   r@   r	   r   r   <module>rB      s         & & & &D !W *1 *1 *1 *1Z8 8 8 8, */% E E E E E E Er   