(degree, knot_vector, span, knot, order)
return ders
Computes derivatives of the basis functions for a single parameter.

    Implementation of Algorithm A2.3 from The NURBS Book by Piegl & Tiller.

    :param degree: degree, :math:`p`
    :type degree: int
    :param knot_vector: knot vector, :math:`U`
    :type knot_vector: list, tuple
    :param span: knot span, :math:`i`
    :type span: int
    :param knot: knot or parameter, :math:`u`
    :type knot: float
    :param order: order of the derivative
    :type order: int
    :return: derivatives of the basis functions
    :rtype: list
Computes derivatives of the basis functions for a single parameter.
Computes derivatives of the basis functions for a single parameter .
def basis_function_ders(degree, knot_vector, span, knot, order):
    """ Computes derivatives of the basis functions for a single parameter.

    Implementation of Algorithm A2.3 from The NURBS Book by Piegl & Tiller.

    :param degree: degree, :math:`p`
    :type degree: int
    :param knot_vector: knot vector, :math:`U`
    :type knot_vector: list, tuple
    :param span: knot span, :math:`i`
    :type span: int
    :param knot: knot or parameter, :math:`u`
    :type knot: float
    :param order: order of the derivative
    :type order: int
    :return: derivatives of the basis functions
    :rtype: list
    """
    # Initialize variables
    left = [1.0 for _ in range(degree + 1)]
    right = [1.0 for _ in range(degree + 1)]
    ndu = [[1.0 for _ in range(degree + 1)] for _ in range(degree + 1)]  # N[0][0] = 1.0 by definition

    for j in range(1, degree + 1):
        left[j] = knot - knot_vector[span + 1 - j]
        right[j] = knot_vector[span + j] - knot
        saved = 0.0
        r = 0
        for r in range(r, j):
            # Lower triangle
            ndu[j][r] = right[r + 1] + left[j - r]
            temp = ndu[r][j - 1] / ndu[j][r]
            # Upper triangle
            ndu[r][j] = saved + (right[r + 1] * temp)
            saved = left[j - r] * temp
        ndu[j][j] = saved

    # Load the basis functions
    ders = [[0.0 for _ in range(degree + 1)] for _ in range((min(degree, order) + 1))]
    for j in range(0, degree + 1):
        ders[0][j] = ndu[j][degree]

    # Start calculating derivatives
    a = [[1.0 for _ in range(degree + 1)] for _ in range(2)]
    # Loop over function index
    for r in range(0, degree + 1):
        # Alternate rows in array a
        s1 = 0
        s2 = 1
        a[0][0] = 1.0
        # Loop to compute k-th derivative
        for k in range(1, order + 1):
            d = 0.0
            rk = r - k
            pk = degree - k
            if r >= k:
                a[s2][0] = a[s1][0] / ndu[pk + 1][rk]
                d = a[s2][0] * ndu[rk][pk]
            if rk >= -1:
                j1 = 1
            else:
                j1 = -rk
            if (r - 1) <= pk:
                j2 = k - 1
            else:
                j2 = degree - r
            for j in range(j1, j2 + 1):
                a[s2][j] = (a[s1][j] - a[s1][j - 1]) / ndu[pk + 1][rk + j]
                d += (a[s2][j] * ndu[rk + j][pk])
            if r <= pk:
                a[s2][k] = -a[s1][k - 1] / ndu[pk + 1][r]
                d += (a[s2][k] * ndu[r][pk])
            ders[k][r] = d

            # Switch rows
            j = s1
            s1 = s2
            s2 = j

    # Multiply through by the the correct factors
    r = float(degree)
    for k in range(1, order + 1):
        for j in range(0, degree + 1):
            ders[k][j] *= r
        r *= (degree - k)

    # Return the basis function derivatives list
    return ders
def basis_function_ders ( degree , knot_vector , span , knot , order ) : # Initialize variables left = [ 1.0 for _ in range ( degree + 1 ) ] right = [ 1.0 for _ in range ( degree + 1 ) ] ndu = [ [ 1.0 for _ in range ( degree + 1 ) ] for _ in range ( degree + 1 ) ] # N[0][0] = 1.0 by definition for j in range ( 1 , degree + 1 ) : left [ j ] = knot - knot_vector [ span + 1 - j ] right [ j ] = knot_vector [ span + j ] - knot saved = 0.0 r = 0 for r in range ( r , j ) : # Lower triangle ndu [ j ] [ r ] = right [ r + 1 ] + left [ j - r ] temp = ndu [ r ] [ j - 1 ] / ndu [ j ] [ r ] # Upper triangle ndu [ r ] [ j ] = saved + ( right [ r + 1 ] * temp ) saved = left [ j - r ] * temp ndu [ j ] [ j ] = saved # Load the basis functions ders = [ [ 0.0 for _ in range ( degree + 1 ) ] for _ in range ( ( min ( degree , order ) + 1 ) ) ] for j in range ( 0 , degree + 1 ) : ders [ 0 ] [ j ] = ndu [ j ] [ degree ] # Start calculating derivatives a = [ [ 1.0 for _ in range ( degree + 1 ) ] for _ in range ( 2 ) ] # Loop over function index for r in range ( 0 , degree + 1 ) : # Alternate rows in array a s1 = 0 s2 = 1 a [ 0 ] [ 0 ] = 1.0 # Loop to compute k-th derivative for k in range ( 1 , order + 1 ) : d = 0.0 rk = r - k pk = degree - k if r >= k : a [ s2 ] [ 0 ] = a [ s1 ] [ 0 ] / ndu [ pk + 1 ] [ rk ] d = a [ s2 ] [ 0 ] * ndu [ rk ] [ pk ] if rk >= - 1 : j1 = 1 else : j1 = - rk if ( r - 1 ) <= pk : j2 = k - 1 else : j2 = degree - r for j in range ( j1 , j2 + 1 ) : a [ s2 ] [ j ] = ( a [ s1 ] [ j ] - a [ s1 ] [ j - 1 ] ) / ndu [ pk + 1 ] [ rk + j ] d += ( a [ s2 ] [ j ] * ndu [ rk + j ] [ pk ] ) if r <= pk : a [ s2 ] [ k ] = - a [ s1 ] [ k - 1 ] / ndu [ pk + 1 ] [ r ] d += ( a [ s2 ] [ k ] * ndu [ r ] [ pk ] ) ders [ k ] [ r ] = d # Switch rows j = s1 s1 = s2 s2 = j # Multiply through by the the correct factors r = float ( degree ) for k in range ( 1 , order + 1 ) : for j in range ( 0 , degree + 1 ) : ders [ k ] [ j ] *= r r *= ( degree - k ) # Return the basis function derivatives list return ders