
    \ht                     2   S SK Jr  S SKJr  S SKJr  S SKJrJ	r	J
r
  S SKJrJr  S SKJrJr  S SKJr  S SKJrJrJrJr  S S	KJr  S S
KJr  S SKJrJr  S SKJ r   S SK!J"r"  S SK#J$r$J%r%  SSK&J'r'J(r(J)r)  SSK*J+r+J,r,  SSK-J.r.   " S S\,5      r/ " S S\/5      r0S r1g)    )defaultdict)index)Expr)Kind
NumberKindUndefinedKind)IntegerRational)_sympifySympifyError)S)ZZQQGFEXRAW)DomainMatrix)DMNonInvertibleMatrixError)CoercionFailedNotInvertible)sympy_deprecation_warning)is_sequence)
filldedentas_int   )
ShapeErrorNonSquareMatrixErrorNonInvertibleMatrixError)classof
MatrixBase)
MatrixKindc                   d   \ rS rSr% Sr\\S'   S rS+S jr\	S 5       r
\	S 5       r\	S	 5       r\	S
 5       rS rS rS r\	S 5       rS rS rS rS r\S\4S j5       rS rS rS rS rS rS rS rS r \	S 5       r!\	S 5       r"S r#S  r$S! r%S" r&S# r'S$ r(S% r)S,S& jr*S' r+S-S( jr,S-S) jr-S*r.g).	RepMatrix   a(  Matrix implementation based on DomainMatrix as an internal representation.

The RepMatrix class is a superclass for Matrix, ImmutableMatrix,
SparseMatrix and ImmutableSparseMatrix which are the main usable matrix
classes in SymPy. Most methods on this class are simply forwarded to
DomainMatrix.
_repc                     [        U[        5      (       d'   [        U5      n[        U[        5      (       d  [        $ U R
                  R                  UR
                  5      $ ! [         a	    [        s $ f = fN)
isinstancer"   r   r   NotImplementedr$   unify_eqselfothers     P/var/www/auris/envauris/lib/python3.13/site-packages/sympy/matrices/repmatrix.py__eq__RepMatrix.__eq__5   sb    %++&  eY//%%yy!!%**--   &%%&s   A" "A54A5Nc                    Ub-  U(       a  [        S5      eU R                  R                  U5      $ U R                  nUR                  nU(       dH  UR                  (       a  UR                  5       $ UR                  (       a   UR                  [        5      $ UR                  " S0 UD6nUR                  R                  (       a  UR                  [        5      nU$ ! [         a     UR                  5       $ f = f)a?  Convert to a :class:`~.DomainMatrix`.

Examples
========

>>> from sympy import Matrix
>>> M = Matrix([[1, 2], [3, 4]])
>>> M.to_DM()
DomainMatrix({0: {0: 1, 1: 2}, 1: {0: 3, 1: 4}}, (2, 2), ZZ)

The :meth:`DomainMatrix.to_Matrix` method can be used to convert back:

>>> M.to_DM().to_Matrix() == M
True

The domain can be given explicitly or otherwise it will be chosen by
:func:`construct_domain`. Any keyword arguments (besides ``domain``)
are passed to :func:`construct_domain`:

>>> from sympy import QQ, symbols
>>> x = symbols('x')
>>> M = Matrix([[x, 1], [1, x]])
>>> M
Matrix([
[x, 1],
[1, x]])
>>> M.to_DM().domain
ZZ[x]
>>> M.to_DM(field=True).domain
ZZ(x)
>>> M.to_DM(domain=QQ[x]).domain
QQ[x]

See Also
========

DomainMatrix
DomainMatrix.to_Matrix
DomainMatrix.convert_to
DomainMatrix.choose_domain
construct_domain
z,Options cannot be used with domain parameter )	TypeErrorr$   
convert_todomainis_ZZcopyis_QQr   r   choose_domainis_EXr   )r+   r4   kwargsrepdomrep_doms         r-   to_DMRepMatrix.to_DMA   s    V  NOO99''//iijj yyxxz!>>"-- ##-f- >>((/G & xxz!s   C 
C87C8c                 j   UR                   n[        U5      nU[        :w  ae  UR                  (       a  UnOUR                  (       a  [
        nO[        nXC:w  a  UR                  U5      nUnU[        :w  a  UR                  U5      nU[        :X  a!  [        U[        5      (       d  [        SSSSS9  X4$ )N+  
                non-Expr objects in a Matrix is deprecated. Matrix represents
                a mathematical matrix. To represent a container of non-numeric
                entities, Use a list of lists, TableForm, NumPy array, or some
                other data structure instead.
                1.9deprecated-non-expr-in-matrix   deprecated_since_versionactive_deprecations_target
stacklevel)r4   r   r   
is_Integeris_Rationalr   r3   
from_sympyr'   r   r   )clsr;   elementr4   
new_domains        r-   _unify_element_sympyRepMatrix._unify_element_sympy   s    7#U?!!#
$$
"

 #nnZ0#$//8U?:gt#<#<% */+J
 |    c                 $   [        S U 5       5      (       d  [        SSSSS9  [        X1U4[        5      n[        S U 5       5      (       aC  [        S U 5       5      (       a  UR	                  [
        5      nU$ UR	                  [        5      nU$ )	Nc              3   B   #    U  H  n[        U[        5      v   M     g 7fr&   )
issubclassr   .0typs     r-   	<genexpr>1RepMatrix._dod_to_DomainMatrix.<locals>.<genexpr>   s     :ES:c4((E   rA   rB   rC      rE   c              3   B   #    U  H  n[        U[        5      v   M     g 7fr&   )rT   r
   rU   s     r-   rX   rY      s     :ESz#x((ErZ   c              3   B   #    U  H  n[        U[        5      v   M     g 7fr&   )rT   r	   rU   s     r-   rX   rY      s     =u:c7++urZ   )allr   r   r   r3   r   r   )rL   rowscolsdodtypesr;   s         r-   _dod_to_DomainMatrixRepMatrix._dod_to_DomainMatrix   s     :E:::% */+J
 3te4:E:::=u===nnR( 
 nnR(
rQ   c                     [        [        5      n[        U5       H!  u  pVUS:w  d  M  [        XR5      u  pxXdU   U'   M#     [	        [        [        U5      5      n	U R                  XXI5      n
U
$ Nr   )r   dict	enumeratedivmodsetmaptyperc   )rL   r_   r`   	flat_listelements_dodnrM   ijrb   r;   s              r-   _flat_list_to_DomainMatrix$RepMatrix._flat_list_to_DomainMatrix   sg     #4(#I.JA!|a%,Q" /
 Ci()&&t<G
rQ   c                     [        [        5      nUR                  5        H  u  u  pVnUS:w  d  M  XtU   U'   M     [        [	        [
        UR                  5       5      5      nU R                  XXH5      n	U	$ rf   )r   rg   itemsrj   rk   rl   valuesrc   )
rL   r_   r`   smatrn   rp   rq   rM   rb   r;   s
             r-   _smat_to_DomainMatrixRepMatrix._smat_to_DomainMatrix   sg     #4(#zz|OFQG!|%,Q"  , Cdkkm,-&&t<G
rQ   c                 R    U R                   R                  5       R                  5       $ r&   )r$   to_sympyto_list_flatr+   s    r-   flatRepMatrix.flat   s    yy!!#0022rQ   c                 R    U R                   R                  5       R                  5       $ r&   )r$   r{   to_listr}   s    r-   _eval_tolistRepMatrix._eval_tolist   s    yy!!#++--rQ   c                 R    U R                   R                  5       R                  5       $ r&   )r$   r{   to_dokr}   s    r-   _eval_todokRepMatrix._eval_todok   s    yy!!#**,,rQ   c                 D    U R                  U R                  XU5      5      $ r&   )_fromreprx   )rL   r_   r`   doks       r-   _eval_from_dokRepMatrix._eval_from_dok   s    ||C55d#FGGrQ   c                 4    [        U R                  5       5      $ r&   )list_eval_iter_valuesr}   s    r-   _eval_valuesRepMatrix._eval_values   s    D**,--rQ   c                     U R                   nUR                  nUR                  5       nUR                  (       d  [	        UR
                  U5      nU$ r&   )r$   r4   iter_valuesis_EXRAWrk   r{   )r+   r;   Krv   s       r-   r   RepMatrix._eval_iter_values   s<    iiJJ"zzV,FrQ   c                    ^ U R                   nUR                  nUR                  mUR                  5       nUR                  (       d  U4S jU 5       nU$ )Nc              3   <   >#    U  H  u  pUT" U5      4v   M     g 7fr&   r1   )rV   rp   vr{   s      r-   rX   -RepMatrix._eval_iter_items.<locals>.<genexpr>
  s     8%$!a!%%s   )r$   r4   r{   
iter_itemsr   )r+   r;   r   ru   r{   s       @r-   _eval_iter_itemsRepMatrix._eval_iter_items  s@    iiJJ:: zz8%8ErQ   c                 T    U R                  U R                  R                  5       5      $ r&   r   r$   r6   r}   s    r-   r6   RepMatrix.copy      }}TYY^^-..rQ   returnc                 .   U R                   R                  nU[        [        4;   a  [        nOYU[
        :X  aD  U R                  5        Vs1 s H  o3R                  iM     nn[        U5      S:X  a  Uu  nO[        nO[        S5      e[        U5      $ s  snf )Nr   z%Domain should only be ZZ, QQ or EXRAW)r$   r4   r   r   r   r   rv   kindlenr   RuntimeErrorr    )r+   r4   element_kindekindss        r-   r   RepMatrix.kind  sx    !!b"X%Lu_%)[[]3]VV]E35zQ!&,FGG,'' 4s   
Bc                   ^ SnU R                  5       n[        U5      U R                  U R                  -  :w  a  [        R
                  R                  " T6 nU=(       d#    [        U4S jUR                  5        5       5      $ )NFc              3   @   >#    U  H  oR                   " T6 v   M     g 7fr&   )has)rV   valuepatternss     r-   rX   &RepMatrix._eval_has.<locals>.<genexpr>(  s     J\E99h/\s   )	todokr   r_   r`   r   Zeror   anyrv   )r+   r   zhasr   s    `  r-   	_eval_hasRepMatrix._eval_has   s\     jjls8tyy**66::x(DJsJSZZ\JJJrQ   c                    ^  [        U 4S j[        T R                  5       5       5      (       d  g[        T R	                  5       5      T R                  :H  $ )Nc              3   6   >#    U  H  nTX4   S :H  v   M     g7f)r   Nr1   )rV   rp   r+   s     r-   rX   .RepMatrix._eval_is_Identity.<locals>.<genexpr>+  s     =,<q4:?,<s   F)r^   ranger_   r   r   r}   s   `r-   _eval_is_IdentityRepMatrix._eval_is_Identity*  s:    =E$)),<===4::< DII--rQ   c                 t    X R                   -
  R                  U5      n[        UR                  5       5      S:H  $ rf   )T	applyfuncr   rv   )r+   simpfuncdiffs      r-   _eval_is_symmetricRepMatrix._eval_is_symmetric/  s.    vv((24;;=!Q&&rQ   c                 T    U R                  U R                  R                  5       5      $ )zReturns the transposed SparseMatrix of this SparseMatrix.

Examples
========

>>> from sympy import SparseMatrix
>>> a = SparseMatrix(((1, 2), (3, 4)))
>>> a
Matrix([
[1, 2],
[3, 4]])
>>> a.T
Matrix([
[1, 3],
[2, 4]])
)r   r$   	transposer}   s    r-   _eval_transposeRepMatrix._eval_transpose3  s     " }}TYY00233rQ   c                 j    U R                  U R                  R                  UR                  5      5      $ r&   )r   r$   vstackr*   s     r-   _eval_col_joinRepMatrix._eval_col_joinF  $    }}TYY--ejj9::rQ   c                 j    U R                  U R                  R                  UR                  5      5      $ r&   )r   r$   hstackr*   s     r-   _eval_row_joinRepMatrix._eval_row_joinI  r   rQ   c                 V    U R                  U R                  R                  X5      5      $ r&   )r   r$   extract)r+   rowsListcolsLists      r-   _eval_extractRepMatrix._eval_extractL  s     }}TYY..xBCCrQ   c                     [        X5      $ r&   )_getitem_RepMatrix)r+   keys     r-   __getitem__RepMatrix.__getitem__O  s    !$,,rQ   c                 \    [         R                  " X4[        5      nU R                  U5      $ r&   )r   zerosr   r   rL   r_   r`   r;   s       r-   _eval_zerosRepMatrix._eval_zerosR  s%      $r2||C  rQ   c                 \    [         R                  " X4[        5      nU R                  U5      $ r&   )r   eyer   r   r   s       r-   	_eval_eyeRepMatrix._eval_eyeW  s%    |R0||C  rQ   c                 d    [        X5      R                  U R                  UR                  -   5      $ r&   r   r   r$   r*   s     r-   	_eval_addRepMatrix._eval_add\  %    t#,,TYY-CDDrQ   c                 d    [        X5      R                  U R                  UR                  -  5      $ r&   r   r*   s     r-   _eval_matrix_mulRepMatrix._eval_matrix_mul_  r   rQ   c                     U R                   R                  UR                   5      u  p#UR                  U5      n[        X5      R	                  U5      $ r&   )r$   unifymul_elementwiser   r   )r+   r,   selfrepotherrepnewreps        r-   _eval_matrix_mul_elementwise&RepMatrix._eval_matrix_mul_elementwiseb  sA     IIOOEJJ7((2t#,,V44rQ   c                 ~    U R                  U R                  U5      u  p!U R                  UR                  U5      5      $ r&   )rO   r$   r   	scalarmulr+   r,   r;   s      r-   _eval_scalar_mulRepMatrix._eval_scalar_mulg  s2    ..tyy%@
}}S]]5122rQ   c                 ~    U R                  U R                  U5      u  p!U R                  UR                  U5      5      $ r&   )rO   r$   r   
rscalarmulr   s      r-   _eval_scalar_rmulRepMatrix._eval_scalar_rmulk  s2    ..tyy%@
}}S^^E233rQ   c                 ^    U R                  U R                  R                  [        5      5      $ r&   )r   r$   r   absr}   s    r-   	_eval_AbsRepMatrix._eval_Abso  s     }}TYY00566rQ   c                     U R                   nUR                  nU[        [        4;   a  U R	                  5       $ U R                  UR                  S 5      5      $ )Nc                 "    U R                  5       $ r&   )	conjugate)r   s    r-   <lambda>+RepMatrix._eval_conjugate.<locals>.<lambda>x  s
    rQ   )r$   r4   r   r   r6   r   r   )r+   r;   r4   s      r-   _eval_conjugateRepMatrix._eval_conjugater  sE    iib"X99;==/F!GHHrQ   c                    U R                   [        USS5      :w  a  gSn[        U R                  5       HQ  n[        U R                  5       H5  nXU4   R                  XU4   U5      nUSL a      gUSLd  M,  USL d  M3  UnM7     MS     U$ )ay  Applies ``equals`` to corresponding elements of the matrices,
trying to prove that the elements are equivalent, returning True
if they are, False if any pair is not, and None (or the first
failing expression if failing_expression is True) if it cannot
be decided if the expressions are equivalent or not. This is, in
general, an expensive operation.

Examples
========

>>> from sympy import Matrix
>>> from sympy.abc import x
>>> A = Matrix([x*(x - 1), 0])
>>> B = Matrix([x**2 - x, 0])
>>> A == B
False
>>> A.simplify() == B.simplify()
True
>>> A.equals(B)
True
>>> A.equals(2)
False

See Also
========
sympy.core.expr.Expr.equals
shapeNFT)r
  getattrr   r_   r`   equals)r+   r,   failing_expressionrvrp   rq   anss          r-   r  RepMatrix.equalsz  s    8 ::66tyy!A499%a4j''d5GH%< _tB & " 	rQ   c                 .   U R                   (       d
  [        5       e [        U5      n[        USS9n U R                  U5      nUR                  (       a!   UR                  5       nUR                  5       $ UR                  5       u  px SU-  n	Xy-  nUR                  5       $ ! [         a    [	        S5      ef = f! [         a    [        S5      ef = f! [         a  nSU S3n[        U5      UeSnAff = f! [         a    SU S3n[        U5      ef = f)	z
Returns the inverse of the integer matrix ``M`` modulo ``m``.

Examples
========

>>> from sympy import Matrix
>>> A = Matrix(2, 2, [1, 2, 3, 4])
>>> A.inv_mod(5)
Matrix([
[3, 1],
[4, 2]])
>>> A.inv_mod(3)
Matrix([
[1, 1],
[0, 1]])

z%inv_mod: modulus m must be an integerF)	symmetricz(inv_mod: matrix entries must be integerszMatrix is not invertible (mod )Nr   )	is_squarer   r   
ValueErrorr2   r   r>   r   is_Fieldinvr   r   adj_detr   	to_Matrix)
Mmr   dMdMiexcmsgdMadjdetdetinvs
             r-   inv_modRepMatrix.inv_mod  s/   ( {{&((	Eq	A qE"	IB ::=ffh }} JE4S .C}}3  	ECDD	E  	IGHH	I . =6qc;.s3<= ! 46qc;.s334s:   B" B; C 	C8 "B8;C
C5C00C58Dc                     [         R                  " [        U5      5      nU R                  R	                  [
        5      nUR                  US9nU R                  U5      $ )u  LLL-reduced basis for the rowspace of a matrix of integers.

Performs the Lenstra–Lenstra–Lovász (LLL) basis reduction algorithm.

The implementation is provided by :class:`~DomainMatrix`. See
:meth:`~DomainMatrix.lll` for more details.

Examples
========

>>> from sympy import Matrix
>>> M = Matrix([[1, 0, 0, 0, -20160],
...             [0, 1, 0, 0, 33768],
...             [0, 0, 1, 0, 39578],
...             [0, 0, 0, 1, 47757]])
>>> M.lll()
Matrix([
[ 10, -3,  -2,  8,  -4],
[  3, -9,   8,  1, -11],
[ -3, 13,  -9, -3,  -9],
[-12, -7, -11,  9,  -1]])

See Also
========

lll_transform
sympy.polys.matrices.domainmatrix.DomainMatrix.lll
delta)r   rK   r   r$   r3   r   lllr   )r+   r'  r  basiss       r-   r(  RepMatrix.lll  sI    : huo.YY!!"%U#}}U##rQ   c                     [         R                  " [        U5      5      nU R                  R	                  [
        5      nUR                  US9u  p4U R                  U5      nU R                  U5      nXV4$ )u\  LLL-reduced basis and transformation matrix.

Performs the Lenstra–Lenstra–Lovász (LLL) basis reduction algorithm.

The implementation is provided by :class:`~DomainMatrix`. See
:meth:`~DomainMatrix.lll_transform` for more details.

Examples
========

>>> from sympy import Matrix
>>> M = Matrix([[1, 0, 0, 0, -20160],
...             [0, 1, 0, 0, 33768],
...             [0, 0, 1, 0, 39578],
...             [0, 0, 0, 1, 47757]])
>>> B, T = M.lll_transform()
>>> B
Matrix([
[ 10, -3,  -2,  8,  -4],
[  3, -9,   8,  1, -11],
[ -3, 13,  -9, -3,  -9],
[-12, -7, -11,  9,  -1]])
>>> T
Matrix([
[ 10, -3,  -2,  8],
[  3, -9,   8,  1],
[ -3, 13,  -9, -3],
[-12, -7, -11,  9]])

The transformation matrix maps the original basis to the LLL-reduced
basis:

>>> T * M == B
True

See Also
========

lll
sympy.polys.matrices.domainmatrix.DomainMatrix.lll_transform
r&  )r   rK   r   r$   r3   r   lll_transformr   )r+   r'  r  r)  	transformBr   s          r-   r,  RepMatrix.lll_transform  sd    T huo.YY!!"%++%+8MM% MM)$trQ   r1   r&   )F)g      ?)/__name__
__module____qualname____firstlineno____doc__r   __annotations__r.   r>   classmethodrO   rc   rr   rx   r~   r   r   r   r   r   r   r6   propertyr    r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r#  r(  r,  __static_attributes__r1   rQ   r-   r"   r"      sO   6 
.M^ $ $L  2   
 
3.- H H./ (j ( (K.
'4&;;D- ! ! ! !EE5
347I'R2h $D/rQ   r"   c                      ^  \ rS rSrSrSrS r\SS.S j5       r\U 4S j5       r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrU =r$ )MutableRepMatrixi+  zCMutable matrix based on DomainMatrix as the internal representationFc                 &    U R                   " U0 UD6$ r&   )_new)rL   argsr:   s      r-   __new__MutableRepMatrix.__new__6  s    xx(((rQ   Tr6   c                    USL a   [        U5      S:w  a  [        S5      eUu  pEnO U R                  " U0 UD6u  pEn[        U5      nU R	                  XEU5      nU R                  U5      $ )NF   zA'copy=False' requires a matrix be initialized as rows,cols,[list])r   r2   _handle_creation_inputsr   rr   r   )rL   r6   r=  r:   r_   r`   rm   r;   s           r-   r<  MutableRepMatrix._new9  sp    5= 4yA~ cdd$(!D	$'$?$?$P$P!D	YI,,TC||C  rQ   c                 d   > [         TU ]  U 5      nUR                  u  Ul        Ul        Xl        U$ r&   )superr>  r
  r_   r`   r$   )rL   r;   obj	__class__s      r-   r   MutableRepMatrix._fromrepI  s-    goc" YY#(
rQ   c                 T    U R                  U R                  R                  5       5      $ r&   r   r}   s    r-   r6   MutableRepMatrix.copyP  r   rQ   c                 "    U R                  5       $ r&   r@  r}   s    r-   
as_mutableMutableRepMatrix.as_mutableS  s    yy{rQ   c                     U R                  X5      nUbP  Uu  pEnU R                  U R                  U5      u  U l        nU R                  R                  R	                  XEU5        gg)a@  

Examples
========

>>> from sympy import Matrix, I, zeros, ones
>>> m = Matrix(((1, 2+I), (3, 4)))
>>> m
Matrix([
[1, 2 + I],
[3,     4]])
>>> m[1, 0] = 9
>>> m
Matrix([
[1, 2 + I],
[9,     4]])
>>> m[1, 0] = [[0, 1]]

To replace row r you assign to position r*m where m
is the number of columns:

>>> M = zeros(4)
>>> m = M.cols
>>> M[3*m] = ones(1, m)*2; M
Matrix([
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[2, 2, 2, 2]])

And to replace column c you can assign to position c:

>>> M[2] = ones(m, 1)*4; M
Matrix([
[0, 0, 4, 0],
[0, 0, 4, 0],
[0, 0, 4, 0],
[2, 2, 4, 2]])
N)_setitemrO   r$   r;   setitem)r+   r   r   r  rp   rq   s         r-   __setitem__MutableRepMatrix.__setitem__V  s[    P ]]3&>KA%#88EJDIuIIMM!!!. rQ   c                     [         R                  " U R                  S S 2S U24   U R                  S S 2US-   S 24   5      U l        U =R                  S-  sl        g Nr   )r   r   r$   r`   )r+   cols     r-   _eval_col_delMutableRepMatrix._eval_col_del  sG     ''		!DSD&(9499Qs1uvX;NO			Q	rQ   c                     [         R                  " U R                  S U2S S 24   U R                  US-   S 2S S 24   5      U l        U =R                  S-  sl        g rU  )r   r   r$   r_   )r+   rows     r-   _eval_row_delMutableRepMatrix._eval_row_del  sG     ''		$3$q&(9499SUVQY;OP			Q	rQ   c                 l    U R                  U5      nU R                  U S S 2S U24   X S S 2US 24   5      $ r&   )r<  r   )r+   rV  r,   s      r-   _eval_col_insert!MutableRepMatrix._eval_col_insert  s7    		% {{4$3$<QstV==rQ   c                 l    U R                  U5      nU R                  U S U2S S 24   X US 2S S 24   5      $ r&   )r<  r   )r+   rZ  r,   s      r-   _eval_row_insert!MutableRepMatrix._eval_row_insert  s7    		% {{4Q<ST!V==rQ   c                 ^    [        U R                  5       H  nU" XU4   U5      XU4'   M     g)a  In-place operation on col j using two-arg functor whose args are
interpreted as (self[i, j], i).

Examples
========

>>> from sympy import eye
>>> M = eye(3)
>>> M.col_op(1, lambda v, i: v + 2*M[i, 0]); M
Matrix([
[1, 2, 0],
[0, 1, 0],
[0, 0, 1]])

See Also
========
col
row_op
Nr   r_   )r+   rq   frp   s       r-   col_opMutableRepMatrix.col_op  s/    ( tyy!A41:q)DAJ "rQ   c                 h    [        SU R                  5       H  nXU4   XU4   sXU4'   XU4'   M     g)zSwap the two given columns of the matrix in-place.

Examples
========

>>> from sympy import Matrix
>>> M = Matrix([[1, 0], [1, 0]])
>>> M
Matrix([
[1, 0],
[1, 0]])
>>> M.col_swap(0, 1)
>>> M
Matrix([
[0, 1],
[0, 1]])

See Also
========

col
row_swap
r   Nrd  r+   rp   rq   ks       r-   col_swapMutableRepMatrix.col_swap  =    0 q$))$A%)Q$Zd"DAJT
 %rQ   c                 ^    [        U R                  5       H  nU" XU4   U5      XU4'   M     g)a*  In-place operation on row ``i`` using two-arg functor whose args are
interpreted as ``(self[i, j], j)``.

Examples
========

>>> from sympy import eye
>>> M = eye(3)
>>> M.row_op(1, lambda v, j: v + 2*M[0, j]); M
Matrix([
[1, 0, 0],
[2, 1, 0],
[0, 0, 1]])

See Also
========
row
zip_row_op
col_op

Nr   r`   )r+   rp   re  rq   s       r-   row_opMutableRepMatrix.row_op  s/    , tyy!A41:q)DAJ "rQ   c                 X    [        U R                  5       H  nXU4==   U-  ss'   M     g)zMultiply the given row by the given factor in-place.

Examples
========

>>> from sympy import eye
>>> M = eye(3)
>>> M.row_mult(1,7); M
Matrix([
[1, 0, 0],
[0, 7, 0],
[0, 0, 1]])

Nro  )r+   rp   factorrq   s       r-   row_multMutableRepMatrix.row_mult  s'     tyy!A1II "rQ   c                 d    [        U R                  5       H  nXU4==   X0X4   -  -  ss'   M     g)zAdd k times row s (source) to row t (target) in place.

Examples
========

>>> from sympy import eye
>>> M = eye(3)
>>> M.row_add(0, 2,3); M
Matrix([
[1, 0, 0],
[0, 1, 0],
[3, 0, 1]])
Nro  )r+   strj  rq   s        r-   row_addMutableRepMatrix.row_add  s/     tyy!A1I9$I "rQ   c                 h    [        SU R                  5       H  nXU4   XU4   sXU4'   XU4'   M     g)zSwap the two given rows of the matrix in-place.

Examples
========

>>> from sympy import Matrix
>>> M = Matrix([[0, 1], [1, 0]])
>>> M
Matrix([
[0, 1],
[1, 0]])
>>> M.row_swap(0, 1)
>>> M
Matrix([
[1, 0],
[0, 1]])

See Also
========

row
col_swap
r   Nro  ri  s       r-   row_swapMutableRepMatrix.row_swap  rm  rQ   c                 f    [        U R                  5       H  nU" XU4   XU4   5      XU4'   M     g)a0  In-place operation on row ``i`` using two-arg functor whose args are
interpreted as ``(self[i, j], self[k, j])``.

Examples
========

>>> from sympy import eye
>>> M = eye(3)
>>> M.zip_row_op(1, 0, lambda v, u: v + 2*u); M
Matrix([
[1, 0, 0],
[2, 1, 0],
[0, 0, 1]])

See Also
========
row
row_op
col_op

Nro  )r+   rp   rj  re  rq   s        r-   
zip_row_opMutableRepMatrix.zip_row_op  s5    , tyy!A41:tqDz2DAJ "rQ   c                     [        U5      (       d  [        S[        U5      -  5      eU R                  U[        U 5      " U5      5      $ )a  Copy in elements from a list.

Parameters
==========

key : slice
    The section of this matrix to replace.
value : iterable
    The iterable to copy values from.

Examples
========

>>> from sympy import eye
>>> I = eye(3)
>>> I[:2, 0] = [1, 2] # col
>>> I
Matrix([
[1, 0, 0],
[2, 1, 0],
[0, 0, 1]])
>>> I[1, :2] = [[3, 4]]
>>> I
Matrix([
[1, 0, 0],
[3, 4, 0],
[0, 0, 1]])

See Also
========

copyin_matrix
z,`value` must be an ordered iterable, not %s.)r   r2   rl   copyin_matrix)r+   r   r   s      r-   copyin_listMutableRepMatrix.copyin_list8  sB    D 5!!JTRW[XYY!!#tDz%'899rQ   c                    U R                  U5      u  p4pVUR                  nXC-
  Xe-
  pXxU	4:w  a  [        [        S5      5      e[	        UR
                  5       H.  n
[	        UR                  5       H  nX*U4   X
U-   X-   4'   M     M0     g)a  Copy in values from a matrix into the given bounds.

Parameters
==========

key : slice
    The section of this matrix to replace.
value : Matrix
    The matrix to copy values from.

Examples
========

>>> from sympy import Matrix, eye
>>> M = Matrix([[0, 1], [2, 3], [4, 5]])
>>> I = eye(3)
>>> I[:3, :2] = M
>>> I
Matrix([
[0, 1, 0],
[2, 3, 0],
[4, 5, 1]])
>>> I[0, 1] = M
>>> I
Matrix([
[0, 0, 1],
[2, 2, 3],
[4, 4, 5]])

See Also
========

copyin_list
zXThe Matrix `value` doesn't have the same dimensions as the in sub-Matrix given by `key`.N)
key2boundsr
  r   r   r   r_   r`   )r+   r   r   rlorhiclochir
  drdcrp   rq   s               r-   r  MutableRepMatrix.copyin_matrix^  s    F "__S1#CIBHZ )O P Q Q uzz"A5::&).!tWag%& ' #rQ   c           	      ^   [        U5      nU(       d+  [        R                  " U R                  [        5      U l        g[        U R                  5       Vs0 s H,  o"[        R                  [        U R                  5      U5      _M.     nn[        X0R                  [        5      U l        gs  snf )a  Fill self with the given value.

Notes
=====

Unless many values are going to be deleted (i.e. set to zero)
this will create a matrix that is slower than a dense matrix in
operations.

Examples
========

>>> from sympy import SparseMatrix
>>> M = SparseMatrix.zeros(3); M
Matrix([
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
>>> M.fill(1); M
Matrix([
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]])

See Also
========

zeros
ones
N)r   r   r   r
  r   r$   r   r_   rg   fromkeysr`   )r+   r   rp   rn   s       r-   fillMutableRepMatrix.fill  sy    > $**4::u=DIOTUYU^U^O_`O_!t}}U499-=uEEO_L`$\::uEDI as   3B*)r$   )r0  r1  r2  r3  r4  is_zeror>  r6  r<  r   r6   rM  rR  rW  r[  r^  ra  rf  rk  rp  rt  ry  r|  r  r  r  r  r8  __classcell__)rH  s   @r-   r:  r:  +  s    M G) " ! !  /,/\>>*.<6*4 $%$<632$:L-5^$F $FrQ   r:  c           	         [        U[        5      (       a3  Uu  p# U R                  R                  [	        U5      [	        U5      5      $ U R                  u  pVXV-  (       d  / U   $ U R                  R&                  nUR(                  n[        U[        5      n	U	(       a6  [        XV-  5      U    V
s/ s H  oR*                  " [-        X5      6 PM     nn
O#UR*                  " [-        [	        U5      U5      6 /nU[.        :w  a#  UR0                  nU Vs/ s H
  o" U5      PM     nnU	(       a  U$ US   $ ! [
        [        4 Ga8    [        U[        5      (       a  UR                  (       a&  [        U[        5      (       ae  UR                  (       dT  US:  SL d0  X0R                  S   :  SL d  US:  SL d  X R                  S   :  SL a  [        S5      eSSKJn  U" XU5      s $ [        U[        5      (       a  [        U R                  5      U   nO[!        U5      (       a  OU/n[        U[        5      (       a  [        U R"                  5      U   nO[!        U5      (       a  OU/nU R%                  X#5      s $ f = fs  sn
f s  snf )a  Return portion of self defined by key. If the key involves a slice
then a list will be returned (if key is a single slice) or a matrix
(if key was a tuple involving a slice).

Examples
========

>>> from sympy import Matrix, I
>>> m = Matrix([
... [1, 2 + I],
... [3, 4    ]])

If the key is a tuple that does not involve a slice then that element
is returned:

>>> m[1, 0]
3

When a tuple key involves a slice, a matrix is returned. Here, the
first column is selected (all rows, column 0):

>>> m[:, 0]
Matrix([
[1],
[3]])

If the slice is not a tuple then it selects from the underlying
list of elements that are arranged in row order and a list is
returned if a slice is involved:

>>> m[0]
1
>>> m[::2]
[1, 3]
r   Tr   zindex out of boundary)MatrixElement)r'   tupler$   getitem_sympyindex_r2   
IndexErrorr   	is_numberr
  r  "sympy.matrices.expressions.matexprr  slicer   r_   r   r`   r   r;   r4   getitemri   r   r{   )r+   r   rp   rq   r  r_   r`   r;   r4   is_slicero   rv   r{   vals                 r-   r   r     s   H #u	&99**6!9fQi@@2 ZZ
 {c7Niimmc5)=B4;=OPS=TU=Tkk6!?3=TFUFkk6&+t#<=>FU?H/56vhsmvF6M!9] :& 	&1d##AKKZ4=P=PYZYdYdUtO!zz!}*<)EUtO!zz!}*<)E$%<==L$Ta00!U##$))$Q'QC!U##$))$Q'QC<<%%)	&F V 7s%   -D2 0!I>J2B/I;#BI;:I;N)2collectionsr   operatorr   r  sympy.core.exprr   sympy.core.kindr   r   r   sympy.core.numbersr	   r
   sympy.core.sympifyr   r   sympy.core.singletonr   sympy.polys.domainsr   r   r   r   sympy.polys.matricesr   sympy.polys.matrices.exceptionsr   sympy.polys.polyerrorsr   r   sympy.utilities.exceptionsr   sympy.utilities.iterablesr   sympy.utilities.miscr   r   
exceptionsr   r   r   
matrixbaser   r   r   r    r"   r:  r   r1   rQ   r-   <module>r     sg    # $   ; ; 0 5 " 1 1 - F @ @ 1 3 R R + Q
 QhFFy FFRVrQ   