SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.functionfit.BSpline Class Reference

Represents a B-spline with control points at \((X_i, Y_i)\). More...

Inheritance diagram for umontreal.ssj.functionfit.BSpline:
umontreal.ssj.functions.MathFunction umontreal.ssj.functions.MathFunctionWithIntegral umontreal.ssj.functions.MathFunctionWithDerivative umontreal.ssj.functions.MathFunctionWithFirstDerivative umontreal.ssj.functions.MathFunction umontreal.ssj.functions.MathFunction umontreal.ssj.functions.MathFunction

Public Member Functions

 BSpline (final double[] x, final double[] y, final int degree)
 Constructs a new uniform B-spline of degree degree with control points at (x[i], y[i]).
 BSpline (final double[] x, final double[] y, final double[] knots)
 Constructs a new uniform B-spline with control points at (x[i], y[i]), and knot vector given by the array knots.
double[] getX ()
 Returns the \(X_i\) coordinates for this spline.
double[] getY ()
 Returns the \(Y_i\) coordinates for this spline.
double getMaxKnot ()
 Returns the knot maximal value.
double getMinKnot ()
 Returns the knot minimal value.
double[] getKnots ()
 Returns an array containing the knot vector \((t_0, t_{m-1})\).
BSpline derivativeBSpline ()
 Returns the derivative B-spline object of the current variable.
BSpline derivativeBSpline (int i)
 Returns the \(i\)th derivative B-spline object of the current variable; \(i\) must be less than the degree of the original B-spline.
double evaluate (final double u)
 Returns the value of the function evaluated at \(x\).
double integral (double a, double b)
 Computes (or estimates) the integral of the function over the interval \([a, b]\).
double derivative (double u)
 Computes (or estimates) the first derivative of the function at point x.
double derivative (double u, int n)
 Computes (or estimates) the \(n\)th derivative of the function at point x.

Static Public Member Functions

static BSpline createInterpBSpline (double[] x, double[] y, int degree)
 Returns a B-spline curve of degree degree interpolating the.
static BSpline createApproxBSpline (double[] x, double[] y, int degree, int hp1)
 Returns a B-spline curve of degree degree smoothing \((x_i, y_i)\), for \(i=0,…,n\) points.

Detailed Description

Represents a B-spline with control points at \((X_i, Y_i)\).

Let

\(\mathbf{P_i}=(X_i, Y_i)\), for \(i=0,…,n-1\), be a control point and let \(t_j\), for \(j=0,…,m-1\) be a knot. A B-spline [41]  of degree \(p=m-n-1\) is a parametric curve defined as

\[ \mathbf{P(t)} = \sum_{i=0}^{n-1} N_{i, p}(t) \mathbf{P_i},\mbox{ for }t_p\le t\le t_{m-p-1}. \]

Here,

\begin{align*} N_{i, p}(t) & = \frac{t-t_i}{t_{i+p} - t_i}N_{i, p-1}(t) + \frac{t_{i+p+1} - t}{t_{i+p+1} - t_{i+1}}N_{i+1, p-1}(t) \\ N_{i, 0}(t) & = \left\{ \begin{array}{ll} 1 & \mbox{ for }t_i\le t\le t_{i+1}, \\ 0 \mbox{ elsewhere}. \end{array} \right. \end{align*}

This class provides methods to evaluate \(\mathbf{P(t)}=(X(t), Y(t))\) at any value of \(t\), for a B-spline of any degree \(p\ge1\). Note that the evaluate(double) method of this class can be slow, since it uses a root finder to determine the value of \(t^*\) for which \(X(t^*)=x\) before it computes \(Y(t^*)\).

Definition at line 62 of file BSpline.java.

Constructor & Destructor Documentation

◆ BSpline() [1/2]

umontreal.ssj.functionfit.BSpline.BSpline ( final double[] x,
final double[] y,
final int degree )

Constructs a new uniform B-spline of degree degree with control points at (x[i], y[i]).

The knots of the resulting B-spline are set uniformly from x[0] to x[n-1].

Parameters
xthe values of \(X\).
ythe values of \(Y\).
degreethe degree of the B-spline.

Definition at line 86 of file BSpline.java.

◆ BSpline() [2/2]

umontreal.ssj.functionfit.BSpline.BSpline ( final double[] x,
final double[] y,
final double[] knots )

Constructs a new uniform B-spline with control points at (x[i], y[i]), and knot vector given by the array knots.

Parameters
xthe values of \(X\).
ythe values of \(Y\).
knotsthe knots of the B-spline.

Definition at line 103 of file BSpline.java.

Member Function Documentation

◆ createApproxBSpline()

BSpline umontreal.ssj.functionfit.BSpline.createApproxBSpline ( double[] x,
double[] y,
int degree,
int hp1 )
static

Returns a B-spline curve of degree degree smoothing \((x_i, y_i)\), for \(i=0,…,n\) points.

The precision depends on the parameter \(hp1\): \(1 \le\mathtt{degree} \le hp1<n\), which represents the number of control points used by the new B-spline curve, minimizing the quadratic error

\[ L = \sum_{i=0}^n\left( \frac{Y_i - S_i(X_i)}{W_i}\right)^2. \]

This method uses the uniformly spaced method for interpolating points with a B-spline curve and a uniformed clamped knot vector, as described in http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/.

Parameters
xthe values of \(X\).
ythe values of \(Y\).
degreethe degree of the B-spline.
hp1the desired number of control points.
Returns
the B-spline curve.

Definition at line 234 of file BSpline.java.

◆ createInterpBSpline()

BSpline umontreal.ssj.functionfit.BSpline.createInterpBSpline ( double[] x,
double[] y,
int degree )
static

Returns a B-spline curve of degree degree interpolating the.

\((x_i, y_i)\) points [41] . This method uses the uniformly spaced method for interpolating points with a B-spline curve, and a uniformed clamped knot vector, as described in http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/.

Parameters
xthe values of \(X\).
ythe values of \(Y\).
degreethe degree of the B-spline.
Returns
the B-spline curve.

Definition at line 172 of file BSpline.java.

◆ derivative() [1/2]

double umontreal.ssj.functionfit.BSpline.derivative ( double x)

Computes (or estimates) the first derivative of the function at point x.

Parameters
xthe point to evaluate the derivative to.
Returns
the value of the derivative.

Implements umontreal.ssj.functions.MathFunctionWithFirstDerivative.

Definition at line 388 of file BSpline.java.

◆ derivative() [2/2]

double umontreal.ssj.functionfit.BSpline.derivative ( double x,
int n )

Computes (or estimates) the \(n\)th derivative of the function at point x.

For \(n=0\), this returns the result of umontreal.ssj.functions.MathFunction.evaluate(double).

Parameters
xthe point to evaluate the derivate to.
nthe order of the derivative.
Returns
the resulting derivative.
Exceptions
IllegalArgumentExceptionif `n` is negative or 0.

Implements umontreal.ssj.functions.MathFunctionWithDerivative.

Definition at line 392 of file BSpline.java.

◆ derivativeBSpline() [1/2]

BSpline umontreal.ssj.functionfit.BSpline.derivativeBSpline ( )

Returns the derivative B-spline object of the current variable.

Using this function and the returned object, instead of the derivative method, is strongly recommended if one wants to compute many derivative values.

Returns
the derivative B-spline of the current variable.

Definition at line 322 of file BSpline.java.

◆ derivativeBSpline() [2/2]

BSpline umontreal.ssj.functionfit.BSpline.derivativeBSpline ( int i)

Returns the \(i\)th derivative B-spline object of the current variable; \(i\) must be less than the degree of the original B-spline.

Using this function and the returned object, instead of the derivative method, is strongly recommended if one wants to compute many derivative values.

Parameters
ithe degree of the derivative.
Returns
the ith derivative.

Definition at line 363 of file BSpline.java.

◆ evaluate()

double umontreal.ssj.functionfit.BSpline.evaluate ( final double x)

Returns the value of the function evaluated at \(x\).

Parameters
xvalue at which the function is evaluated
Returns
function evaluated at x

Implements umontreal.ssj.functions.MathFunction.

Definition at line 372 of file BSpline.java.

◆ getKnots()

double[] umontreal.ssj.functionfit.BSpline.getKnots ( )

Returns an array containing the knot vector \((t_0, t_{m-1})\).

Returns
the knot vector.

Definition at line 156 of file BSpline.java.

◆ getMaxKnot()

double umontreal.ssj.functionfit.BSpline.getMaxKnot ( )

Returns the knot maximal value.

Returns
the \(Y_i\) coordinates.

Definition at line 138 of file BSpline.java.

◆ getMinKnot()

double umontreal.ssj.functionfit.BSpline.getMinKnot ( )

Returns the knot minimal value.

Returns
the \(Y_i\) coordinates.

Definition at line 147 of file BSpline.java.

◆ getX()

double[] umontreal.ssj.functionfit.BSpline.getX ( )

Returns the \(X_i\) coordinates for this spline.

Returns
the \(X_i\) coordinates.

Definition at line 120 of file BSpline.java.

◆ getY()

double[] umontreal.ssj.functionfit.BSpline.getY ( )

Returns the \(Y_i\) coordinates for this spline.

Returns
the \(Y_i\) coordinates.

Definition at line 129 of file BSpline.java.

◆ integral()

double umontreal.ssj.functionfit.BSpline.integral ( double a,
double b )

Computes (or estimates) the integral of the function over the interval \([a, b]\).

Parameters
athe starting point of the interval.
bthe ending point of the interval.
Returns
the value of the integral.

Implements umontreal.ssj.functions.MathFunctionWithIntegral.

Definition at line 384 of file BSpline.java.


The documentation for this class was generated from the following file: