JSci.maths.polynomials
Class RealPolynomial

java.lang.Object
  extended by JSci.maths.analysis.RealFunction
      extended by JSci.maths.polynomials.RealPolynomial
All Implemented Interfaces:
java.io.Serializable, Ring.Member, AbelianGroup.Member, Mapping, Member, Polynomial

public class RealPolynomial
extends RealFunction
implements Polynomial

A Polynomial as a Ring.Member over a real Field

See Also:
Serialized Form

Constructor Summary
RealPolynomial(double[] coeff)
          Creates a new instance of RealPolynomial
RealPolynomial(Field.Member[] f)
          Creates a new RealPolynomial object.
 
Method Summary
 RealFunction add(RealFunction g)
          The group composition law.
 int degree()
          The degree
 RealFunction differentiate()
          Differentiate the real polynomial.
 boolean equals(java.lang.Object o)
          Returns true if this polynomial is equal to another.
 Field.Member getCoefficient(int k)
          Get the coefficient of degree k, i.e.
 double getCoefficientAsDouble(int k)
          Get the coefficient of degree k, i.e.
 Field.Member[] getCoefficients()
          Get the coefficients as an array
 double[] getCoefficientsAsDoubles()
          Get the coefficients as an array of doubles
 java.lang.Object getSet()
           
 int hashCode()
          Some kind of hashcode...
 RealPolynomial 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.
 double map(double x)
          Evaluates this polynomial.
 RealFunction multiply(RealFunction r)
          The multiplication law.
 AbelianGroup.Member negate()
          Returns the inverse member.
 RealPolynomial scalarDivide(double 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
 RealPolynomial scalarMultiply(double a)
          Returns the multiplication of this polynomial by a scalar
 Polynomial scalarMultiply(Field.Member f)
          Returns the multiplication of this polynomial by a scalar
 RealFunction subtract(RealFunction g)
          The group composition law with inverse.
 java.lang.String toString()
          String representation P(x) = a_k x^k +...
 
Methods inherited from class JSci.maths.analysis.RealFunction
add, compose, constant, dimension, divide, divide, inverse, multiply, subtract, taylorExpand, tensor
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface JSci.maths.fields.Ring.Member
multiply
 
Methods inherited from interface JSci.maths.groups.AbelianGroup.Member
add, subtract
 

Constructor Detail

RealPolynomial

public RealPolynomial(double[] coeff)
Creates a new instance of RealPolynomial


RealPolynomial

public RealPolynomial(Field.Member[] f)
Creates a new RealPolynomial object.

Parameters:
f -
Method Detail

getCoefficient

public Field.Member getCoefficient(int k)
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:
k - degree
Returns:
coefficient as described above

getCoefficientAsDouble

public double getCoefficientAsDouble(int k)
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:
k - 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

getCoefficientsAsDoubles

public double[] getCoefficientsAsDoubles()
Get the coefficients as an array of doubles

Returns:
the coefficients as an array

map

public double map(double x)
Evaluates this polynomial.

Specified by:
map in interface Mapping

degree

public int degree()
The degree

Specified by:
degree in interface Polynomial
Returns:
the degree

getSet

public java.lang.Object getSet()
Specified by:
getSet in interface Member
Overrides:
getSet in class RealFunction

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 RealFunction add(RealFunction g)
The group composition law. Returns a new polynom with grade = max( this.grade, g.grade)

Overrides:
add in class RealFunction
Parameters:
g - a group member

differentiate

public RealFunction 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 class RealFunction
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

scalarDivide

public RealPolynomial scalarDivide(double 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)
Returns true if this polynomial is equal to another.

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 RealPolynomial 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:
new Polynomial with coefficients *= a

scalarMultiply

public RealPolynomial scalarMultiply(double a)
Returns the multiplication of this polynomial by a scalar

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

multiply

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

Overrides:
multiply in class RealFunction
Parameters:
r - a polynomial
Returns:
a new Polynomial with grade = max( this.grade, r.grade) + min( this.grade, r.grade)

negate

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

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

subtract

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

Overrides:
subtract in class RealFunction
Parameters:
g - a group member

toString

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

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