org.geotools.math
Class Polynom

java.lang.Object
  extended byorg.geotools.math.Polynom
All Implemented Interfaces:
java.io.Serializable

public class Polynom
extends java.lang.Object
implements java.io.Serializable

The coefficients of a polynomial equation. The equation must be in the form y = c0 + c1×x + c2×x2 + c3×x3 + ... + cn×xn. The static method roots(double[]) can be used for computing the root of a polynomial equation without creating a object.

Since:
2.0
Version:
$Id: Polynom.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Ken Turkiwski, Martin Desruisseaux
See Also:
Serialized Form

Constructor Summary
Polynom(double[] c)
          Construct a polynom with the specified coefficients.
 
Method Summary
 boolean equals(java.lang.Object object)
          Compare this polynom with the specified object for equality.
 int hashCode()
          Returns a hash value for this polynom.
static void main(java.lang.String[] c)
          Display to the standard output the roots of a polynomial equation.
 double[] roots()
          Find the roots of this polynome.
static double[] roots(double[] c)
          Find the roots of a polynomial equation.
 java.lang.String toString()
          Returns a string representation of this polynom.
 double y(double x)
          Evaluate this polynomial equation for the specified x value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Polynom

public Polynom(double[] c)
Construct a polynom with the specified coefficients.

Parameters:
c - The coefficients. This array is copied.
Method Detail

y

public final double y(double x)
Evaluate this polynomial equation for the specified x value. More specifically, this method compute c0 + c1×x + c2×x2 + c3×x3 + ... + cn×xn.


roots

public double[] roots()
Find the roots of this polynome.

Returns:
The roots.

roots

public static double[] roots(double[] c)
Find the roots of a polynomial equation. More specifically, this method solve the following equation:
c[0] + c[1]*x + c[2]*x2 + c[3]*x3 + ... + c[n]*xn == 0
where n is the array length minus 1.

Parameters:
c - The coefficients for the polynomial equation.
Returns:
The roots. This array may have any length up to .
Throws:
java.lang.UnsupportedOperationException - if there is more coefficients than this method can handle.

main

public static void main(java.lang.String[] c)
Display to the standard output the roots of a polynomial equation. More specifically, this method solve the following equation:
c[0] + c[1]*x + c[2]*x2 + c[3]*x3 + ... + c[n]*xn == 0
where n is the array length minus 1.

Parameters:
c - The coefficients for the polynomial equation.

hashCode

public int hashCode()
Returns a hash value for this polynom.


equals

public boolean equals(java.lang.Object object)
Compare this polynom with the specified object for equality.


toString

public java.lang.String toString()
Returns a string representation of this polynom.



Copyright © GeoTools. All Rights Reserved.