+
    iL'                         ^ RI HtHt ^ RIHtHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHt R tR t]! ^R	7      R
 4       tR tR tR# )    )Ssympify)Dummysymbols)	Piecewisepiecewise_fold)And)Interval)	lru_cachec                    \        V \        4      '       dT   \        V P                  4      ^8X  d:   V P                  w  r#VP                  V8X  d   Y2r2VP                  VP
                  3# \        RV ,          4      h)zreturn the interval corresponding to the condition

Conditions in spline's Piecewise give the range over
which an expression is valid like (lo <= x) & (x <= hi).
This function returns (lo, hi).
zunexpected cond type: %s)
isinstancer	   lenargsltsgts	TypeError)condxabs   &&  ڀ/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/functions/special/bsplines.py_ivlr   
   s^     $TYY1!4yy55A:quuaee|
.5
66    c                \   \         P                  W39   d"   \        W#,          4      pVP                  4       # \         P                  W239   d"   \        W,          4      pVP                  4       # . p\        W,          4      p\        W#,          4      p\        VP                  RR 4      p	VP                  RR  F  p
V
P
                  pV
P                  p\        W4      ^ ,          p\        V	4       Fe  w  rVP
                  pVP                  p\        VV4      w  ppVV8X  d   VV,          pW  M)VV8  g   KI  VV8:  g   KR  VP                  V4       W  M	  VP                  W34       K  	  VP                  V	4       VP                  R4       \        VRR/ pVP                  4       # )zConstruct c*b1 + d*b2.NevaluateFr   T)r   Zeror   listr   exprr   r   	enumerateappendextendr   expand)cb1db2r   rvnew_argsp1p2p2argsargr    r   loweriarg2expr2cond2lower_2upper_2s   &&&&&               r   _add_splinesr6      s}    	vv"AF#h 99;g 
B7	AF#d 99;a AF#AF# bggcrl# 773B<C88D88DM!$E %V,				#'q> D=EMD	u_E)9 OOD)	% -* OOTL)9  > 	 		"15199;r   )maxsizec           	        Tp\        4       p\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p\        V 4      p \        V4      p\        V4      pV^,
          pW ,           ^,           V8  d   \	        R4      hV ^ 8X  dK   \        \        P                  \        W,          W^,           ,          4      P                  V4      3R4      pEM%V ^ 8  Ed   WV ,           ^,           ,          W^,           ,          ,
          pV\        P                  8w  dA   WV ,           ^,           ,          V,
          V,          p	\        V ^,
          W^,           V4      p
M\        P                  ;rWV ,           ,          W,          ,
          pV\        P                  8w  d,   W1V,          ,
          V,          p\        V ^,
          WV4      pM\        P                  ;r\        WWV4      pM\	        RV,          4      hVP                  W4/4      # )aL  
The $n$-th B-spline at $x$ of degree $d$ with knots.

Explanation
===========

B-Splines are piecewise polynomials of degree $d$. They are defined on a
set of knots, which is a sequence of integers or floats.

Examples
========

The 0th degree splines have a value of 1 on a single interval:

    >>> from sympy import bspline_basis
    >>> from sympy.abc import x
    >>> d = 0
    >>> knots = tuple(range(5))
    >>> bspline_basis(d, knots, 0, x)
    Piecewise((1, (x >= 0) & (x <= 1)), (0, True))

For a given ``(d, knots)`` there are ``len(knots)-d-1`` B-splines
defined, that are indexed by ``n`` (starting at 0).

Here is an example of a cubic B-spline:

    >>> bspline_basis(3, tuple(range(5)), 0, x)
    Piecewise((x**3/6, (x >= 0) & (x <= 1)),
              (-x**3/2 + 2*x**2 - 2*x + 2/3,
              (x >= 1) & (x <= 2)),
              (x**3/2 - 4*x**2 + 10*x - 22/3,
              (x >= 2) & (x <= 3)),
              (-x**3/6 + 2*x**2 - 8*x + 32/3,
              (x >= 3) & (x <= 4)),
              (0, True))

By repeating knot points, you can introduce discontinuities in the
B-splines and their derivatives:

    >>> d = 1
    >>> knots = (0, 0, 2, 3, 4)
    >>> bspline_basis(d, knots, 0, x)
    Piecewise((1 - x/2, (x >= 0) & (x <= 2)), (0, True))

It is quite time consuming to construct and evaluate B-splines. If
you need to evaluate a B-spline many times, it is best to lambdify them
first:

    >>> from sympy import lambdify
    >>> d = 3
    >>> knots = tuple(range(10))
    >>> b0 = bspline_basis(d, knots, 0, x)
    >>> f = lambdify(x, b0)
    >>> y = f(0.5)

Parameters
==========

d : integer
    degree of bspline

knots : list of integer values
    list of knots points of bspline

n : integer
    $n$-th B-spline

x : symbol

See Also
========

bspline_basis_set

References
==========

.. [1] https://en.wikipedia.org/wiki/B-spline

c              3   8   "   T F  p\        V4      x  K  	  R # 5iN)r   ).0ks   & r   	<genexpr> bspline_basis.<locals>.<genexpr>   s     ,e'!**es   z(n + d + 1 must not exceed len(knots) - 1zdegree must be non-negative: %rr   )r   tupleintr   
ValueErrorr   r   Oner
   containsr   bspline_basisr6   xreplace)r'   knotsnr   xvarn_knotsn_intervalsresultdenomBr(   Ar&   s   &&&&         r   rD   rD   T   s   f DAE,e,EE,e,,EAAAA%jGA+Kuqy;CDDAvUUHUXuU|4==a@A9
 
Q!eai 5Q</AFF?1uqy!A%.Aq1ueUA6BVVOB!eux'AFF?1X&Aq1ue2BVVOBaQA.:Q>?? ??A9%%r   c           	         \        V4      V ,
          ^,
          p\        V4       Uu. uF  p\        V \        V4      WB4      NK  	  up# u upi )a  
Return the ``len(knots)-d-1`` B-splines at *x* of degree *d*
with *knots*.

Explanation
===========

This function returns a list of piecewise polynomials that are the
``len(knots)-d-1`` B-splines of degree *d* for the given knots.
This function calls ``bspline_basis(d, knots, n, x)`` for different
values of *n*.

Examples
========

>>> from sympy import bspline_basis_set
>>> from sympy.abc import x
>>> d = 2
>>> knots = range(5)
>>> splines = bspline_basis_set(d, knots, x)
>>> splines
[Piecewise((x**2/2, (x >= 0) & (x <= 1)),
           (-x**2 + 3*x - 3/2, (x >= 1) & (x <= 2)),
           (x**2/2 - 3*x + 9/2, (x >= 2) & (x <= 3)),
           (0, True)),
Piecewise((x**2/2 - x + 1/2, (x >= 1) & (x <= 2)),
          (-x**2 + 5*x - 11/2, (x >= 2) & (x <= 3)),
          (x**2/2 - 4*x + 8, (x >= 3) & (x <= 4)),
          (0, True))]

Parameters
==========

d : integer
    degree of bspline

knots : list of integers
    list of knots points of bspline

x : symbol

See Also
========

bspline_basis

)r   rangerD   r?   )r'   rF   r   	n_splinesr0   s   &&&  r   bspline_basis_setrR      sC    ` E
Q"I:?	:JK:JQM!U5\10:JKKKs   A	c                  a ^ RI Hp ^ RIHp \	        V 4      p V P
                  '       d   V P                  '       g   \        RV ,          4      h\        V4      \        V4      8w  d   \        R4      h\        V4      V ^,           8  d   \        R4      h\        ;QJ d,    R \        W"R,          4       4       F  '       d   K   RM!	  R	M! R \        W"R,          4       4       4      '       g   \        R
4      hV Uu. uF  p\	        V4      NK  	  ppV P                  '       d   V ^,           ^,          pW'V)  pMIV ^,          p\        W'V) ^,
           W'^,           V)  4       U	U
u. uF  w  rW,           ^,          NK  	  pp	p
V^ ,          .V ^,           ,          \        V4      ,           VR,          .V ^,           ,          ,           p\        WS4      pV UU
u. uF#  q U
u. uF  qP                  SV4      NK  	  up
NK%  	  ppp
V! V! V4      V! V4      3\        RP!                  \        V4      4      \"        R7      4      p\        V4      ^ ,          pV U
UUu0 uF#  qP$                   F  w  ppVR	8w  g   K  VkK  	  K%  	  ppp
p\'        VV3R lR7      pV U
UUu. uF$  qP$                   UUu/ uF	  w  ppVVbK  	  uppNK&  	  ppp
p. pV Ft  p\)        \        VV4       UU u. uF-  w  pp VV P+                  V\,        P.                  4      ,          NK/  	  up p\,        P.                  4      pVP1                  VV34       Kv  	  \3        V!  # u upi u up
p	i u up
i u up
pi u uppp
i u uppi u uppp
i u up pi )a  
Return spline of degree *d*, passing through the given *X*
and *Y* values.

Explanation
===========

This function returns a piecewise function such that each part is
a polynomial of degree not greater than *d*. The value of *d*
must be 1 or greater and the values of *X* must be strictly
increasing.

Examples
========

>>> from sympy import interpolating_spline
>>> from sympy.abc import x
>>> interpolating_spline(1, x, [1, 2, 4, 7], [3, 6, 5, 7])
Piecewise((3*x, (x >= 1) & (x <= 2)),
        (7 - x/2, (x >= 2) & (x <= 4)),
        (2*x/3 + 7/3, (x >= 4) & (x <= 7)))
>>> interpolating_spline(3, x, [-2, 0, 1, 3, 4], [4, 2, 1, 1, 3])
Piecewise((7*x**3/117 + 7*x**2/117 - 131*x/117 + 2, (x >= -2) & (x <= 1)),
        (10*x**3/117 - 2*x**2/117 - 122*x/117 + 77/39, (x >= 1) & (x <= 4)))

Parameters
==========

d : integer
    Degree of Bspline strictly greater than equal to one

x : symbol

X : list of strictly increasing real values
    list of X coordinates through which the spline passes

Y : list of real values
    list of corresponding Y coordinates through which the spline passes

See Also
========

bspline_basis_set, interpolating_poly

)linsolve)Matrixz1Spline degree must be a positive integer, not %s.z/Number of X and Y coordinates must be the same.z6Degree must be less than the number of control points.c              3   .   "   T F  w  rW8  x  K  	  R # 5ir:    )r;   r   r   s   &  r   r=   'interpolating_spline.<locals>.<genexpr>9  s     /qus   :   NNFTz.The x-coordinates must be strictly increasing.zc0:{})clsc                    < \        V S4      # r:   )r   )r%   r   s   &r   <lambda>&interpolating_spline.<locals>.<lambda>S  s    Q
r   )keyr   )sympy.solvers.solvesetrT   sympy.matrices.denserU   r   
is_Integeris_positiverA   r   allzipis_oddr   rR   subsr   formatr   r   sortedsumgetr   r   r"   r   )r'   r   XYrT   rU   r0   jinterior_knotsr   r   rF   basisvrN   coeffer%   	intervalsbasis_dictssplinepieces   &f&&                  r   interpolating_splinerw      s   \ 0+ 	
ALLLQ]]]LqPQQ
1vQJKK
1vA~QRR3/Q"/333/Q"///IJJQQA 	xxxUqLaRF"%aQBFmQ1ur]"C
"C$!QUAII"C 	 
 qTFa!etN33qugQ6GGEa*E0121	&1&&A,	&A2fQi+WW^^CF5KQV-WXEKNE!DEqfq!!t)EID y&:;I8=>1vv.vVaAqDv.K>F03E;0GH0Gfq!Qq!&&!!!0GH!&&
 	uaj!	 
 fC 	 
 
'2 E /> IsN   >M(MM$#M=M$M*<
M*!M74M1M7*3M>M$1M7N)
sympy.corer   r   sympy.core.symbolr   r   sympy.functionsr   r   sympy.logic.boolalgr	   sympy.sets.setsr
   	functoolsr   r   r6   rD   rR   rw   rW   r   r   <module>r~      sK    ! . 5 # $ 78v 3t& t&n1Lh\r   