JSci.maths.polynomials
Class RealPolynomial

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

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.
 RealPolynomial divide(double a)
          return a new real Polynomial with coefficients divided by a
 Polynomial divide(Field.Member f)
          return a new real Polynomial with coefficients divided by f
 boolean equals(java.lang.Object o)
          Returns true if this polynomial is equal to another.
 Field.Member getCoefficient(int n)
          Get the coefficient of degree k, i.e.
 double getCoefficientAsDouble(int n)
          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
 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.
 RealPolynomial multiply(double a)
          Returns the multiplication of this polynomial by a scalar
 Polynomial multiply(Field.Member f)
          Returns the multiplication of this polynomial by a scalar
 RealFunction multiply(RealFunction r)
          The multiplication law.
 AbelianGroup.Member negate()
          Returns the inverse member.
 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, 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 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

getCoefficientAsDouble

public double getCoefficientAsDouble(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

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

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)

divide

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

Specified by:
divide in interface Polynomial
Parameters:
f - divisor
Returns:
new Polynomial with coefficients /= f

divide

public RealPolynomial divide(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.

Parameters:
o - the other polynomial
Returns:
true if so

hashCode

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

Returns:
a hashcode

integrate

public RealPolynomial integrate()
"inverse" operation for differentiate

Returns:
the integrated polynomial

multiply

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

Specified by:
multiply in interface Polynomial
Parameters:
f -
Returns:
new Polynomial with coefficients *= a

multiply

public RealPolynomial multiply(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
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 +...

Returns:
String