org.jscience.mathematics.analysis.polynomials
Class ExactRealPolynomial

java.lang.Object
  extended by org.jscience.mathematics.analysis.ExactRealFunction
      extended by org.jscience.mathematics.analysis.polynomials.ExactRealPolynomial
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Field.Member, Ring.Member, AbelianGroup.Member, AbstractMapping, C1Function, NumberMapping, Polynomial, Member

public class ExactRealPolynomial
extends ExactRealFunction
implements Polynomial, java.io.Serializable, java.lang.Cloneable

A Polynomial as a Ring.Member over a realField

See Also:
Serialized Form

Field Summary
static ExactRealPolynomial ONE
          The real polynomial representing the multiplicative identity.
static ExactRealPolynomial ZERO
          The real polynomial representing the additive identity.
 
Constructor Summary
ExactRealPolynomial(ExactReal[] coeff)
          Creates a new instance of ExactRealPolynomial, polynom is always simplified discarding every trailing zeros and array copied (but not contents of elements).
ExactRealPolynomial(ExactReal d, int degree)
          Simple constructor.
ExactRealPolynomial(ExactRealPolynomial polynomial)
          Creates a new instance of ExactRealPolynomial, polynom is always simplified discarding every trailing zeros.
ExactRealPolynomial(Field.Member[] f)
          Creates a new ExactRealPolynomial object, polynom is always simplified discarding every trailing zeros and array copied (but not contents of elements).
 
Method Summary
 ExactRealFunction add(ExactRealFunction g)
          The group composition law.
 java.lang.Object clone()
           
 int degree()
          The degree understood as the number of coeffiecients, and therefore the highest degree is degree()-1
 ExactRealFunction differentiate()
          Differentiate the real polynomial.
 boolean equals(java.lang.Object o)
          Is this-o == Null ?
 ExactRealPolynomial[] euclidianDivision(ExactRealPolynomial divisor)
          Perform the euclidian division of two polynomials.
 Field.Member getCoefficient(int n)
          Get the coefficient of degree k, i.e.
 ExactReal getCoefficientAsExactReal(int n)
          Get the coefficient of degree k, i.e.
 Field.Member[] getCoefficients()
          Get the coefficients as an array
 ExactReal[] getCoefficientsAsExactReals()
          Get the coefficients as an array of ExactReals
 java.lang.Object getSet()
           
 int hashCode()
          Some kind of hashcode...
 ExactRealPolynomial integrate()
          "inverse" operation for differentiate
 boolean isOne()
          Returns true if this polynomial is equal to one.
 boolean isZero()
          Returns true if this polynomial is equal to zero.
 ExactReal map(ExactReal x)
          Evaluates this polynomial.
 ExactRealFunction multiply(ExactRealFunction r)
          The multiplication law.
 AbelianGroup.Member negate()
          Returns the inverse member.
 ExactRealPolynomial scalarDivide(ExactReal a)
          return a new real Polynomial with coefficients divided by a
 Polynomial scalarDivide(Field.Member f)
          return a new real Polynomial with coefficients divided by f
 ExactRealPolynomial scalarMultiply(ExactReal a)
          Returns the multiplication of this polynomial by a scalar
 Polynomial scalarMultiply(Field.Member f)
          Returns the multiplication of this polynomial by a scalar
 void setCoefficient(int n, Field.Member c)
          DOCUMENT ME!
 void setCoefficientAsExactReal(int n, ExactReal c)
          DOCUMENT ME!
 ExactRealFunction subtract(ExactRealFunction g)
          The group composition law with inverse.
 ExactComplexPolynomial toExactComplexPolynomial()
           
 java.lang.String toString()
          String representation P(x) = a_k x^k +...
 java.lang.String toString(java.lang.String unknown)
          String representation P(x) = a_k x^k +...
 
Methods inherited from class org.jscience.mathematics.analysis.ExactRealFunction
add, compose, divide, divide, getIntervalsList, inverse, map, multiply, setIntervalsList, subtract, taylorExpand, tensor
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jscience.mathematics.algebraic.fields.Ring.Member
multiply
 
Methods inherited from interface org.jscience.mathematics.algebraic.groups.AbelianGroup.Member
add, subtract
 

Field Detail

ZERO

public static final ExactRealPolynomial ZERO
The real polynomial representing the additive identity.


ONE

public static final ExactRealPolynomial ONE
The real polynomial representing the multiplicative identity.

Constructor Detail

ExactRealPolynomial

public ExactRealPolynomial(ExactReal[] coeff)
Creates a new instance of ExactRealPolynomial, polynom is always simplified discarding every trailing zeros and array copied (but not contents of elements).

Parameters:
coeff - DOCUMENT ME!
Throws:
java.lang.NullPointerException - DOCUMENT ME!

ExactRealPolynomial

public ExactRealPolynomial(ExactRealPolynomial polynomial)
Creates a new instance of ExactRealPolynomial, polynom is always simplified discarding every trailing zeros.

Parameters:
polynomial - DOCUMENT ME!

ExactRealPolynomial

public ExactRealPolynomial(Field.Member[] f)
Creates a new ExactRealPolynomial object, polynom is always simplified discarding every trailing zeros and array copied (but not contents of elements).

Parameters:
f -
Throws:
java.lang.NullPointerException - DOCUMENT ME!
java.lang.IllegalArgumentException - DOCUMENT ME!

ExactRealPolynomial

public ExactRealPolynomial(ExactReal d,
                           int degree)
Simple constructor. Build a one term polynomial from one coefficient and the corresponding degree.

Parameters:
d - coefficient
degree - degree associated with the coefficient
Method Detail

getCoefficient

public Field.Member getCoefficient(int n)
Get the coefficient of degree k, i.e. a_k if P(x) := sum_{k=0}^n a_k x^k

Specified by:
getCoefficient in interface Polynomial
Parameters:
n - degree
Returns:
coefficient as described above

getCoefficientAsExactReal

public ExactReal getCoefficientAsExactReal(int n)
Get the coefficient of degree k, i.e. a_k if P(x) := sum_{k=0}^n a_k x^k as a real number

Parameters:
n - degree
Returns:
coefficient as described above

getCoefficients

public Field.Member[] getCoefficients()
Get the coefficients as an array

Specified by:
getCoefficients in interface Polynomial
Returns:
the coefficients as an array

getCoefficientsAsExactReals

public ExactReal[] getCoefficientsAsExactReals()
Get the coefficients as an array of ExactReals

Returns:
the coefficients as an array

setCoefficient

public void setCoefficient(int n,
                           Field.Member c)
DOCUMENT ME!

Parameters:
n -

setCoefficientAsExactReal

public void setCoefficientAsExactReal(int n,
                                      ExactReal c)
DOCUMENT ME!

Parameters:
n -

map

public ExactReal map(ExactReal x)
Evaluates this polynomial.

Specified by:
map in class ExactRealFunction
Parameters:
x - DOCUMENT ME!
Returns:
DOCUMENT ME!

degree

public int degree()
The degree understood as the number of coeffiecients, and therefore the highest degree is degree()-1

Specified by:
degree in interface Polynomial
Returns:
the degree

getSet

public java.lang.Object getSet()

isZero

public boolean isZero()
Returns true if this polynomial is equal to zero. All coefficients are tested for |a_k| < GlobalSettings.ZERO_TOL.

Returns:
true if all coefficients < GlobalSettings.ZERO_TOL

isOne

public boolean isOne()
Returns true if this polynomial is equal to one. It is tested, whether |a_0 - 1| <= GlobalSettings.ZERO_TOL and the remaining coefficients are |a_k| < GlobalSettings.ZERO_TOL.

Returns:
true if this is equal to one.

add

public ExactRealFunction add(ExactRealFunction g)
The group composition law. Returns a new polynom with grade = max( this.degree, g.degree)

Overrides:
add in class ExactRealFunction
Parameters:
g - a group member
Returns:
DOCUMENT ME!

differentiate

public ExactRealFunction differentiate()
Differentiate the real polynomial. Only useful iff the polynomial is built over a banach space and an appropriate multiplication law is provided.

Specified by:
differentiate in interface C1Function
Specified by:
differentiate in class ExactRealFunction
Returns:
a new polynomial with degree = max(this.degree-1 , 0)

scalarDivide

public Polynomial scalarDivide(Field.Member f)
return a new real Polynomial with coefficients divided by f

Specified by:
scalarDivide in interface Polynomial
Parameters:
f - divisor
Returns:
new Polynomial with coefficients /= f
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarDivide

public ExactRealPolynomial scalarDivide(ExactReal a)
return a new real Polynomial with coefficients divided by a

Parameters:
a - divisor
Returns:
new Polynomial with coefficients /= a

equals

public boolean equals(java.lang.Object o)
Is this-o == Null ?

Overrides:
equals in class java.lang.Object
Parameters:
o - the other polynomial
Returns:
true if so

hashCode

public int hashCode()
Some kind of hashcode... (Since I have an equals)

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode

integrate

public ExactRealPolynomial integrate()
"inverse" operation for differentiate

Returns:
the integrated polynomial

scalarMultiply

public Polynomial scalarMultiply(Field.Member f)
Returns the multiplication of this polynomial by a scalar

Specified by:
scalarMultiply in interface Polynomial
Parameters:
f -
Returns:
DOCUMENT ME!
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

scalarMultiply

public ExactRealPolynomial scalarMultiply(ExactReal a)
Returns the multiplication of this polynomial by a scalar

Parameters:
a - factor
Returns:
new Polynomial with coefficients = a

multiply

public ExactRealFunction multiply(ExactRealFunction r)
The multiplication law. Multiplies this Polynomial with another

Overrides:
multiply in class ExactRealFunction
Parameters:
r - a RealFunction
Returns:
a new Polynomial with grade = max( this.grade, r.grade) + min( this.grade, r.grade) -1
Throws:
java.lang.IllegalArgumentException - DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the inverse member. (That is mult(-1))

Specified by:
negate in interface AbelianGroup.Member
Overrides:
negate in class ExactRealFunction
Returns:
inverse

subtract

public ExactRealFunction subtract(ExactRealFunction g)
The group composition law with inverse.

Overrides:
subtract in class ExactRealFunction
Parameters:
g - a group member
Returns:
DOCUMENT ME!

toString

public java.lang.String toString()
String representation P(x) = a_k x^k +...

Overrides:
toString in class java.lang.Object
Returns:
String

toString

public java.lang.String toString(java.lang.String unknown)
String representation P(x) = a_k x^k +...

Parameters:
unknown - The name of the unkwown
Returns:
String

euclidianDivision

public ExactRealPolynomial[] euclidianDivision(ExactRealPolynomial divisor)
Perform the euclidian division of two polynomials.

Parameters:
divisor - denominator polynomial
Returns:
an array of two elements containing the quotient and the remainder of the division

toExactComplexPolynomial

public ExactComplexPolynomial toExactComplexPolynomial()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object