|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object becker.xtras.grapher.SamplePolynomialFunction
public final class SamplePolynomialFunction
A sample class implementing the IPolynomialFunction
interface. It
calculates values of a polynomial function.
Please see the package description for a more in-depth discussion of using this class.
Constructor Summary | |
---|---|
SamplePolynomialFunction(int deg)
Create a sample polynomial function with the given degree. |
Method Summary | |
---|---|
void |
addView(IView aView)
Add a view (graphical user interface) to the function. |
double |
eval(double x)
Evaluate the function for a given value of x. |
double[] |
getCoefficients()
Get the coefficients for this polynomial. |
int |
getDegree()
Get the degree of this polynomial. |
double[] |
getYValues(double minX,
double maxX,
int num)
Get evenly distributed values for f(x) for all the values of x between minX and maxX. |
void |
setCoefficients(double[] coefs)
Set the coefficients for this polynomial. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SamplePolynomialFunction(int deg)
deg
- The degree of the leading term in the polynomial.Method Detail |
---|
public double eval(double x)
IPolynomialFunction
eval
in interface IPolynomialFunction
x
- The value for which the function should be evaluated.public int getDegree()
IPolynomialFunction
y = 5*x^3 + 2*x^2 + 0*x + 5
is 3
.
getDegree
in interface IPolynomialFunction
public void setCoefficients(double[] coefs)
IPolynomialFunction
setCoefficients
in interface IPolynomialFunction
coefs
- the coefficients to the polynomial such that ai
appears in coef[i]
.public double[] getCoefficients()
IPolynomialFunction
getCoefficients
in interface IPolynomialFunction
public double[] getYValues(double minX, double maxX, int num)
IPolynomialFunction
getYValues
in interface IPolynomialFunction
minX
- The smallest value of x; must be less than maxX.maxX
- The largest value of x.num
- The number of values to return; must be positive.
public void addView(IView aView)
IPolynomialFunction
updateView
method must be called each time the function's state changes.
addView
in interface IPolynomialFunction
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |