Class FirstDegreePolynomialRootsEstimator


public class FirstDegreePolynomialRootsEstimator extends PolynomialRootsEstimator
Class to estimate the root of a first degree polynomial along with other polynomial properties. A first degree polynomial is defined by its parameters as p(x) = a * x + b, hence the polynomial can be simply be defined by an array of length 2 [b, a].
  • Field Details

    • EPS

      public static final double EPS
      Constant defining machine precision.
      See Also:
    • VALID_POLY_PARAMS_LENGTH

      public static final int VALID_POLY_PARAMS_LENGTH
      Number of parameters valid for a first degree polynomial.
      See Also:
    • realPolyParams

      private double[] realPolyParams
      Array containing parameters of a first degree polynomial.
  • Constructor Details

    • FirstDegreePolynomialRootsEstimator

      public FirstDegreePolynomialRootsEstimator()
      Empty constructor.
    • FirstDegreePolynomialRootsEstimator

      public FirstDegreePolynomialRootsEstimator(double[] polyParams)
      Constructor.
      Parameters:
      polyParams - Array containing polynomial parameters.
      Throws:
      IllegalArgumentException - Raised if the length of the provided array is not valid.
  • Method Details

    • setPolynomialParameters

      public void setPolynomialParameters(double[] polyParams) throws LockedException
      Set array of first degree polynomial parameters. A first degree polynomial is defined by p(x) = a * x + b, and the array must be provided as [b, a]. Note: This class only supports real polynomial parameters.
      Parameters:
      polyParams - Array containing polynomial parameters.
      Throws:
      LockedException - Raised if this instance is locked.
      IllegalArgumentException - Raised if the length of the provided array is not valid.
    • internalSetPolynomialParameters

      private void internalSetPolynomialParameters(double[] polyParams)
      Internal method to set array of first degree polynomial parameters. A first degree polynomial is defined by p(x) = a * x + b, and the array must be provided as [b, a]. Note: This class only supports real polynomial parameters. This method does not check if this instance is locked.
      Parameters:
      polyParams - Array containing polynomial parameters.
      Throws:
      IllegalArgumentException - Raised if the length of the provided array is not valid.
    • getRealPolynomialParameters

      public double[] getRealPolynomialParameters() throws NotAvailableException
      Returns array of first degree polynomial parameters. A first degree polynomial is defined by p(x) = a * x + b, and the array is returned as [b, a]. Note: This class only supports real polynomial parameters.
      Returns:
      Array of first degree polynomial parameters.
      Throws:
      NotAvailableException - if parameters are not available for retrieval.
    • arePolynomialParametersAvailable

      public boolean arePolynomialParametersAvailable()
      Returns boolean indicating whether REAL polynomial parameters have been provided and is available for retrieval. Note: This class only supports real polynomial parameters.
      Overrides:
      arePolynomialParametersAvailable in class PolynomialRootsEstimator
      Returns:
      True if available, false otherwise.
    • getPolynomialParameters

      public com.irurueta.algebra.Complex[] getPolynomialParameters() throws NotAvailableException
      This method will always raise a NotAvailableException because this class only supports REAL polynomial parameters.
      Overrides:
      getPolynomialParameters in class PolynomialRootsEstimator
      Returns:
      throws NotAvailableException.
      Throws:
      NotAvailableException - always throws this exception.
    • internalSetPolynomialParameters

      protected void internalSetPolynomialParameters(com.irurueta.algebra.Complex[] polyParams)
      This method will always raise an IllegalArgumentException because this class only supports REAL polynomial parameters.
      Specified by:
      internalSetPolynomialParameters in class PolynomialRootsEstimator
      Parameters:
      polyParams - Polynomial parameters.
    • estimate

      public void estimate() throws LockedException, NotReadyException
      Estimates the root of provided polynomial.
      Overrides:
      estimate in class RootEstimator
      Throws:
      LockedException - Raised if this instance is locked estimating a root.
      NotReadyException - Raised if this instance is not ready because polynomial parameters have not been provided.
    • isFirstDegree

      public static boolean isFirstDegree(double[] polyParams)
      Returns boolean indicating whether provided array of polynomial parameters correspond to a valid first degree polynomial. A first degree polynomial is defined by p(x) = a * x + b, and the array is returned as [b, a]. Note: This class only supports real polynomial parameters
      Parameters:
      polyParams - Array containing polynomial parameters
      Returns:
      True if is a first degree polynomial, false otherwise
    • isFirstDegree

      public boolean isFirstDegree() throws NotReadyException
      Returns boolean indicating whether polynomial parameters provided to this instance correspond to a valid first degree polynomial. A first degree polynomial is defined by p(x) = a * x + b, and the array is returned as [b, a]. Note: This class only supports real polynomial parameters.
      Returns:
      True if is a first degree polynomial, false otherwise.
      Throws:
      NotReadyException - Raised if this instance is not ready because an array of polynomial parameters has not yet been provided.
    • isRealSolution

      public boolean isRealSolution()
      Returns boolean indicating whether estimated root is real. Because this class only accepts real polynomial parameters, then the estimated root will always be real, and consequently this method always returns true.
      Returns:
      True if estimated root is real, false otherwise.
    • solveLinear

      private double solveLinear(double a, double b)
      Internal method to estimate a root on a first degree polynomial.
      Parameters:
      a - A parameter.
      b - B parameter.
      Returns:
      Root.