+
    ‹°³jQ9  ã                   óÄ   € ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^RI
Ht ^RIHtHt ^RIHt ^R	IHtHtHtHt ^R
IHtHt  ! R R]4      t ! R R]]4      t]tR# )é    )ÚCallable)ÚDict)Úsympy_deprecation_warning©Úis_sequence)Úas_int)Ú
MatrixBase)ÚMutableRepMatrixÚ	RepMatrix)Ú_iszero)Ú_liupcÚ _row_structure_symbolic_choleskyÚ_cholesky_sparseÚ_LDLdecomposition_sparse)Ú_lower_triangular_solve_sparseÚ_upper_triangular_solve_sparsec                   ó¸  a a€ ] tR t^t oRt]V 3R l4       t]R 4       tR t	R t
R tR tR tR	 tR
 tR tRR ltRR lt]! ]RRR4      t]! ]RRR4      tR tR tRR ltRR ltR tR t]P                  ]n        ]P                  ]n        ]P                  ]n        ]P                  ]n        ]P                  ]n        ]P                  ]n        RtVt V ;t!# )ÚSparseRepMatrixa  
A sparse matrix (a matrix with a large number of zero elements).

Examples
========

>>> from sympy import SparseMatrix, ones
>>> SparseMatrix(2, 2, range(4))
Matrix([
[0, 1],
[2, 3]])
>>> SparseMatrix(2, 2, {(1, 1): 2})
Matrix([
[0, 0],
[0, 2]])

A SparseMatrix can be instantiated from a ragged list of lists:

>>> SparseMatrix([[1, 2, 3], [1, 2], [1]])
Matrix([
[1, 2, 3],
[1, 2, 0],
[1, 0, 0]])

For safety, one may include the expected size and then an error
will be raised if the indices of any element are out of range or
(for a flat list) if the total number of elements does not match
the expected shape:

>>> SparseMatrix(2, 2, [1, 2])
Traceback (most recent call last):
...
ValueError: List length (2) != rows*columns (4)

Here, an error is not raised because the list is not flat and no
element is out of range:

>>> SparseMatrix(2, 2, [[1, 2]])
Matrix([
[1, 2],
[0, 0]])

But adding another element to the first (and only) row will cause
an error to be raised:

>>> SparseMatrix(2, 2, [[1, 2, 3]])
Traceback (most recent call last):
...
ValueError: The location (0, 2) is out of designated range: (1, 1)

To autosize the matrix, pass None for rows:

>>> SparseMatrix(None, [[1, 2, 3]])
Matrix([[1, 2, 3]])
>>> SparseMatrix(None, {(1, 1): 1, (3, 3): 3})
Matrix([
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 3]])

Values that are themselves a Matrix are automatically expanded:

>>> SparseMatrix(4, 4, {(1, 1): ones(2)})
Matrix([
[0, 0, 0, 0],
[0, 1, 1, 0],
[0, 1, 1, 0],
[0, 0, 0, 0]])

A ValueError is raised if the expanding matrix tries to overwrite
a different element already present:

>>> SparseMatrix(3, 3, {(0, 0): ones(2), (1, 1): 2})
Traceback (most recent call last):
...
ValueError: collision at (1, 1)

See Also
========
DenseMatrix
MutableSparseMatrix
ImmutableSparseMatrix
c                óŒ  <a€ \        V4      ^8X  d_   \        V^ ,          \        4      '       dB   V^ ,          P                  pV^ ,          P                  pV^ ,          P                  4       oW4S3# / o\        V4      ^8X  d   V^ ,          f   RRV^,          .p\        V4      ^8X  EdN   VR,          w  rVYVu;J d   f   M MR;r4M6RWV39   d   \        R4      h\        V^ ,          4      \        V^,          4      rC\        V^,          \        4      '       dÁ   V^,          pRW439   d   \        RP                  W44      4      h\        V4       Uu. uF  q€P                  V4      NK  	  p	p\        V4       U
u. uF  q P                  V
4      NK  	  pp
V	 F;  pV F2  p
V P                  V! WŠ4      4      pWÀP                  8w  g   K,  VSWŠ3&   K4  	  K=  	  W4S3# \        V^,          \        \        34      '       Ed   V3R lpV^,          P                  4        Fç  w  w  rVp\        V\        4      '       dC   VP                  4       P                  4        F  w  w  rŠpV! WX,           Wj,           V4       K   	  K`  \        V\         \"        34      '       dC   V P$                  ! V3/ VB w   poS F#  w  rŠV! WX,           Wj,           SWŠ3,          4       K%  	  K¾  V P                  V4      pV! WVV P                  V4      4       Ké  	  EM-\'        V^,          4      '       Ed   \(        ;QJ d#    R V^,           4       F  '       g   K   RM	  RM! R V^,           4       4      '       * pV'       g    V P$                  ! V^,          3/ VB w   poM¦V^,          p\        V4      W4,          8w  d%   \        R	P                  \        V4      W44      4      h\        V4       FT  p\        V4       FB  p
VW„,          V
,           ,          pV P                  V4      pWÀP                  8w  g   K<  VSWŠ3&   KD  	  KV  	  VfX   SP+                  4       pV'       d   \-        R
 V 4       4      ^,           M^ pV'       d   \-        R V 4       4      ^,           M^ pMdSP+                  4        FP  w  rŠV'       d   Wƒ8¼  g   V
'       g   K  W¤8¼  g   K%  \        RP                  WŠ3^ V^,
          ^ V^,
          4      4      h	  W4S3# \        V4      ^8X  dÎ   \        V^ ,          \         \"        34      '       d«   V^ ,          p^ p\/        V4       Fu  w  pp\        V\         \"        34      '       g   V.p\/        V4       F,  w  r¯WðP                  8w  g   K  V P                  V4      SWŠ3&   K.  	  \-        V\        V4      4      pKw  	  V'       d   \        V4      M^ pTpW4S3# \0        SV `H  ! V!  w  r4p\        V4       FC  p\        V4       F1  p
VWH,          V
,           ,          pWÀP                  8w  g   K+  VSWŠ3&   K3  	  KE  	  W4S3# u upi u up
i )é   N:Né   Nz*Pass rows=None and no cols for autosizing.z2{} and {} must be integers for this specification.c           	      ó    <€ V'       dE   W3S9   d5   VSW3,          8w  d&   \        R P                  W3VSW3,          4      4      hVSW3&   R# R# )z)There is a collision at {} for {} and {}.N)Ú
ValueErrorÚformat)ÚiÚjÚvÚsmats   &&&€ÚV/home/luca/screen-checking/.venv/lib/python3.14/site-packages/sympy/matrices/sparse.pyÚupdateÚ7SparseRepMatrix._handle_creation_inputs.<locals>.update–   sS   ø€ çØ˜6 Tœ>¨a°4¸¸µ:¬oÜ",Ø Kß!'¡¨¨°°4¸¸µ:Ó!>ó#ð ð &'˜˜Q˜T›
ñ ó    c              3   ó8   "  € T F  p\        V4      x € K  	  R # 5i©Nr   )Ú.0r   s   & r   Ú	<genexpr>Ú:SparseRepMatrix._handle_creation_inputs.<locals>.<genexpr>®   s   é € Ð?±w°!œ{¨1Ÿ~˜~³wùs   ‚TFzMThe length of the flat list ({}) does not match the specified size ({} * {}).c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir$   © )r%   ÚrÚ_s   &  r   r&   r'   Ä   ó   é € Ð.©¡ �1«ùó   ‚c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir$   r)   )r%   r+   Úcs   &  r   r&   r'   Å   r,   r-   z?The location {} is out of the designated range[{}, {}]x[{}, {}])ÚlenÚ
isinstancer	   ÚrowsÚcolsÚtodokr   r   r   r   ÚrangeÚ_sympifyÚzeroÚdictr   ÚitemsÚlistÚtupleÚ_handle_creation_inputsr   ÚanyÚkeysÚmaxÚ	enumerateÚsuper)ÚclsÚargsÚkwargsr2   r3   r*   r/   Úopr   Úrow_indicesr   Úcol_indicesÚvaluer    r   Úvvr+   ÚflatÚ	flat_listr>   ÚrowÚmatr   Ú	__class__s   &*,                   @€r   r<   Ú'SparseRepMatrix._handle_creation_inputsk   s+  ù€ äˆt‹9˜Œ>œj¨¨a­´*×=Ò=Ø˜•7—<‘<ˆDØ˜•7—<‘<ˆDØ˜•7—=‘=“?ˆDØ˜tÐ#Ð#àˆäˆt‹9˜Œ>˜d 1�gšoØ˜$  Q¥Ð(ˆDäˆt‹9˜�>Ø˜•8‰DˆAØ�~‹~Ø"Ð"��tØ˜!˜”Ü Ø@óBð Bô $ D¨¥G›_¬f°T¸!µW«o�dä˜$˜q�'¤8×,Ò,Ø˜!•W�à˜D˜<Ô'Ü$ð)ß)/©°Ó);ó=ð =ô 9>¸d¼ÓD¹°1Ÿ|™|¨Až¹�ÐDÜ8=¸d¼ÓD¹°1Ÿ|™|¨Až¹�ÐDã$�AÛ(˜Ø #§¡©R°«XÓ 6˜Ø §H¡HÖ,Ø).˜D  ›Jó )ñ %ð  4Ð'Ð'ä˜D �G¤d¬D \×2Ó2õ'ð "& a¥§¡¦‘I‘F�Q˜AÜ! !¤Z×0Ò0Ø*+¯'©'«)¯/©/Ö*;™J™F˜Q BÙ" 1¥5¨!­%°Ö4ó +<ä# A¬¬e }×5Ò5Ø%(×%@Ò%@ÀÑ%MÀfÑ%M™
˜˜1˜dÛ$(™D˜AÙ" 1¥5¨!­%°°a°dµÖ<ó %)ð  ŸL™L¨›O˜Ù˜q S§\¡\°!£_Ö5ó "1ô ˜T !�W×%Ó%ß›3Ñ?°t¸A¶wÓ?Ÿ3Ÿ3š3Ñ?°t¸A¶wÓ?Ó?Ô?�ßà×3Ò3°D¸µGÑF¸vÑFñ �A�q™$ð !% Q¥�IÜ˜9“~¨­Ô4Ü(ðBç#™V¤C¨	£N°DÓ?óð ô # 4ž[˜Ü!& t¦˜AØ$-¨a­f°q­jÕ$9˜EØ$'§L¡L°Ó$7˜EØ$¯©Ö0Ø-2  Q T£
ó	 "-ñ )ð Š|Ø—y‘y“{�ß6:”sÑ.©Ó.Ó.°Ö2À�ß6:”sÑ.©Ó.Ó.°Ö2À‘ð !ŸI™IžK‘D�Aß˜QœY¯!©!°¶	Ü(ð0ç#™V Q F¨A¨t°a­x¸¸DÀ1½HÓEóð ñ (ð ˜tÐ#Ð#ä�‹Y˜!Œ^¤
¨4°­7´T¼5°M× BÒ Bà�Q•ˆAØˆAÜ# Až,‘��3Ü! #¬¬e }×5Ò5Ø˜%�CÜ& sž^‘E�AØŸX™X–~Ø%(§\¡\°"Ó%5˜˜Q˜T›
ñ ,ô ˜œ3˜s›8Ó$’ñ '÷ ”3�q”6 AˆDØˆDØ˜tÐ#Ð#ô $™gÒ=¸tÑD‰OˆD˜Ü˜4–[�Ü˜tž�AØ ¥¨¥
�O�EØ§¡Ö(Ø%*˜˜Q˜T›
ó %ñ !ð ˜tÐ#Ð#ùòA EùÚDs   ÅX<Å:Yc                ó>   € \        R RRR7       V P                  4       # )z�
            The private _smat attribute of SparseMatrix is deprecated. Use the
            .todok() method instead.
            z1.9z$deprecated-private-matrix-attributes)Údeprecated_since_versionÚactive_deprecations_target)r   r4   ©Úselfs   &r   Ú_smatÚSparseRepMatrix._smatì   s'   € ô 	"ðð &+Ø'Mõ	
ð �z‰z‹|Ðr"   c                ó’   € V P                  VP                  R R4      VP                  R\        4      VP                  RR4      R7      # )ÚmethodÚLDLÚ
iszerofuncÚtry_block_diagF)rX   rZ   r[   )ÚinvÚgetr   )rT   rD   s   &,r   Ú_eval_inverseÚSparseRepMatrix._eval_inverseú   sD   € Ø�x‰x˜vŸz™z¨(°EÓ:Ø#)§:¡:¨l¼GÓ#DØ'-§z¡zÐ2BÀEÓ'Jð ó Lð 	Lr"   c                ó  € \        V4      '       g   \        R4      h/ pV P                  4       P                  4        F  w  r4V! V4      pV^ 8w  g   K  WRV&   K  	  V P	                  V P
                  V P                  V4      # )zðApply a function to each element of the matrix.

Examples
========

>>> from sympy import SparseMatrix
>>> m = SparseMatrix(2, 2, lambda i, j: i*2+j)
>>> m
Matrix([
[0, 1],
[2, 3]])
>>> m.applyfunc(lambda i: 2*i)
Matrix([
[0, 2],
[4, 6]])

z`f` must be callable.)ÚcallableÚ	TypeErrorr4   r9   Ú_newr2   r3   )rT   ÚfÚdokÚkr   Úfvs   &&    r   Ú	applyfuncÚSparseRepMatrix.applyfuncÿ   so   € ô$ ˜�{Š{ÜÐ3Ó4Ð4ð
 ˆØ—J‘J“L×&Ñ&Ö(‰DˆAÙ�1“ˆBØ�QŽwØ�A“ñ )ð
 �y‰y˜Ÿ™ D§I¡I¨sÓ3Ð3r"   c                ó   € ^RI Hp V! V 4      # )z,Returns an Immutable version of this Matrix.)ÚImmutableSparseMatrix)Ú	immutablerk   )rT   rk   s   & r   Úas_immutableÚSparseRepMatrix.as_immutable  s   € å4Ù$ TÓ*Ð*r"   c                ó   € \        V 4      # )zëReturns a mutable version of this matrix.

Examples
========

>>> from sympy import ImmutableMatrix
>>> X = ImmutableMatrix([[1, 2], [3, 4]])
>>> Y = X.as_mutable()
>>> Y[1, 1] = 5 # Can set values in Y
>>> Y
Matrix([
[1, 2],
[3, 5]])
)ÚMutableSparseMatrixrS   s   &r   Ú
as_mutableÚSparseRepMatrix.as_mutable$  s   € ô # 4Ó(Ð(r"   c                ó®   € \        V P                  4       P                  4       R R7       Uu. uF  p\        WV,          3,           4      NK  	  up# u upi )a3  Returns a column-sorted list of non-zero elements of the matrix.

Examples
========

>>> from sympy import SparseMatrix
>>> a=SparseMatrix(((1, 2), (3, 4)))
>>> a
Matrix([
[1, 2],
[3, 4]])
>>> a.CL
[(0, 0, 1), (1, 0, 3), (0, 1, 2), (1, 1, 4)]

See Also
========

sympy.matrices.sparse.SparseMatrix.row_list
c                 ó*   € \        \        V 4      4      # r$   )r:   Úreversed)rf   s   &r   Ú<lambda>Ú*SparseRepMatrix.col_list.<locals>.<lambda>I  s   € ÔY]Ô^fÐghÓ^iÔYjr"   ©Úkey)Úsortedr4   r>   r;   ©rT   rf   s   & r   Úcol_listÚSparseRepMatrix.col_list5  sB   € ô( 06°d·j±j³l×6GÑ6GÓ6IÑOjÕ/kÓlÑ/k¨!”�a �7˜*•nÖ%Ñ/kÑlÐlùÒls   ­"Ac                ó4   € \        V P                  4       4      # )z2Returns the number of non-zero elements in Matrix.)r0   r4   rS   s   &r   ÚnnzÚSparseRepMatrix.nnzK  s   € ä�4—:‘:“<Ó Ð r"   c                ó´   € \        V P                  4       P                  4       \        R7       Uu. uF  p\	        WV,          3,           4      NK  	  up# u upi )a2  Returns a row-sorted list of non-zero elements of the matrix.

Examples
========

>>> from sympy import SparseMatrix
>>> a = SparseMatrix(((1, 2), (3, 4)))
>>> a
Matrix([
[1, 2],
[3, 4]])
>>> a.RL
[(0, 0, 1), (0, 1, 2), (1, 0, 3), (1, 1, 4)]

See Also
========

sympy.matrices.sparse.SparseMatrix.col_list
rx   )rz   r4   r>   r:   r;   r{   s   & r   Úrow_listÚSparseRepMatrix.row_listO  sL   € ô* �4—:‘:“<×$Ñ$Ó&¬DÕ1ó3Ù1ð +,”�a �7˜*•nÖ%Ù1ñ3ð 	3ùò 3s   °"Ac                ó   € W,          # )z"Scalar element-wise multiplicationr)   )rT   Úscalars   &&r   Úscalar_multiplyÚSparseRepMatrix.scalar_multiplyf  s
   € à�}Ðr"   c                óf   € V P                   pW0,          P                  VR7      V,          V,          # )a´  Return the least-square fit to the data.

By default the cholesky_solve routine is used (method='CH'); other
methods of matrix inversion can be used. To find out which are
available, see the docstring of the .inv() method.

Examples
========

>>> from sympy import SparseMatrix, Matrix, ones
>>> A = Matrix([1, 2, 3])
>>> B = Matrix([2, 3, 4])
>>> S = SparseMatrix(A.row_join(B))
>>> S
Matrix([
[1, 2],
[2, 3],
[3, 4]])

If each line of S represent coefficients of Ax + By
and x and y are [2, 3] then S*xy is:

>>> r = S*Matrix([2, 3]); r
Matrix([
[ 8],
[13],
[18]])

But let's add 1 to the middle value and then solve for the
least-squares value of xy:

>>> xy = S.solve_least_squares(Matrix([8, 14, 18])); xy
Matrix([
[ 5/3],
[10/3]])

The error is given by S*xy - r:

>>> S*xy - r
Matrix([
[1/3],
[1/3],
[1/3]])
>>> _.norm().n(2)
0.58

If a different xy is used, the norm will be higher:

>>> xy += ones(2, 1)/10
>>> (S*xy - r).norm().n(2)
1.5

©rX   )ÚTr\   )rT   ÚrhsrX   Úts   &&& r   Úsolve_least_squaresÚ#SparseRepMatrix.solve_least_squaresj  s+   € ðl �F‰FˆØ•�|‰| 6ˆ|Ó*¨1Õ,¨SÕ0Ð0r"   c                ó  € V P                   '       gO   V P                  V P                  8  d   \        R4      hV P                  V P                  8”  d   \        R4      hR# V P	                  VR7      P                  V4      # )z†Return solution to self*soln = rhs using given inversion method.

For a list of possible inversion methods, see the .inv() docstring.
zUnder-determined system.z]For over-determined system, M, having more rows than columns, try M.solve_least_squares(rhs).r‰   N)Ú	is_squarer2   r3   r   r\   Úmultiply)rT   r‹   rX   s   &&&r   ÚsolveÚSparseRepMatrix.solve£  sq   € ð
 �~�~ˆ~Ø�y‰y˜4Ÿ9™9Ô$Ü Ð!;Ó<Ð<Ø—‘˜TŸY™YÔ&Ü ð "Nó Oð Oñ 'ð —8‘8 6�8Ó*×3Ñ3°CÓ8Ð8r"   NzAlternate faster representationc                ó   € \        V 4      # r$   )r   rS   s   &r   ÚliupcÚSparseRepMatrix.liupc´  s   € Ü�d‹|Ðr"   c                ó   € \        V 4      # r$   )r   rS   s   &r   Úrow_structure_symbolic_choleskyÚ/SparseRepMatrix.row_structure_symbolic_cholesky·  s   € Ü/°Ó5Ð5r"   c                ó   € \        WR 7      # ©)Ú	hermitian)r   ©rT   rœ   s   &&r   ÚcholeskyÚSparseRepMatrix.choleskyº  s   € Ü Ô:Ð:r"   c                ó   € \        WR 7      # r›   )r   r�   s   &&r   ÚLDLdecompositionÚ SparseRepMatrix.LDLdecomposition½  s   € Ü'¨ÔBÐBr"   c                ó   € \        W4      # r$   )r   ©rT   r‹   s   &&r   Úlower_triangular_solveÚ&SparseRepMatrix.lower_triangular_solveÀ  ó   € Ü-¨dÓ8Ð8r"   c                ó   € \        W4      # r$   )r   r¤   s   &&r   Úupper_triangular_solveÚ&SparseRepMatrix.upper_triangular_solveÃ  r§   r"   r)   )rY   )T)"Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úclassmethodr<   ÚpropertyrU   r^   rh   rm   rq   r|   r   r‚   r†   r�   r’   ÚRLÚCLr•   r˜   rž   r¡   r¥   r©   r   r   r   r   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)rN   Ú__classdict__s   @@r   r   r      s
  ù‡ € ñSðj ô~$ó ð~$ð@ ñó ðòLò
4ò@+ò
)ò"mò,!ò3ò.ô71ôr9ñ 
�(˜D $Ð(IÓ	J€BÙ	�(˜D $Ð(IÓ	J€Bòò6ô;ôCò9ò9ð /5¯n©n€E„MØ.N×.VÑ.VÐ#Ô+Ø.>×.FÑ.F€HÔØ.F×.NÑ.NÐÔØ.D×.LÑ.LÐÔ"Ø.D×.LÑ.LÐ×"Ô"r"   r   c                   ó0   a € ] tR tRt o ]R 4       tRtV tR# )rp   iÎ  c                ór   € V P                   ! V/ VB w  r4pV P                  W4V4      pV P                  V4      # r$   )r<   Ú_smat_to_DomainMatrixÚ_fromrep)rB   rC   rD   r2   r3   r   Úreps   &*,    r   rc   ÚMutableSparseMatrix._newÐ  s=   € à×6Ò6¸ÐGÀÑGÑˆ�Dà×'Ñ'¨°DÓ9ˆà�|‰|˜CÓ Ð r"   r)   N)r«   r¬   r­   r®   r°   rc   r´   rµ   )r·   s   @r   rp   rp   Î  s   ø‡ € àñ!ó ö!r"   rp   N)Úcollections.abcr   Úsympy.core.containersr   Úsympy.utilities.exceptionsr   Úsympy.utilities.iterablesr   Úsympy.utilities.miscr   Ú
matrixbaser	   Ú	repmatrixr
   r   Ú	utilitiesr   Údecompositionsr   r   r   r   Úsolversr   r   r   rp   ÚSparseMatrixr)   r"   r   Ú<module>rÉ      sT   ðÝ $å &Ý @Ý 1Ý 'å "ß 2å ÷ó ÷DôvM�iô vMôr!˜/Ð+;ô !ð #‚r"   