Exemplo n.º 1
0
def spalde(x, tck):
    """Evaluate all derivatives of a B-spline.

    Description:

      Given the knots and coefficients of a cubic B-spline compute all
      derivatives up to order k at a point (or set of points).

    Inputs:

      tck -- A length 3 sequence describing the given spline (See splev).
      x -- A point or a set of points at which to evaluate the derivatives.
           Note that t(k) <= x <= t(n-k+1) must hold for each x.

    Outputs: (results, )

      results -- An array (or a list of arrays) containing all derivatives
                 up to order k inclusive for each point x.

    See also:
      splprep, splrep, splint, sproot, splev - evaluation, roots, integral
      bisplrep, bisplev - bivariate splines
      UnivariateSpline, BivariateSpline - an alternative wrapping
              of the FITPACK functions
    Notes:
    Based on algorithms from:
        de Boor C : On calculating with b-splines, J. Approximation Theory
                    6 (1972) 50-62.
        Cox M.G.  : The numerical evaluation of b-splines, J. Inst. Maths
                    applics 10 (1972) 134-149.
       Dierckx P. : Curve and surface fitting with splines, Monographs on
                    Numerical Analysis, Oxford University Press, 1993.
    """
    t, c, k = tck
    try:
        c[0][0]
        parametric = True
    except:
        parametric = False
    if parametric:
        return _ntlist(map(lambda c, x=x, t=t, k=k: spalde(x, [t, c, k]), c))
    else:
        try:
            x = x.tolist()
        except:
            try:
                x = list(x)
            except:
                x = [x]
        if len(x) > 1:
            return map(lambda x, tck=tck: spalde(x, tck), x)
        d, ier = _fitpack._spalde(t, c, k, x[0])
        if ier == 0: return d
        if ier == 10:
            raise TypeError, "Invalid input data. t(k)<=x<=t(n-k+1) must hold."
        raise TypeError, "Unknown error"
Exemplo n.º 2
0
def spalde(x,tck):
    """
    Evaluate all derivatives of a B-spline.

    Given the knots and coefficients of a cubic B-spline compute all
    derivatives up to order k at a point (or set of points).

    Parameters
    ----------
    tck : tuple
        A tuple (t,c,k) containing the vector of knots,
        the B-spline coefficients, and the degree of the spline.
    x : array_like
        A point or a set of points at which to evaluate the derivatives.
        Note that ``t(k) <= x <= t(n-k+1)`` must hold for each `x`.

    Returns
    -------
    results : array_like
        An array (or a list of arrays) containing all derivatives
        up to order k inclusive for each point x.

    See Also
    --------
    splprep, splrep, splint, sproot, splev, bisplrep, bisplev,
    UnivariateSpline, BivariateSpline

    References
    ----------
    .. [1] de Boor C : On calculating with b-splines, J. Approximation Theory
       6 (1972) 50-62.
    .. [2] Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths
       applics 10 (1972) 134-149.
    .. [3] Dierckx P. : Curve and surface fitting with splines, Monographs on
       Numerical Analysis, Oxford University Press, 1993.

    """
    t,c,k=tck
    try:
        c[0][0]
        parametric = True
    except:
        parametric = False
    if parametric:
        return _ntlist(map(lambda c,x=x,t=t,k=k:spalde(x,[t,c,k]),c))
    else:
        x = myasarray(x)
        if len(x)>1:
            return map(lambda x,tck=tck:spalde(x,tck),x)
        d,ier=_fitpack._spalde(t,c,k,x[0])
        if ier==0: return d
        if ier==10:
            raise TypeError,"Invalid input data. t(k)<=x<=t(n-k+1) must hold."
        raise TypeError,"Unknown error"
Exemplo n.º 3
0
def spalde(x, tck):
    """
    Evaluate all derivatives of a B-spline.

    Given the knots and coefficients of a cubic B-spline compute all
    derivatives up to order k at a point (or set of points).

    Parameters
    ----------
    tck : tuple
        A tuple (t,c,k) containing the vector of knots,
        the B-spline coefficients, and the degree of the spline.
    x : array_like
        A point or a set of points at which to evaluate the derivatives.
        Note that ``t(k) <= x <= t(n-k+1)`` must hold for each `x`.

    Returns
    -------
    results : array_like
        An array (or a list of arrays) containing all derivatives
        up to order k inclusive for each point x.

    See Also
    --------
    splprep, splrep, splint, sproot, splev, bisplrep, bisplev,
    UnivariateSpline, BivariateSpline

    References
    ----------
    .. [1] de Boor C : On calculating with b-splines, J. Approximation Theory
       6 (1972) 50-62.
    .. [2] Cox M.G. : The numerical evaluation of b-splines, J. Inst. Maths
       applics 10 (1972) 134-149.
    .. [3] Dierckx P. : Curve and surface fitting with splines, Monographs on
       Numerical Analysis, Oxford University Press, 1993.

    """
    t, c, k = tck
    try:
        c[0][0]
        parametric = True
    except:
        parametric = False
    if parametric:
        return _ntlist(map(lambda c, x=x, t=t, k=k: spalde(x, [t, c, k]), c))
    else:
        x = myasarray(x)
        if len(x) > 1:
            return map(lambda x, tck=tck: spalde(x, tck), x)
        d, ier = _fitpack._spalde(t, c, k, x[0])
        if ier == 0: return d
        if ier == 10:
            raise TypeError("Invalid input data. t(k)<=x<=t(n-k+1) must hold.")
        raise TypeError("Unknown error")
Exemplo n.º 4
0
def spalde(x,tck):
    """Evaluate all derivatives of a B-spline.

    Description:

      Given the knots and coefficients of a cubic B-spline compute all
      derivatives up to order k at a point (or set of points).

    Inputs:

      tck -- A length 3 sequence describing the given spline (See splev).
      x -- A point or a set of points at which to evaluate the derivatives.
           Note that t(k) <= x <= t(n-k+1) must hold for each x.

    Outputs: (results, )

      results -- An array (or a list of arrays) containing all derivatives
                 up to order k inclusive for each point x.

    See also:
      splprep, splrep, splint, sproot, splev - evaluation, roots, integral
      bisplrep, bisplev - bivariate splines
      UnivariateSpline, BivariateSpline - an alternative wrapping
              of the FITPACK functions
    Notes:
    Based on algorithms from:
        de Boor C : On calculating with b-splines, J. Approximation Theory
                    6 (1972) 50-62.
        Cox M.G.  : The numerical evaluation of b-splines, J. Inst. Maths
                    applics 10 (1972) 134-149.
       Dierckx P. : Curve and surface fitting with splines, Monographs on
                    Numerical Analysis, Oxford University Press, 1993.
    """
    t,c,k=tck
    try:
        c[0][0]
        parametric = True
    except:
        parametric = False
    if parametric:
        return _ntlist(map(lambda c,x=x,t=t,k=k:spalde(x,[t,c,k]),c))
    else:
        try: x=x.tolist()
        except:
            try: x=list(x)
            except: x=[x]
        if len(x)>1:
            return map(lambda x,tck=tck:spalde(x,tck),x)
        d,ier=_fitpack._spalde(t,c,k,x[0])
        if ier==0: return d
        if ier==10:
            raise TypeError,"Invalid input data. t(k)<=x<=t(n-k+1) must hold."
        raise TypeError,"Unknown error"
Exemplo n.º 5
0
def spalde(x,tck):
    """Evaluate all derivatives of a B-spline.

    Description:

      Given the knots and coefficients of a cubic B-spline compute all
      derivatives up to order k at a point (or set of points).

    Inputs:

      tck -- A length 3 sequence describing the given spline (See splev).
      x -- A point or a set of points at which to evaluate the derivatives.
           Note that t(k) <= x <= t(n-k+1) must hold for each x.

    Outputs: (results, )

      results -- An array (or a list of arrays) containing all derivatives
                 up to order k inclusive for each point x.

    See also:
      splprep, splrep, splint, sproot, splev - evaluation, roots, integral
      bisplrep, bisplev - bivariate splines
      UnivariateSpline, BivariateSpline - an alternative wrapping 
              of the FITPACK functions
    """
    t,c,k=tck
    try:
        c[0][0]
        parametric = True
    except:
        parametric = False
    if parametric:
        return _ntlist(map(lambda c,x=x,t=t,k=k:spalde(x,[t,c,k]),c))
    else:
      try: x=x.tolist()
      except:
          try: x=list(x)
          except: x=[x]
      if len(x)>1:
          return map(lambda x,tck=tck:spalde(x,tck),x)
      d,ier=_fitpack._spalde(t,c,k,x[0])
      if ier==0: return d
      if ier==10:
          raise TypeError,"Invalid input data. t(k)<=x<=t(n-k+1) must hold."
      raise TypeError,"Unknown error"