Package com.irurueta.numerical.roots
Class FirstDegreePolynomialRootsEstimator
java.lang.Object
com.irurueta.numerical.roots.RootEstimator
com.irurueta.numerical.roots.PolynomialRootsEstimator
com.irurueta.numerical.roots.FirstDegreePolynomialRootsEstimator
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Constant defining machine precision.private double[]
Array containing parameters of a first degree polynomial.static final int
Number of parameters valid for a first degree polynomial.Fields inherited from class com.irurueta.numerical.roots.PolynomialRootsEstimator
polyParams, roots
Fields inherited from class com.irurueta.numerical.roots.RootEstimator
locked
-
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.FirstDegreePolynomialRootsEstimator
(double[] polyParams) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns boolean indicating whether REAL polynomial parameters have been provided and is available for retrieval.void
estimate()
Estimates the root of provided polynomial.com.irurueta.algebra.Complex[]
This method will always raise a NotAvailableException because this class only supports REAL polynomial parameters.double[]
Returns array of first degree polynomial parameters.private void
internalSetPolynomialParameters
(double[] polyParams) Internal method to set array of first degree polynomial parameters.protected void
internalSetPolynomialParameters
(com.irurueta.algebra.Complex[] polyParams) This method will always raise an IllegalArgumentException because this class only supports REAL polynomial parameters.boolean
Returns boolean indicating whether polynomial parameters provided to this instance correspond to a valid first degree polynomial.static boolean
isFirstDegree
(double[] polyParams) Returns boolean indicating whether provided array of polynomial parameters correspond to a valid first degree polynomial.boolean
Returns boolean indicating whether estimated root is real.void
setPolynomialParameters
(double[] polyParams) Set array of first degree polynomial parameters.private double
solveLinear
(double a, double b) Internal method to estimate a root on a first degree polynomial.Methods inherited from class com.irurueta.numerical.roots.PolynomialRootsEstimator
areRootsAvailable, getRoots, isReady, setPolynomialParameters
Methods inherited from class com.irurueta.numerical.roots.RootEstimator
isLocked
-
Field Details
-
EPS
public static final double EPSConstant defining machine precision.- See Also:
-
VALID_POLY_PARAMS_LENGTH
public static final int VALID_POLY_PARAMS_LENGTHNumber of parameters valid for a first degree polynomial.- See Also:
-
realPolyParams
private double[] realPolyParamsArray 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
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
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 classPolynomialRootsEstimator
- Returns:
- True if available, false otherwise.
-
getPolynomialParameters
This method will always raise a NotAvailableException because this class only supports REAL polynomial parameters.- Overrides:
getPolynomialParameters
in classPolynomialRootsEstimator
- 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 classPolynomialRootsEstimator
- Parameters:
polyParams
- Polynomial parameters.
-
estimate
Estimates the root of provided polynomial.- Overrides:
estimate
in classRootEstimator
- 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
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.
-