|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectvec_math.Polynom
public class Polynom
A representation of a polynomial of the form
p(x) = ∑aixThis class provides methods for setting the coefficients and evaluating the polynomial at a given value for x. Manipulation of the polynom is not intended, but may be added in subclasses.i
| Field Summary | |
|---|---|
private double[] |
a
The constants of the polynom. |
private double |
first
The value of the 1st derivative of the polynom at the last evaluation. |
private double |
oldx
The last x value the polynom was evaluated for. |
private double |
val
The value of the polynom at the last evaluation. |
| Constructor Summary | |
|---|---|
Polynom()
Constructs a new polynom. |
|
Polynom(double[] coef)
Constructs a new polynom. |
|
Polynom(String coef)
Constructs a new polynom. |
|
| Method Summary | |
|---|---|
private void |
calculate(double x)
Evaluates the polynom and its first derivative simultaneously. |
double |
derivative(double x)
Returns the value of the first derivative of the polynom at the given value x. |
double |
evaluate(double x)
Returns the value of the polynom for the given value of x. |
double[] |
getCoefficients()
Returns the coefficients. |
int |
getDegree()
Returns the degree of the polynom. |
boolean |
setCoefficients(double[] coef)
Sets the polynomial coefficients. |
boolean |
setCoefficients(String comma)
Sets the polynomial coefficients from a comma-separated list of doubles. |
String |
toString()
Returns a string description of the polynom. |
boolean |
valid()
Returns true if the coefficients of this polynom has been set. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private double[] a
private double oldx
private double val
private double first
| Constructor Detail |
|---|
public Polynom()
public Polynom(String coef)
public Polynom(double[] coef)
| Method Detail |
|---|
public boolean setCoefficients(double[] coef)
coef - The coefficients of the polynom as a double array.public boolean setCoefficients(String comma)
comma - A comma-separated striong holding the coefficients.public double[] getCoefficients()
public int getDegree()
public boolean valid()
public double evaluate(double x)
evaluate in interface Functionpublic double derivative(double x)
derivative in interface Derivativepublic String toString()
toString in class Objectprivate void calculate(double x)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||