org.spaceroots.mantissa.algebra
Class Polynomial

java.lang.Object
  extended byorg.spaceroots.mantissa.algebra.Polynomial
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Polynomial.Double, Polynomial.Rational

public abstract class Polynomial
extends Object
implements Serializable

This class implements polynomials with one unknown.

This is an abstract class that only declares general methods but does not hold the coefficients by themselves. Specific subclasses are used to handle exact rational coefficients or approximate real coefficients. This design is taken from the various java.awt.geom classes (Point2D, Rectangle2D ...)

The methods implemented deal mainly with the polynomials algebra (addition, multiplication ...) but the analysis aspects are also considered (value of the polynom for a given unknown, derivative).

Instances of this class are immutable.

Version:
$Id: Polynomial.java 1716 2006-12-13 22:56:35Z luc $
Author:
L. Maisonobe
See Also:
Serialized Form

Nested Class Summary
static class Polynomial.DivisionResult
          This class stores the result of the euclidian division of two polynomials.
static class Polynomial.Double
          This class implements polynomials with one unknown and real coefficients.
static class Polynomial.Rational
          This class implements polynomials with one unknown and rational coefficients.
 
Constructor Summary
Polynomial()
           
 
Method Summary
 Polynomial divide(BigInteger i)
          Divide the instance by a constant.
 Polynomial divide(long l)
          Divide the instance by a constant.
 Polynomial divide(RationalNumber r)
          Divide the instance by a constant.
abstract  int getDegree()
          Get the polynomial degree.
abstract  Polynomial getDerivative()
          Get the derivative of the instance with respect to the unknown.
abstract  boolean isIdentity()
          Check if the instance is the identity polynomial.
abstract  boolean isOne()
          Check if the instance is the constant unit polynomial.
abstract  boolean isZero()
          Check if the instance is the null polynomial.
 Polynomial multiply(BigInteger i)
          Multiply the instance by a constant.
abstract  Polynomial multiply(long l)
          Multiply the instance by a constant.
abstract  Polynomial multiply(RationalNumber r)
          Multiply the instance by a constant.
abstract  Polynomial negate()
          Negate the instance.
abstract  double valueAt(double x)
          Get the value of the polynomial for a specified unknown.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polynomial

public Polynomial()
Method Detail

isZero

public abstract boolean isZero()
Check if the instance is the null polynomial.

Returns:
true if the polynomial is null

isOne

public abstract boolean isOne()
Check if the instance is the constant unit polynomial.

Returns:
true if the polynomial is the constant unit polynomial

isIdentity

public abstract boolean isIdentity()
Check if the instance is the identity polynomial.

Returns:
true if the polynomial is the identity polynomial

getDegree

public abstract int getDegree()
Get the polynomial degree.

Returns:
degree

negate

public abstract Polynomial negate()
Negate the instance.

Returns:
a new polynomial

multiply

public abstract Polynomial multiply(RationalNumber r)
Multiply the instance by a constant.

Parameters:
r - constant to multiply by
Returns:
a new polynomial

multiply

public abstract Polynomial multiply(long l)
Multiply the instance by a constant.

Parameters:
l - constant to multiply by
Returns:
a new Polynomial

multiply

public Polynomial multiply(BigInteger i)
Multiply the instance by a constant.

Parameters:
i - constant to multiply by
Returns:
a new Polynomial

divide

public Polynomial divide(long l)
Divide the instance by a constant.

Parameters:
l - constant to multiply by
Returns:
a new polynomial
Throws:
ArithmeticException - if the constant is zero

divide

public Polynomial divide(RationalNumber r)
Divide the instance by a constant.

Parameters:
r - constant to multiply by
Returns:
a new polynomial
Throws:
ArithmeticException - if the constant is zero

divide

public Polynomial divide(BigInteger i)
Divide the instance by a constant.

Parameters:
i - constant to multiply by
Returns:
a new polynomial
Throws:
ArithmeticException - if the constant is zero

valueAt

public abstract double valueAt(double x)
Get the value of the polynomial for a specified unknown.

Parameters:
x - value of the unknown
Returns:
value of the polynomial

getDerivative

public abstract Polynomial getDerivative()
Get the derivative of the instance with respect to the unknown. The derivative of a n degree polynomial is a n-1 degree polynomial of the same type.

Returns:
a new polynomial which is the derivative of the instance


Copyright © 2001-2007 Luc Maisonobe. All Rights Reserved.