Class FiniteDifferenceMatrixBuilder
java.lang.Object
net.finmath.finitedifference.solvers.FiniteDifferenceMatrixBuilder
Builds finite difference matrices for approximating the first and second
derivatives of a function sampled on a (possibly) non-uniform grid.
The matrices returned by this class are linear operators which, when applied
to a vector of function values f(x_i), approximate f'(x_i)
and
f''(x_i) at the grid points x_i.
The implementation uses
- forward differences at the first node,
- backward differences at the last node,
- central differences at internal nodes.
- Author:
- Alessandro Gnoatto
-
Constructor Summary
ConstructorsConstructorDescriptionFiniteDifferenceMatrixBuilder(double[] x) Constructs a finite difference matrix builder for the given grid. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.commons.math3.linear.RealMatrixReturns the finite difference matrix for the first derivative.org.apache.commons.math3.linear.RealMatrixReturns the finite difference matrix for the second derivative.
-
Constructor Details
-
FiniteDifferenceMatrixBuilder
public FiniteDifferenceMatrixBuilder(double[] x) Constructs a finite difference matrix builder for the given grid.- Parameters:
x- Array of grid points.
-
-
Method Details
-
getFirstDerivativeMatrix
public org.apache.commons.math3.linear.RealMatrix getFirstDerivativeMatrix()Returns the finite difference matrix for the first derivative.- Returns:
- The matrix representing the first derivative operator.
-
getSecondDerivativeMatrix
public org.apache.commons.math3.linear.RealMatrix getSecondDerivativeMatrix()Returns the finite difference matrix for the second derivative.- Returns:
- The matrix representing the second derivative operator.
-