Package org.opensourcephysics.tools
Class KnownPolynomial
java.lang.Object
org.opensourcephysics.numerics.Polynomial
org.opensourcephysics.numerics.PolynomialLeastSquareFit
org.opensourcephysics.tools.KnownPolynomial
- All Implemented Interfaces:
Function
,KnownFunction
A polynomial that implements KnownFunction. Limited to degree 5 or less.
-
Field Summary
Fields inherited from class org.opensourcephysics.numerics.Polynomial
coefficients
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Gets a clone of this function.boolean
Determines if another KnownFunction is the same as this one.Gets the description of the function.getExpression
(String indepVarName) Gets the expression.getName()
Gets the name of the function.int
Gets the parameter count.getParameterDescription
(int i) Gets a parameter description.getParameterName
(int i) Gets a parameter name.double
getParameterValue
(int i) Gets a parameter value.newUserFunction
(String var) void
setDescription
(String aDescription) Sets the description of the function.void
Sets the name of the function.void
setParameters
(String[] names, double[] values, String[] descriptions) Sets the parameters.void
setParameterValue
(int i, double value) Sets a parameter value.toString()
Converts this polynomial to a String.Methods inherited from class org.opensourcephysics.numerics.PolynomialLeastSquareFit
computeCoefficients, fitData
Methods inherited from class org.opensourcephysics.numerics.Polynomial
add, add, coefficient, deflate, degree, derivative, divide, divide, divideWithRemainder, evalPolynomial, evaluate, getCoefficients, integral, integral, multiply, multiply, roots, rootsReal, subtract, subtract, valueAndDerivative
-
Constructor Details
-
KnownPolynomial
public KnownPolynomial(double[] coeffs)
-
-
Method Details
-
getParameterCount
public int getParameterCount()Gets the parameter count.- Specified by:
getParameterCount
in interfaceKnownFunction
- Returns:
- the number of parameters
-
getParameterName
Gets a parameter name.- Specified by:
getParameterName
in interfaceKnownFunction
- Parameters:
i
- the parameter index- Returns:
- the name of the parameter
-
getParameterDescription
Gets a parameter description. May be null.- Specified by:
getParameterDescription
in interfaceKnownFunction
- Parameters:
i
- the parameter index- Returns:
- the description of the parameter (may be null)
-
getParameterValue
public double getParameterValue(int i) Gets a parameter value.- Specified by:
getParameterValue
in interfaceKnownFunction
- Parameters:
i
- the parameter index- Returns:
- the value of the parameter
-
setParameterValue
public void setParameterValue(int i, double value) Sets a parameter value.- Specified by:
setParameterValue
in interfaceKnownFunction
- Parameters:
i
- the parameter indexvalue
- the value
-
setParameters
Sets the parameters.- Specified by:
setParameters
in interfaceKnownFunction
- Parameters:
names
- the parameter names (may be null)values
- the parameter values (may be null)descriptions
- the parameter descriptions (may be null)
-
getExpression
Gets the expression.- Specified by:
getExpression
in interfaceKnownFunction
- Parameters:
indepVarName
- the name of the independent variable- Returns:
- the equation expression
-
getName
Gets the name of the function.- Specified by:
getName
in interfaceKnownFunction
- Returns:
- the name
-
setName
Sets the name of the function.- Specified by:
setName
in interfaceKnownFunction
- Parameters:
aName
- the name
-
getDescription
Gets the description of the function.- Specified by:
getDescription
in interfaceKnownFunction
- Returns:
- the description
-
setDescription
Sets the description of the function.- Specified by:
setDescription
in interfaceKnownFunction
- Parameters:
aDescription
- the description
-
clone
Gets a clone of this function.- Specified by:
clone
in interfaceKnownFunction
- Overrides:
clone
in classObject
- Returns:
- the clone
-
equals
Determines if another KnownFunction is the same as this one.- Specified by:
equals
in interfaceKnownFunction
- Overrides:
equals
in classObject
- Parameters:
f
- the KnownFunction to test- Returns:
- true if equal
-
toString
Description copied from class:Polynomial
Converts this polynomial to a String.- Overrides:
toString
in classPolynomial
-
newUserFunction
- Specified by:
newUserFunction
in interfaceKnownFunction
-