Beispiel #1
0
    def __call__(self, x, nu=None):
        """ Evaluate spline (or its nu-th derivative) at positions x.
        Note: x can be unordered but the evaluation is more efficient
        if x is (partially) ordered.

        """
        if nu is None:
            return dfitpack.splev(*(self._eval_args+(x,)))
        return dfitpack.splder(nu=nu,*(self._eval_args+(x,)))
Beispiel #2
0
    def __call__(self, x, nu=None):
        """ Evaluate spline (or its nu-th derivative) at positions x.
        Note: x can be unordered but the evaluation is more efficient
        if x is (partially) ordered.

        """
        if nu is None:
            return dfitpack.splev(*(self._eval_args+(x,)))
        return dfitpack.splder(nu=nu,*(self._eval_args+(x,)))
Beispiel #3
0
def splev(x,tck,der=0):
    """Evaulate a B-spline and its derivatives.

    Description:
      Given the knots and coefficients of a B-spline representation, evaluate
      the value of the smoothing polynomial and it's derivatives.
      This is a wrapper around the FORTRAN routines splev and splder of FITPACK.

    Inputs:
      x (u) -- a 1-D array of points at which to return the value of the
               smoothed spline or its derivatives.  If tck was returned from
               splprep, then the parameter values, u should be given.
      tck -- A sequence of length 3 returned by splrep or splprep containg the
             knots, coefficients, and degree of the spline.
      der -- The order of derivative of the spline to compute (must be less than
             or equal to k).

    Outputs: (y, )
      y -- an array of values representing the spline function or curve.
           If tck was returned from splrep, then this is a list of arrays
           representing the curve in N-dimensional space.

    See also:
      splprep, splrep, sproot, spalde, splint - evaluation, roots, integral
      bisplrep, bisplev - bivariate splines
      UnivariateSpline, BivariateSpline - an alternative wrapping
              of the FITPACK functions
    """
    t,c,k=tck
    try:
        c[0][0] # check if c is >1-d
        parametric = True # it is
    except TypeError: parametric = False # c is 1-d
    if parametric:
        return map(lambda c,x=x,t=t,k=k,der=der:splev(x,[t,c,k],der),c)
    else:
        if not (0<=der<=k):
            raise ValueError,"0<=der=%d<=k=%d must hold"%(der,k)
        x=myasarray(x)
        c = c.copy()
        c.resize(len(t))
        if (der>0):
            y,ier=dfitpack.splder(t,c,k,x,der)
        else:
            y,ier=dfitpack.splev(t,c,k,x)
        if ier==10: raise ValueError,"Invalid input data"
        if ier: raise TypeError,"An unkown error occurred"
        if len(y)>1: return y
        return y[0]