Class Gradient

java.lang.Object
org.wpilib.math.autodiff.Gradient
All Implemented Interfaces:
AutoCloseable

public class Gradient extends Object implements AutoCloseable
This class calculates the gradient of a variable with respect to a vector of variables.

The gradient is only recomputed if the variable expression is quadratic or higher order.

  • Constructor Details

    • Gradient

      public Gradient(Variable variable, Variable wrt)
      Constructs a Gradient object.
      Parameters:
      variable - Variable of which to compute the gradient.
      wrt - Variable with respect to which to compute the gradient.
    • Gradient

      public Gradient(Variable variable, VariableMatrix wrt)
      Constructs a Gradient object.
      Parameters:
      variable - Variable of which to compute the gradient.
      wrt - Vector of variables with respect to which to compute the gradient.
    • Gradient

      public Gradient(Variable variable, VariableBlock wrt)
      Constructs a Gradient object.
      Parameters:
      variable - Variable of which to compute the gradient.
      wrt - Vector of variables with respect to which to compute the gradient.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • get

      public VariableMatrix get()
      Returns the gradient as a VariableMatrix.

      This is useful when constructing optimization problems with derivatives in them.

      Returns:
      The gradient as a VariableMatrix.
    • value

      public org.ejml.simple.SimpleMatrix value()
      Evaluates the gradient at wrt's value.
      Returns:
      The gradient at wrt's value.