Ë
    £èhÊj  ã                  ób  — U d dl mZ d dlmZmZmZmZmZmZm	Z	 d dl
mZ d dlZd dlmZ d dlmZ d dlZd dlZd dlZd dlmZ d dlmZ g d¢Zd(d	„Zeee      Zd
ed<   eeedf      Zd
ed<   eeef   Z d
ed<   ejB                  ejD                     Z!d
ed<   d)d„Z# ed¬«      d*d„«       Z$ G d„ d«      Z% G d„ dejL                  «      Z'd+d,d„Z(d-d„Z)d.d„Z*d/d„Z+ G d„ de'«      Z,d0d„Z-	 	 	 	 	 	 d.d„Z.	 	 	 	 	 	 	 	 	 	 d1d „Z/d2d3d!„Z0d2d4d"„Z1d5d#„Z2 G d$„ d%e'«      Z3d6d&„Z4	 	 	 	 	 	 	 	 	 	 	 	 	 	 d7d'„Z5y)8é    )Úannotations)ÚIterableÚTupleÚListÚSequenceÚAnyÚcastÚOptional)Ú	TypeAliasN)Ú	lru_cache)Úrepeat)Ú	USE_C_EXT)ÚMatrixÚSolverÚnumpy_vector_solverÚnumpy_matrix_solverÚNumpySolverÚtridiagonal_vector_solverÚtridiagonal_matrix_solverÚdetect_banded_matrixÚcompact_banded_matrixÚBandedMatrixLUÚbanded_matrixÚquadratic_equationÚcubic_equationÚbinomial_coefficientc               '  ó@   K  — t        | Ž D ]  }t        |«      –— Œ y ­w©N)ÚzipÚlist)ÚargsÚes     ú1lib/python3.12/site-packages/ezdxf/math/linalg.pyÚzip_to_listr$   ,   s   è ø€ Ü�$‹ZˆÜ�1‹g‹ñ ùs   ‚r   Ú
MatrixData.ÚFrozenMatrixDataÚShapeÚNDArrayc           
     ó¢   — t        | t        «      r| j                  } | D ��cg c]  }|D �cg c]  }t        |«      ‘Œ c}‘Œ c}}S c c}w c c}}w r   ©Ú
isinstancer   ÚmatrixÚfloat)ÚAÚrowÚvs      r#   Úcopy_float_matrixr1   7   sC   € Ü�!”VÔØ�H‰HˆÙ/0Ô1©q¨™sÓ#™s˜!ŒU�1�X˜sÓ#¨qÒ1Ð1ùÒ#ùÓ1s   ¢	A«A½AÁAé€   )Úmaxsizec                óÈ   — || kD  rt        d«      S t        j                  | «      }t        j                  |«      }t        j                  | |z
  «      }t        |||z  z  «      S )a	  Computes the binomial coefficient (denoted by `k choose i`).

    Please see the following website for details:
    http://mathworld.wolfram.com/BinomialCoefficient.html

    Args:
        k: size of the set of distinct elements
        i: size of the subsets

    r   )r-   ÚmathÚ	factorial)ÚkÚiÚk_factÚi_factÚk_i_facts        r#   r   r   =   sW   € ð 	ˆ1‚uÜ�Q‹xˆä—.‘. Ó#€FÜ—.‘. Ó#€FÜ—N‘N 1 q¡5Ó)€HÜ�˜8 fÑ,Ñ-Ó.Ð.ó    c                  ób  — e Zd ZdZdZ	 	 	 d#	 	 	 	 	 d$d„Zd%d„Zd&d„Zd'd„Zd'd„Z	e
d(d	„«       Zed)d
„«       Zed)d„«       Zed*d„«       Zd+d„Zd+d„Zd+d„Zd,d„Zd,d„Zd-d.d„Zd-d.d„Zd/d.d„Zed0d„«       Zd1d„Zd1d„Zd2d„Zd3d„Zd4d„Zd5d„Zd5d„Z d6d„Z!e!Z"d6d„Z#e#Z$d6d„Z%e%Z&d2d „Z'd2d!„Z(d7d"„Z)y)8r   a´  Basic matrix implementation based :class:`numpy.ndarray`. Matrix data is stored in
    row major order, this means in a list of rows, where each row is a list of floats.

    Initialization:

        - Matrix(shape=(rows, cols)) ... new matrix filled with zeros
        - Matrix(matrix[, shape=(rows, cols)]) ... from copy of matrix and optional reshape
        - Matrix([[row_0], [row_1], ..., [row_n]]) ... from Iterable[Iterable[float]]
        - Matrix([a1, a2, ..., an], shape=(rows, cols)) ... from Iterable[float] and shape

    .. versionchanged:: 1.2
        Implementation based on :class:`numpy.ndarray`.

    Attributes:
        matrix: matrix data as :class:`numpy.ndarray`

    )r,   Úabs_tolNc                óè  — d| _         t        j                  dt        j                  ¬«      | _        |�+t        j                  |t        j                  ¬«      | _        y |€|�t        j
                  |«      | _        y y t        |t        «      r=|€|j                  }|j                  j                  |«      j                  «       | _        y t        |«      }	 t        j                  |D �cg c]  }t        |«      ‘Œ c}t        j                  ¬«      | _        y c c}w # t        $ rI |�Dt        j                  t        |«      t        j                  ¬«      j                  |«      | _        Y y Y y w xY w)Nçê-�™—q=© ©Údtype)r>   ÚnpÚarrayÚfloat64r,   Úzerosr+   r   ÚshapeÚreshapeÚcopyr    Ú	TypeError)ÚselfÚitemsrH   r,   r/   s        r#   Ú__init__zMatrix.__init__i   s  € ð $ˆŒÜ!Ÿx™x¨´"·*±*Ô=ˆŒØÐÜŸ(™( 6´·±Ô<ˆDŒKØàˆ=ØÐ Ü Ÿh™h u›o�•àÜ˜œvÔ&Øˆ}ØŸ™�ØŸ,™,×.Ñ.¨uÓ5×:Ñ:Ó<ˆD�Kä˜“KˆEðYÜ Ÿh™h¹UÓ'C¹U°c¬¨S­	¸UÑ'CÌ2Ï:É:ÔV�•ùÒ'CøÜò YØÐ$Ü"$§(¡(¬4°«;¼b¿j¹jÔ"I×"QÑ"QÐRWÓ"X�D–Kñ %ðYús%   ÃD Ã+DÃ=D ÄD ÄAE1Å0E1c                ó@   — t        j                  | j                  «      S r   )rD   Úravelr,   ©rL   s    r#   Ú__iter__zMatrix.__iter__†   s   € Ü�x‰x˜Ÿ™Ó$Ð$r<   c                óp   — t        | j                  j                  «       ¬«      }| j                  |_        |S )N©r,   )r   r,   rJ   r>   ©rL   Úms     r#   Ú__copy__zMatrix.__copy__‰   s)   € Ü˜$Ÿ+™+×*Ñ*Ó,Ô-ˆØ—L‘LˆŒ	Øˆr<   c                ó,   — t        | j                  «      S r   )Ústrr,   rQ   s    r#   Ú__str__zMatrix.__str__Ž   s   € Ü�4—;‘;ÓÐr<   c                óH   — dt        j                  | j                  «      › d�S )NzMatrix(Ú))ÚreprlibÚreprr,   rQ   s    r#   Ú__repr__zMatrix.__repr__‘   s   € ØœŸ™ d§k¡kÓ2Ð3°1Ð5Ð5r<   c                ó�   — t        t        j                  t        | «      t        j                  ¬«      j                  |«      ¬«      S )z[Returns a new matrix for iterable `items` in the configuration of
        `shape`.
        rB   rT   )r   rD   rE   r    rF   rI   )rM   rH   s     r#   rI   zMatrix.reshape”   s-   € ô
 œRŸX™X¤d¨5£k¼¿¹ÔD×LÑLÈUÓSÔTÐTr<   c                ó4   — | j                   j                  d   S ©zCount of matrix rows.r   ©r,   rH   rQ   s    r#   ÚnrowszMatrix.nrows›   ó   € ð �{‰{× Ñ  Ñ#Ð#r<   c                ó4   — | j                   j                  d   S )zCount of matrix columns.é   rc   rQ   s    r#   ÚncolszMatrix.ncols    re   r<   c                ó.   — | j                   j                  S )z9Shape of matrix as (n, m) tuple for n rows and m columns.rc   rQ   s    r#   rH   zMatrix.shape¥   s   € ð �{‰{× Ñ Ð r<   c                ó2   — t        | j                  |   «      S )z&Returns row `index` as list of floats.©r    r,   ©rL   Úindexs     r#   r/   z
Matrix.rowª   s   € ä�D—K‘K Ñ&Ó'Ð'r<   c                ó:   — t        | j                  dd…|f   «      S )z(Return column `index` as list of floats.Nrk   rl   s     r#   Úcolz
Matrix.col®   s   € ä�D—K‘K¢ 5 Ñ)Ó*Ð*r<   c                óJ   — t        | j                  j                  |«      «      S )aŒ  Returns diagonal `index` as list of floats.

        An `index` of 0 specifies the main diagonal, negative values
        specifies diagonals below the main diagonal and positive values
        specifies diagonals above the main diagonal.

        e.g. given a 4x4 matrix:

        - index 0 is [00, 11, 22, 33],
        - index -1 is [10, 21, 32] and
        - index +1 is [01, 12, 23]

        )r    r,   Údiagonalrl   s     r#   ÚdiagzMatrix.diag²   s   € ô �D—K‘K×(Ñ(¨Ó/Ó0Ð0r<   c                ó:   — t        d„ | j                  D «       «      S )zReturn a list of all rows.c              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr   )r    )Ú.0Úrs     r#   Ú	<genexpr>zMatrix.rows.<locals>.<genexpr>Ä   s   è ø€ Ð1¡[ ”D˜—G¡[ùs   ‚rk   rQ   s    r#   ÚrowszMatrix.rowsÂ   s   € äÑ1 T§[¢[Ó1Ó1Ð1r<   c                ó‚   — t        | j                  «      D �cg c]  }t        | j                  |«      «      ‘Œ c}S c c}w )zReturn a list of all columns.)Úrangerh   r    ro   )rL   r8   s     r#   ÚcolszMatrix.colsÆ   s2   € ä+0°·±Ô+<Ó=Ñ+< a”�T—X‘X˜a“[Õ!Ð+<Ñ=Ð=ùÒ=s   ˜!<c                óÜ   — t        |t        t        f«      rt        |«      g| j                  z  }t	        |«      }t        |«      | j                  k7  rt        d«      ‚|| j                  |<   y)z>Set row values to a fixed value or from an iterable of floats.zInvalid item countN)r+   r-   Úintrh   r    ÚlenÚ
ValueErrorr,   ©rL   rm   rM   s      r#   Úset_rowzMatrix.set_rowÊ   sW   € ä�eœe¤S˜\Ô*Ü˜5“\�N T§Z¡ZÑ/ˆEÜ�U“ˆÜˆu‹:˜Ÿ™Ò#ÜÐ1Ó2Ð2Ø"ˆ�‰�EÒr<   c                óš   — t        |t        t        f«      rt        |«      g| j                  z  }t	        |«      | j
                  dd…|f<   y)zASet column values to a fixed value or from an iterable of floats.N)r+   r-   r}   rd   r    r,   r€   s      r#   Úset_colzMatrix.set_colÓ   s:   € ä�eœe¤S˜\Ô*Ü˜5“\�N T§Z¡ZÑ/ˆEÜ $ U£ˆ�‰’A�u�HÒr<   c                ó`  — t        |t        t        f«      rt        t        |«      «      }t	        |d«      }t        t        |d«      «      }t        t        t	        | j                  | j                  «      «      |«      D ]  \  }}	 || j                  ||z   ||z   f<   Œ y# t        $ r Y  yw xY w)a­  Set diagonal values to a fixed value or from an iterable of floats.

        An `index` of ``0`` specifies the main diagonal, negative values
        specifies diagonals below the main diagonal and positive values
        specifies diagonals above the main diagonal.

        e.g. given a 4x4 matrix:
        index ``0`` is [00, 11, 22, 33],
        index ``-1`` is [10, 21, 32] and
        index ``+1`` is [01, 12, 23]

        r   N)r+   r-   r}   r   ÚmaxÚabsÚminr   rz   rd   rh   r,   Ú
IndexError)rL   rm   rM   Ú
col_offsetÚ
row_offsetÚvalues         r#   Úset_diagzMatrix.set_diagÙ   s›   € ô �eœe¤S˜\Ô*Üœ5 ›<Ó(ˆEä˜e Q›-ˆ
Üœc %¨›mÓ,ˆ
ä¤¤c¨$¯*©*°d·j±jÓ&AÓ BÀEÖJ‰LˆE�5ðØFK�—‘˜E JÑ.°¸
Ñ0BÐBÒCñ Køô ò Úðús   ÂB Â 	B-Â,B-c                óB   — t        |¬«      }|j                  dd«       |S )z6Returns the identity matrix for configuration `shape`.)rH   r   ç      ð?)r   rŒ   )ÚclsrH   rV   s      r#   ÚidentityzMatrix.identityò   s!   € ô ˜ÔˆØ	�
‰
�1�cÔØˆr<   c                ó  — | j                   j                  dk(  r,t        j                  |gt        j                  ¬«      | _         yt        |«      | j                  k(  r%t        j                  | j                   |f   | _         yt        d«      ‚)zAppend a row to the matrix.r   rB   úInvalid item count.N)	r,   ÚsizerD   rE   rF   r~   rh   Úr_r   )rL   rM   s     r#   Ú
append_rowzMatrix.append_rowù   sa   € à�;‰;×Ñ˜qÒ ÜŸ(™( E 7´"·*±*Ô=ˆD�KÜ�‹Z˜4Ÿ:™:Ò%ÜŸ%™% §¡¨UÐ 2Ñ3ˆD�KäÐ2Ó3Ð3r<   c                óB  — | j                   j                  dk(  r:t        j                  |D �cg c]  }|g‘Œ c}t        j                  ¬«      | _         yt        |«      | j                  k(  r%t        j                  | j                   |f   | _         yt        d«      ‚c c}w )zAppend a column to the matrix.r   rB   r’   N)	r,   r“   rD   rE   rF   r~   rd   Úc_r   )rL   rM   Úitems      r#   Ú
append_colzMatrix.append_col  su   € à�;‰;×Ñ˜qÒ ÜŸ(™(±uÓ#=±u¨t T¢F°uÑ#=ÄRÇZÁZÔPˆD�KÜ�‹Z˜4Ÿ:™:Ò%ÜŸ%™% §¡¨UÐ 2Ñ3ˆD�KäÐ2Ó3Ð3ùò	 $>s   ­
Bc                ó\   — | j                  «       }d|j                  j                  _        |S )z@Returns a frozen matrix, all data is stored in immutable tuples.F)rW   r,   ÚflagsÚ	writeablerU   s     r#   ÚfreezezMatrix.freeze  s"   € à�M‰M‹OˆØ#(ˆ�‰�‰Ô Øˆr<   c                ó2   — t        | j                  |   «      S )zjGet value by (row, col) index tuple, fancy slicing as known from
        numpy is not supported.

        )r-   r,   )rL   r˜   s     r#   Ú__getitem__zMatrix.__getitem__  s   € ô
 �T—[‘[ Ñ&Ó'Ð'r<   c                ó"   — || j                   |<   y)zjSet value by (row, col) index tuple, fancy slicing as known from
        numpy is not supported.

        NrT   )rL   r˜   r‹   s      r#   Ú__setitem__zMatrix.__setitem__  s   € ð
 "ˆ�‰�DÒr<   c                óê   — t        |t        «      st        d«      ‚| j                  |j                  k7  rt        d«      ‚t	        t        j                  | j                  |j                  k(  «      «      S )z'Returns ``True`` if matrices are equal.úMatrix class required.úMatrices have different shapes.)r+   r   rK   rH   ÚboolrD   Úallr,   ©rL   Úothers     r#   Ú__eq__zMatrix.__eq__  sU   € ä˜%¤Ô(ÜÐ4Ó5Ð5Ø�:‰:˜Ÿ™Ò$ÜÐ=Ó>Ð>Ü”B—F‘F˜4Ÿ;™;¨%¯,©,Ñ6Ó7Ó8Ð8r<   c           	     ó$  — t        |t        «      st        d«      ‚| j                  |j                  k7  rt        d«      ‚t	        t        j                  t        j                  | j                  |j                  | j                  ¬«      «      «      S )z˜Returns ``True`` if matrices are close to equal, tolerance value for
        comparison is adjustable by the attribute :attr:`Matrix.abs_tol`.

        r£   r¤   )Úatol)
r+   r   rK   rH   r¥   rD   r¦   Úiscloser,   r>   r§   s     r#   r¬   zMatrix.isclose'  sc   € ô
 ˜%¤Ô(ÜÐ4Ó5Ð5Ø�:‰:˜Ÿ™Ò$ÜÐ=Ó>Ð>Ü”B—F‘Fœ2Ÿ:™: d§k¡k°5·<±<ÀdÇlÁlÔSÓTÓUÐUr<   c                óÒ   — t        |t        «      r4t        t        j                  | j                  |j                  «      ¬«      S t        | j                  t        |«      z  ¬«      }|S )z[Matrix multiplication by another matrix or a float, returns a new
        matrix.

        rT   )r+   r   rD   Úmatmulr,   r-   )rL   r¨   r,   s      r#   Ú__mul__zMatrix.__mul__2  sH   € ô
 �eœVÔ$Ü¤§¡¨4¯;©;¸¿¹Ó!EÔFÐFä 4§;¡;´°u³Ñ#=Ô>ˆFØˆr<   c                ó¬   — t        |t        «      r#t        | j                  |j                  z   ¬«      S t        | j                  t        |«      z   ¬«      S )zCMatrix addition by another matrix or a float, returns a new matrix.rT   r*   r§   s     r#   Ú__add__zMatrix.__add__?  s<   € ä�eœVÔ$Ü §¡¨u¯|©|Ñ!;Ô<Ð<ä §¡¬u°U«|Ñ!;Ô<Ð<r<   c                ó¬   — t        |t        «      r#t        | j                  |j                  z
  ¬«      S t        | j                  t        |«      z
  ¬«      S )zXMatrix subtraction by another matrix or a float, returns a new
        matrix.

        rT   r*   r§   s     r#   Ú__sub__zMatrix.__sub__H  s>   € ô
 �eœVÔ$Ü §¡¨u¯|©|Ñ!;Ô<Ð<ä §¡¬u°U«|Ñ!;Ô<Ð<r<   c                óB   — t        | j                  j                  ¬«      S )z Returns a new transposed matrix.rT   )r   r,   ÚTrQ   s    r#   Ú	transposezMatrix.transposeT  s   € ä˜TŸ[™[Ÿ]™]Ô+Ð+r<   c                ó   — | j                   | j                  k7  rt        d«      ‚	 t        t        j
                  j                  | j                  «      ¬«      S # t        j
                  j                  $ r t        ‚w xY w)z(Returns inverse of matrix as new object.z+Inverse of non-square matrix not supported.rT   )
rd   rh   rK   r   rD   ÚlinalgÚinvr,   ÚLinAlgErrorÚZeroDivisionErrorrQ   s    r#   ÚinversezMatrix.inverseX  s^   € à�:‰:˜Ÿ™Ò#ÜÐIÓJÐJð	$Ü¤§¡§¡¨t¯{©{Ó!;Ô<Ð<øÜ�y‰y×$Ñ$ò 	$Ü#Ð#ð	$ús   ¦2A Á$A=c                óf   — t        t        j                  j                  | j                  «      «      S )ziReturns determinant of matrix, raises :class:`ZeroDivisionError`
        if matrix is singular.

        )r-   rD   r¸   Údetr,   rQ   s    r#   ÚdeterminantzMatrix.determinanta  s    € ô
 ”R—Y‘Y—]‘] 4§;¡;Ó/Ó0Ð0r<   )NNN)rM   r   rH   zOptional[Shape]r,   zOptional[MatrixData | NDArray])Úreturnr(   )rÀ   z'Matrix')rÀ   rY   )rM   úIterable[float]rH   r'   rÀ   r   ©rÀ   r}   )rÀ   r'   )rm   r}   rÀ   úlist[float])rÀ   zlist[list[float]])rŽ   )rm   r}   rM   zfloat | Iterable[float]rÀ   ÚNone)r   rŽ   )rH   r'   rÀ   r   )rM   úSequence[float]rÀ   rÄ   )rÀ   r   )r˜   útuple[int, int]rÀ   r-   )r˜   rÆ   r‹   r-   )r¨   ÚobjectrÀ   r¥   )r¨   zMatrix | floatrÀ   r   )rÀ   r-   )*Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__rN   rR   rW   rZ   r_   ÚstaticmethodrI   Úpropertyrd   rh   rH   r/   ro   rr   rx   r{   r�   rƒ   rŒ   Úclassmethodr�   r•   r™   r�   rŸ   r¡   r©   r¬   r¯   Ú__imul__r±   Ú__iadd__r³   Ú__isub__r¶   r¼   r¿   rA   r<   r#   r   r   T   s7  „ ñð$ &€Ið Ø!%Ø15ð	YàðYð ðYð /ó	Yó:%óó
 ó6ð òUó ðUð ò$ó ð$ð ò$ó ð$ð ò!ó ð!ó(ó+ó1ó 2ó>ô#ô,ôð2 òó ðó4ó4óó(ó"ó9ó	Vó	ð €Hó=ð €Hó=ð €Hó,ó$ô1r<   r   c                  óX   — e Zd Zej                  dd„«       Zej                  dd„«       Zy)r   c                 ó   — y r   rA   ©rL   ÚBs     r#   Úsolve_matrixzSolver.solve_matrixj  ó   € àr<   c                 ó   — y r   rA   rÕ   s     r#   Úsolve_vectorzSolver.solve_vectorn  rØ   r<   N©rÖ   úMatrixData | NDArrayrÀ   r   ©rÖ   rÁ   rÀ   rÃ   )rÈ   rÉ   rÊ   ÚabcÚabstractmethodr×   rÚ   rA   r<   r#   r   r   i  s4   „ Ø×Ñòó ðð 	×Ñòó ñr<   r   c                óö   — t        | «      |k  rt        |«      |k  r| fS | |z  fS 	 t        j                  |dz  d| z  |z  z
  «      }| |z   d| z  z  | |z
  d| z  z  fS # t        $ r t	        «       cY S w xY w)z~Returns the solution for the quadratic equation ``a*x^2 + b*x + c = 0``.

    Returns 0-2 solutions as a tuple of floats.
    é   é   ç       @)r†   r5   Úsqrtr   Útuple)ÚaÚbÚcr>   Údiscriminants        r#   r   r   s  sœ   € ô
 ˆ1ƒv�ÒÜˆq‹6�GÒØ�B�5ˆLØ��Q‘ˆyÐðÜ—y‘y  A¡¨¨A©°©	Ñ!1Ó2ˆð ˆR�,Ñ 3¨¡7Ñ+°°°\Ñ0AÀcÈAÁgÑ/NÐOÐOøô ò Ü‹wŠðús   ©!A" Á"A8Á7A8c                ó
  — t        | «      dk  r	 t        |||«      S || z  }|| z  }|| z  }||z  }|dz  }d|z  |z
  dz  }	d|z  |z  d|z  z
  d||z  z  z
  dz  }
|	|	z  |	z  }||
|
z  z   }|dk\  r¶t	        j
                  |«      }d}t	        j                  d	|
|z   «      t	        j                  t        |
|z   «      |«      z  }t	        j                  d	|
|z
  «      t	        j                  t        |
|z
  «      |«      z  }||z   }||z
  r| |z   fS |dz  }| |z   | |z
  | |z
  fS t	        j                  |
t	        j
                  | «      z  «      }t	        j
                  |	 «      dz  }|t	        j                  |dz  «      z  |z
  |t	        j                  |dt        j                  z  z   dz  «      z  |z
  |t	        j                  |d
t        j                  z  z   dz  «      z  |z
  fS # t        $ r t        «       cY S w xY w)z‚Returns the solution for the cubic equation ``a*x^3 + b*x^2 + c*x + d = 0``.

    Returns 0-3 solutions as a tuple of floats.
    r@   g      @g      "@g      ;@rã   g      K@ç        gUUUUUUÕ?rŽ   g      @)r†   r   ÚArithmeticErrorrå   r5   rä   ÚcopysignÚpowÚacosÚcosÚpi)ræ   rç   rè   Údr.   rÖ   ÚCÚAAÚA3ÚQÚRÚQQQÚDÚsqrtDÚexpÚSrµ   ÚSTÚST_2ÚthÚsqrtQ2s                        r#   r   r   „  s"  € ô
 ˆ1ƒv�‚~ð	Ü% a¨¨AÓ.Ð.ð 	
ˆA‰€AØ	ˆA‰€AØ	ˆA‰€AØ	
ˆQ‰€BØ	
ˆS‰€Bà	ˆq‰�2‰˜Ñ€AØ	ˆq‰�1‰�t˜a‘xÑ	 #¨¨a©¡.Ñ	0°DÑ8€AØ
ˆa‰%�!‰)€CØˆq�1‰u‰€AàˆC‚xÜ—	‘	˜!“ˆØˆÜ�M‰M˜#˜q 5™yÓ)¬D¯H©H´S¸¸U¹³^ÀSÓ,IÑIˆÜ�M‰M˜#˜q 5™yÓ)¬D¯H©H´S¸¸U¹³^ÀSÓ,IÑIˆØ�‰UˆØˆqŠ5Ø�C˜"‘H�;Ðà˜‘8ˆDà��b‘Ø��d‘
Ø��d‘
ðð ô 
�‰�1”t—y‘y # “Ñ&Ó	'€BÜ�Y‰Y˜�r‹]˜SÑ €Fà”—‘˜"˜s™(Ó#Ñ# bÑ(Ø”—‘˜2 ¤d§g¡g¡Ñ-°Ñ4Ó5Ñ5¸Ñ:Ø”—‘˜2 ¤d§g¡g¡Ñ-°Ñ4Ó5Ñ5¸Ñ:ðð øô? ò 	Ü“7ŠNð	ús   �G, Ç,HÈHc                óê   — t        j                  | t         j                  ¬«      }t        j                  |t         j                  ¬«      }t        t         j                  j                  ||«      ¬«      S )am  Solves the linear equation system given by a nxn Matrix A . x = B by the
    numpy.linalg.solve() function.

    Args:
        A: matrix [[a11, a12, ..., a1n], [a21, a22, ..., a2n], ... [an1, an2, ..., ann]]
        B: matrix [[b11, b12, ..., b1m], [b21, b22, ..., b2m], ... [bn1, bn2, ..., bnm]]

    Raises:
        numpy.linalg.LinAlgError: singular matrix

    rB   rT   )rD   rE   rF   r   r¸   Úsolve)r.   rÖ   Úmat_AÚmat_Bs       r#   r   r   ²  sF   € ô �H‰H�QœbŸj™jÔ)€EÜ�H‰H�QœbŸj™jÔ)€EÜœŸ™Ÿ™¨°Ó6Ô7Ð7r<   c                óH  — t        j                  | t         j                  ¬«      }t        j                  |D �cg c]  }t        |«      g‘Œ c}t         j                  ¬«      }t	        t        j
                  t         j                  j                  ||«      «      «      S c c}w )at  Solves the linear equation system given by a nxn Matrix A . x = B,
    right-hand side quantities as vector B with n elements by the numpy.linalg.solve()
    function.

    Args:
        A: matrix [[a11, a12, ..., a1n], [a21, a22, ..., a2n], ... [an1, an2, ..., ann]]
        B: vector [b1, b2, ..., bn]

    Raises:
        numpy.linalg.LinAlgError: singular matrix

    rB   )rD   rE   rF   r-   r    rP   r¸   r  )r.   rÖ   r  r0   r  s        r#   r   r   Ã  si   € ô �H‰H�QœbŸj™jÔ)€EÜ�H‰H©!Ó,©! Q”u˜Q“x’j¨!Ñ,´B·J±JÔ?€EÜ”—‘œŸ™Ÿ™¨°Ó6Ó7Ó8Ð8ùò -s   ¹Bc                  ó(   — e Zd ZdZdd„Zdd„Zdd„Zy)	r   z5Replaces in v1.2 the :class:`LUDecomposition` solver.c                óX   — t        j                  |t         j                  ¬«      | _        y )NrB   )rD   rE   rF   r  )rL   r.   s     r#   rN   zNumpySolver.__init__Ø  s   € Ü—X‘X˜a¤r§z¡zÔ2ˆ�
r<   c                ó´   — t        j                  |t         j                  ¬«      }t        t         j                  j                  | j                  |«      ¬«      S )aN  
        Solves the linear equation system given by the nxn Matrix
        A . x = B, right-hand side quantities as nxm Matrix B.

        Args:
            B: matrix [[b11, b12, ..., b1m], [b21, b22, ..., b2m],
                ... [bn1, bn2, ..., bnm]]

        Raises:
            numpy.linalg.LinAlgError: singular matrix

        rB   rT   )rD   rE   rF   r   r¸   r  r  )rL   rÖ   r  s      r#   r×   zNumpySolver.solve_matrixÛ  s6   € ô —‘˜¤"§*¡*Ô-ˆÜœRŸY™YŸ_™_¨T¯Z©Z¸Ó?Ô@Ð@r<   c                ó  — t        j                  |D �cg c]  }t        |«      g‘Œ c}t         j                  ¬«      }t	        t        j
                  t         j                  j                  | j                  |«      «      «      S c c}w )a  Solves the linear equation system given by the nxn Matrix
        A . x = B, right-hand side quantities as vector B with n elements.

        Args:
            B: vector [b1, b2, ..., bn]

        Raises:
            numpy.linalg.LinAlgError: singular matrix

        rB   )	rD   rE   r-   rF   r    rP   r¸   r  r  )rL   rÖ   r0   r  s       r#   rÚ   zNumpySolver.solve_vectorë  sY   € ô —‘©aÓ0©a¨œ5 ›8š*¨aÑ0¼¿
¹
ÔCˆÜ”B—H‘HœRŸY™YŸ_™_¨T¯Z©Z¸Ó?Ó@ÓAÐAùò 1s   ”BN)r.   rÜ   rÀ   rÄ   rÛ   rÝ   )rÈ   rÉ   rÊ   rË   rN   r×   rÚ   rA   r<   r#   r   r   Õ  s   „ Ù?ó3óAô Br<   r   c                ót   — | D �cg c]  }t        |«      ‘Œ c}\  }}}t        |||t        |«      «      S c c}w )a%  Solves the linear equation system given by a tri-diagonal nxn Matrix
    A . x = B, right-hand side quantities as vector B. Matrix A is diagonal
    matrix defined by 3 diagonals [-1 (a), 0 (b), +1 (c)].

    Note: a0 is not used but has to be present, cn-1 is also not used and must
    not be present.

    If an :class:`ZeroDivisionError` exception occurs, the equation system can
    possibly be solved by :code:`BandedMatrixLU(A, 1, 1).solve_vector(B)`

    Args:
        A: diagonal matrix [[a0..an-1], [b0..bn-1], [c0..cn-1]] ::

            [[b0, c0, 0, 0, ...],
            [a1, b1, c1, 0, ...],
            [0, a2, b2, c2, ...],
            ... ]

        B: iterable of floats [[b1, b1, ..., bn]

    Returns:
        list of floats

    Raises:
        ZeroDivisionError: singular matrix

    )r    Ú_solve_tridiagonal_matrix)r.   rÖ   r0   ræ   rç   rè   s         r#   r   r   ú  s<   € ñ8 !"Ó"¡˜1Œt�A�w Ñ"�G€A€qˆ!Ü$ Q¨¨1¬d°1«gÓ6Ð6ùò #s   …5c                ó¬  — | D �cg c]  }t        |«      ‘Œ c}\  }}}t        |t        «      s$t        |D �cg c]  }t        |«      ‘Œ c}¬«      }nt        t        |«      }|j                  t        |«      k7  rt        d«      ‚t        |j                  «       D �cg c]  }t        ||||«      ‘Œ c}¬«      j                  «       S c c}w c c}w c c}w )aœ  Solves the linear equation system given by a tri-diagonal nxn Matrix
    A . x = B, right-hand side quantities as nxm Matrix B. Matrix A is diagonal
    matrix defined by 3 diagonals [-1 (a), 0 (b), +1 (c)].

    Note: a0 is not used but has to be present, cn-1 is also not used and must
    not be present.

    If an :class:`ZeroDivisionError` exception occurs, the equation system
    can possibly be solved by :code:`BandedMatrixLU(A, 1, 1).solve_vector(B)`

    Args:
        A: diagonal matrix [[a0..an-1], [b0..bn-1], [c0..cn-1]] ::

            [[b0, c0, 0, 0, ...],
            [a1, b1, c1, 0, ...],
            [0, a2, b2, c2, ...],
            ... ]

        B: matrix [[b11, b12, ..., b1m],
                   [b21, b22, ..., b2m],
                   ...
                   [bn1, bn2, ..., bnm]]

    Returns:
        matrix as :class:`Matrix` object

    Raises:
        ZeroDivisionError: singular matrix

    rT   z+Row count of matrices A and B has to match.)
r    r+   r   r	   rd   r~   r   r{   r  r¶   )	r.   rÖ   r0   ræ   rç   rè   r/   Úmatrix_bro   s	            r#   r   r     s·   € ñB !"Ó"¡˜1Œt�A�w Ñ"�G€A€qˆ!Ü�aœÔ Ü±qÓ!9±q°¤$ s¥)°qÑ!9Ô:‰äœ “?ˆØ‡~�~œ˜Q›ÒÜÐFÓGÐGäØCKÇ=Á=Ä?ÓSÁ?¸CÔ)¨!¨Q°°3Õ7À?ÑSôç�iƒkðùò #ùâ!9ùò Ts   …C·CÂCc                óJ  — t        | «      }dg|z  }dg|z  }|d   }|d   |z  |d<   t        d|«      D ];  }||dz
     |z  ||<   ||   | |   ||   z  z
  }||   | |   ||dz
     z  z
  |z  ||<   Œ= t        |dz
  dd«      D ]  }||xx   ||dz      ||dz      z  z  cc<   Œ  |S )aB  Solves the linear equation system given by a tri-diagonal
    Matrix(a, b, c) . x = r.

    Matrix configuration::

        [[b0, c0, 0, 0, ...],
        [a1, b1, c1, 0, ...],
        [0, a2, b2, c2, ...],
        ... ]

    Args:
        a: lower diagonal [a0 .. an-1], a0 is not used but has to be present
        b: central diagonal [b0 .. bn-1]
        c: upper diagonal [c0 .. cn-1], cn-1 is not used and must not be present
        r: right-hand side quantities

    Returns:
        vector x as list of floats

    Raises:
        ZeroDivisionError: singular matrix

    rë   r   rg   rá   éÿÿÿÿ)r~   rz   )	ræ   rç   rè   rv   ÚnÚuÚgamÚbetÚjs	            r#   r  r  H  sä   € ô4 �‹V€AØ�U˜Q‘Y€AØ�u˜q‘y€CØ�1‘€CØˆQ‰4�#‰:€A€a�DÜ�1�aŽ[ˆØ�1�q‘5‘˜C‘ˆˆA‰Ø�‰d�Q�q‘T˜C ™F‘]Ñ"ˆØ�!‘�q˜‘t˜a  A¡™h‘Ñ&¨#Ñ-ˆˆ!Šð ô
 �A˜‘E˜B Ö#ˆØ	ˆ!‹��A˜‘E‘
˜Q˜q 1™u™XÑ%Ñ%Œð $à€Hr<   c                óD   — t        | |«      \  }}t        | ||«      }|||fS )aY  Transform matrix A into a compact banded matrix representation.
    Returns compact representation as :class:`Matrix` object and
    lower- and upper band count m1 and m2.

    Args:
        A: input :class:`Matrix`
        check_all: check all diagonals if ``True`` or abort testing
            after first all zero diagonal if ``False``.

    )r   r   )r.   Ú	check_allÚm1Úm2rV   s        r#   r   r   q  s.   € ô " ! YÓ/�F€BˆÜ˜a  RÓ(€AØˆb�"ˆ9Ðr<   c                ó>   ‡ ‡— dˆ ˆfd„}dˆ ˆfd„} |«        |«       fS )zÜReturns lower- and upper band count m1 and m2.

    Args:
        A: input :class:`Matrix`
        check_all: check all diagonals if ``True`` or abort testing
            after first all zero diagonal if ``False``.

    c                 ó†   •— d} t        d‰j                  «      D ]$  }t        ‰j                  |«      «      r|} Œ ‰rŒ# | S  | S ©Nr   rg   )rz   rh   Úanyrr   )r  rò   r.   r  s     €€r#   Ú	detect_m2z'detect_banded_matrix.<locals>.detect_m2‹  sC   ø€ ØˆÜ�q˜!Ÿ'™'Ö"ˆAÜ�1—6‘6˜!“9Œ~Ø‘ÚØØˆ	ð #ð
 ˆ	r<   c                 óˆ   •— d} t        d‰j                  «      D ]%  }t        ‰j                  | «      «      r|} Œ!‰rŒ$ | S  | S r  )rz   rd   r  rr   )r  rò   r.   r  s     €€r#   Ú	detect_m1z'detect_banded_matrix.<locals>.detect_m1”  sE   ø€ ØˆÜ�q˜!Ÿ'™'Ö"ˆAÜ�1—6‘6˜1˜"“:ŒØ‘ÚØØˆ	ð #ð
 ˆ	r<   rÂ   rA   )r.   r  r  r  s   ``  r#   r   r   �  s   ù€ ööñ ‹;™	›Ð#Ð#r<   c                óÌ  — | j                   | j                  k7  rt        d«      ‚t        «       }t	        |dd«      D ]:  }dg|z  }|j                  | j                  | «      «       |j                  |«       Œ< |j                  | j                  d«      «       t	        d|dz   «      D ]9  }| j                  |«      }|j                  dg|z  «       |j                  |«       Œ; |S )zñReturns compact banded matrix representation as :class:`Matrix` object.

    Args:
        A: matrix to transform
        m1: lower band count, excluding main matrix diagonal
        m2: upper band count, excluding main matrix diagonal

    zSquare matrix required.r   r  rë   rg   )rd   rh   rK   r   rz   Úextendrr   r™   )r.   r  r  rV   rò   ro   s         r#   r   r      sÄ   € ð 	‡w�w�!—'‘'ÒÜÐ1Ó2Ð2ä‹€Aä�2�q˜"ÖˆØˆe�a‰iˆØ�
‰
�1—6‘6˜1˜"“:ÔØ	�‰�SÕð ð
 ‡L�L�—‘˜“Ôä�1�b˜1‘fÖˆØ�f‰f�Q‹iˆØ�
‰
�C�5˜1‘9ÔØ	�‰�SÕð ð €Hr<   c                  ó:   — e Zd ZdZdd„Zedd„«       Zd	d„Zd
d„Zy)r   z9Represents a LU decomposition of a compact banded matrix.c                óÞ   — t         }t        rddlm} t	        |«      | _        t	        |«      | _         ||j                  | j
                  | j                  «      \  | _        | _	        | _
        y )Nr   )Úlu_decompose)Ú_lu_decomposer   Úezdxf.acc.np_supportr$  r}   r  r  r,   ÚupperÚlowerrm   )rL   r.   r  r  r$  s        r#   rN   zBandedMatrixLU.__init__¿  sJ   € Ü$ˆÝå9ä˜2“wˆŒÜ˜2“wˆŒÙ-9¸!¿(¹(ÀDÇGÁGÈTÏWÉWÓ-UÑ*ˆŒ
�D”J ¥
r<   c                ó4   — | j                   j                  d   S rb   )r'  rH   rQ   s    r#   rd   zBandedMatrixLU.nrowsÉ  s   € ð �z‰z×Ñ Ñ"Ð"r<   c           
     óF  — t         }t        rddlm} t	        j
                  |t        j                  ¬«      }t        |«      | j                  k7  rt        d«      ‚t         ||| j                  | j                  | j                  | j                  | j                  «      «      S )a  Solves the linear equation system given by the banded nxn Matrix
        A . x = B, right-hand side quantities as vector B with n elements.

        Args:
            B: vector [b1, b2, ..., bn]

        Returns:
            vector as list of floats

        r   )Úsolve_vector_banded_matrixrB   ú;Item count of vector B has to be equal to matrix row count.)Ú_solve_vector_banded_matrixr   r&  r+  rD   rE   rF   r~   rd   r   r    r'  r(  rm   r  r  )rL   rÖ   r+  Úxs       r#   rÚ   zBandedMatrixLU.solve_vectorÎ  s}   € ô &AÐ"ÝåGä—X‘X˜a¤r§z¡zÔ2ˆÜˆq‹6�T—Z‘ZÒÜØMóð ô Ù&Ø�4—:‘:˜tŸz™z¨4¯:©:°t·w±wÀÇÁóó
ð 	
r<   c                óö   — t        |¬«      }|j                  | j                  k7  rt        d«      ‚t        |j                  «       D �cg c]  }| j	                  |«      ‘Œ c}¬«      j                  «       S c c}w )aM  
        Solves the linear equation system given by the banded nxn Matrix
        A . x = B, right-hand side quantities as nxm Matrix B.

        Args:
            B: matrix [[b11, b12, ..., b1m], [b21, b22, ..., b2m],
                ... [bn1, bn2, ..., bnm]]

        Returns:
            matrix as :class:`Matrix` object

        rT   z,Row count of self and matrix B has to match.)r   rd   r   r{   rÚ   r¶   )rL   rÖ   r  ro   s       r#   r×   zBandedMatrixLU.solve_matrixê  sd   € ô  Ô#ˆØ�>‰>˜TŸZ™ZÒ'ÜÐKÓLÐLäØ6>·m±m´oÓF±o¨s�D×%Ñ% cÕ*°oÑFô
ç
‰)‹+ð	ùÚFs   ÁA6N)r.   r   r  r}   r  r}   rÂ   rÝ   rÛ   )	rÈ   rÉ   rÊ   rË   rN   rÎ   rd   rÚ   r×   rA   r<   r#   r   r   ¼  s)   „ ÙCóVð ò#ó ð#ó
ô8r<   r   c                óä  — t        j                  | t         j                  ¬«      }|j                  d   }t        j                  ||ft         j                  ¬«      }t        j                  |ft         j
                  ¬«      }||z   dz   }|}t        |«      D ]K  }	t        ||	z
  |«      D ]  }
||	   |
   ||	   |
|z
  <   Œ |dz  }t        ||z
  dz
  |«      D ]
  }
d||	   |
<   Œ ŒM |}t        |«      D ]ø  }||   d   }|}	||k  r|dz  }t        |dz   |«      D ]*  }
t        ||
   d   «      t        |«      kD  sŒ!||
   d   }|
}	Œ, |	dz   ||<   |	|k7  r-t        |«      D ]  }
||	   |
   ||   |
   c||   |
<   ||	   |
<   Œ! t        |dz   |«      D ]Z  }	||	   d   ||   d   z  }|||   |	|z
  dz
  <   t        d|«      D ]  }
||	   |
   |||   |
   z  z
  ||	   |
dz
  <   Œ! d||	   |dz
  <   Œ\ Œú |||fS )NrB   r   rg   rë   )rD   rE   rF   rH   rG   Úint64rz   r†   )r.   r  r  r'  r  r(  rm   ÚmmÚlr8   r  r7   Údums                r#   r%  r%     s8  € ä—X‘X˜a¤r§z¡zÔ2€Eð �[‰[˜‰^€AÜ—X‘X˜q "˜g¬R¯Z©ZÔ8€EÜ—X‘X˜q˜d¬"¯(©(Ô3€Eà�2‰g˜‰k€BØ€AÜ�2ŽYˆÜ�r˜A‘v˜rÖ"ˆAØ# A™h q™kˆE�!‰H�Q˜‘UŠOð #à	ˆQ‰ˆÜ�r˜A‘v ‘z 2Ö&ˆAØˆE�!‰H�QŠKñ 'ð	 ð 	€AÜ�1ŽXˆØ�A‰h�q‰kˆØˆØˆqŠ5Ø�‰FˆAÜ�q˜1‘u˜a–ˆAÜ�5˜‘8˜A‘;Ó¤# c£(Ó*Ø˜A‘h˜q‘k�Ø‘ð !ð �q‘5ˆˆa‰Ø�Š6Ü˜2–Y�Ø+0°©8°A©;¸¸a¹À¹Ð(��a‘˜‘˜U 1™X aš[ð ô �q˜1‘u˜a–ˆAØ˜‘(˜1‘+  a¡¨¡Ñ+ˆCØ"%ˆE�!‰H�Q˜‘U˜Q‘YÑÜ˜1˜b–\�Ø"'¨¡(¨1¡+°°e¸A±h¸q±kÑ0AÑ"A��a‘˜˜Q™’ð "à"ˆE�!‰H�R˜!‘VÒñ !ð ð( �%˜ÐÐr<   c                ó  — |j                   d   }| j                   d   |k7  rt        d«      ‚|}|}||z   dz   }	|}
t        |«      D ]]  }||   dz
  }||k7  r| |   | |   c| |<   | |<   |
|k  r|
dz  }
t        |dz   |
«      D ]!  }| |xx   ||   ||z
  dz
     | |   z  z  cc<   Œ# Œ_ d}
t        |dz
  dd«      D ]E  }| |   }t        d|
«      D ]  }|||   |   | ||z      z  z  }Œ |||   d   z  | |<   |
|	k  sŒA|
dz  }
ŒG | S )zëSolves the linear equation system given by the banded nxn Matrix
    A . x = B, right-hand side quantities as vector B with n elements.

    Args:
        B: vector [b1, b2, ..., bn]

    Returns:
        vector as list of floats

    r   r,  rg   r  )rH   r   rz   )r.  r'  r(  rm   r  r  r  ÚalÚaur2  r3  r7   r  r8   r4  s                  r#   r-  r-  *  sS  € ð$ �[‰[˜‰^€AØ‡w�wˆq�z�Q‚ÜÐVÓWÐWà€BØ€BØ�2‰g˜‰k€BØ€AÜ�1ŽXˆØ�!‰H�q‰LˆØ�Š6Ø˜1™˜q ™tˆJˆAˆa‰D�!�A‘$ØˆqŠ5Ø�‰FˆAÜ�q˜1‘u˜a–ˆAØˆa‹D�B�q‘E˜!˜a™% !™)Ñ$ q¨¡tÑ+Ñ+ŒDñ !ð ð 	
€AÜ�1�q‘5˜"˜bÖ!ˆØ�‰dˆÜ�q˜!–ˆAØ�2�a‘5˜‘8˜a  A¡™hÑ&Ñ&‰Cð à�R˜‘U˜1‘X‰~ˆˆ!‰Øˆr‹6Ø�‰F‰Að "ð €Hr<   )rÀ   zIterable[list])rÀ   r%   )r7   r}   r8   r}   rÀ   r-   )r@   )ræ   r-   rç   r-   rè   r-   rÀ   rÅ   )
ræ   r-   rç   r-   rè   r-   rò   r-   rÀ   rÅ   )r.   rÜ   rÖ   rÜ   rÀ   r   )r.   rÜ   rÖ   rÁ   rÀ   rÃ   )r.   r%   rÖ   rÁ   rÀ   rÃ   )
ræ   rÃ   rç   rÃ   rè   rÃ   rv   rÃ   rÀ   rÃ   )T)r.   r   rÀ   ztuple[Matrix, int, int])r.   r   rÀ   rÆ   )r.   r   r  r}   r  r}   rÀ   r   )r.   r(   r  r}   r  r}   rÀ   z tuple[NDArray, NDArray, NDArray])r.  r(   r'  r(   r(  r(   rm   r(   r  r}   r  r}   rÀ   r(   )6Ú
__future__r   Útypingr   r   r   r   r   r	   r
   Útyping_extensionsr   rÞ   Ú	functoolsr   Ú	itertoolsr   r5   r]   ÚnumpyrD   Únumpy.typingÚnptÚ	ezdxf.accr   Ú__all__r$   r-   r%   Ú__annotations__r&   r}   r'   r(   rF   r1   r   r   ÚABCr   r   r   r   r   r   r   r   r  r   r   r   r   r%  r-  rA   r<   r#   Ú<module>rD     s¶  ðö #÷÷ ñ õ (Û 
å Ý Û Û ã Ý Ý ò€ó$ð
 ˜T %™[Ñ)€
ˆIÓ )Ø# E¨%°¨*Ñ$5Ñ6Ð �)Ó 6Ø˜˜c˜‘?€€yÓ "Ø—[‘[ §¡Ñ,€ˆÓ ,ó2ñ �3Ôò/ó ð/÷,R1ñ R1ôjˆS�W‰Wô ôPó"+ó\8ó"9ô$"B�&ô "BóJ7ð@+Øð+Ø 4ð+àó+ð\&Øð&Ø"ð&Ø'2ð&Ø7Bð&àó&ôRô $ó>ô8A�Vô AóH'ðT,Øð,àð,ð ð,ð ð	,ð
 	ð,ð 	ð,ð ô,r<   