Add antiderivative
@@ -767,6 +767,46 @@ class BSpline:
return self.construct_fast(*tck, extrapolate=self.extrapolate,
axis=self.axis)
+ def antiderivative(self, nu=1):
+ """
+ Return a B-spline representing the antiderivative.
+
+ Parameters
+ ----------
+ nu : int, optional
+ Antiderivative order. Default is 1.
+
+ Returns
+ -------
+ b : BSpline object
+ A new instance representing the antiderivative.
+
+ Notes
+ -----
+ If antiderivative is computed and ``self.extrapolate='periodic'``,
+ it will be set to False for the returned instance. This is done because
+ the antiderivative is no longer periodic and its correct evaluation
+ outside of the initially given x interval is difficult.
+
+ See Also
+ --------
+ splder, splantider
+ """
+ c = self.c
+ # pad the c array if needed
+ ct = len(self.t) - len(c)
+ if ct > 0:
+ c = cupy.r_[c, cupy.zeros((ct,) + c.shape[1:])]
+ tck = splantider((self.t, c, self.k), nu)
+
+ if self.extrapolate == 'periodic':
+ extrapolate = False
+ else:
+ extrapolate = self.extrapolate
+
+ return self.construct_fast(*tck, extrapolate=extrapolate,
+ axis=self.axis)
+
def integrate(self, a, b, extrapolate=None):
"""
Compute a definite integral of the spline.
