Class NumericalJacobianFB

java.lang.Object
org.ddogleg.optimization.derivative.NumericalJacobianFB
All Implemented Interfaces:
FunctionInOut, FunctionNtoMxN<DMatrixRMaj>

public class NumericalJacobianFB
extends Object
implements FunctionNtoMxN<DMatrixRMaj>
Finite difference numerical jacobian calculation using the forward+backwards equation. Difference equation, f'(x) = (f(x+h)-f(x-h))/(2*h). Scaling is taken in account by h based upon the magnitude of the elements in variable x.

NOTE: If multiple input parameters are modified by the function when a single one is changed numerical derivatives aren't reliable.

  • Constructor Details

    • NumericalJacobianFB

      public NumericalJacobianFB​(FunctionNtoM function, double differenceScale)
    • NumericalJacobianFB

      public NumericalJacobianFB​(FunctionNtoM function)
  • Method Details

    • getNumOfInputsN

      public int getNumOfInputsN()
      Description copied from interface: FunctionInOut
      Number of input elements. Typically the parameters you are optimizing.
      Specified by:
      getNumOfInputsN in interface FunctionInOut
      Returns:
      number of input elements
    • getNumOfOutputsM

      public int getNumOfOutputsM()
      Description copied from interface: FunctionInOut
      Number of output elements. Typically the functions that are being optimized.
      Specified by:
      getNumOfOutputsM in interface FunctionInOut
      Returns:
      number of output elements
    • process

      public void process​(double[] input, DMatrixRMaj jacobian)
      Description copied from interface: FunctionNtoMxN

      Processes the input vector to output a 2D a matrix. The matrix has a dimension of M rows and N columns and is formatted as a row major 1D-array.

      The user can modify the input parameters here and the optimizer must use those changes.

      Specified by:
      process in interface FunctionNtoMxN<DMatrixRMaj>
      Parameters:
      input - Vector with input parameters.
      jacobian - Row major array with M rows and N columns.
    • declareMatrixMxN

      public DMatrixRMaj declareMatrixMxN()
      Description copied from interface: FunctionNtoMxN
      Creates a matrix which can store the jacobian. Size is set by M and N
      Specified by:
      declareMatrixMxN in interface FunctionNtoMxN<DMatrixRMaj>
      Returns:
      new instance of a matrix