org.spaceroots.mantissa.algebra
Class Polynomial
- java.lang.Object
-
- org.spaceroots.mantissa.algebra.Polynomial
-
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- Polynomial.Double, Polynomial.Rational
public abstract class Polynomial extends java.lang.Object implements java.io.SerializableThis 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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classPolynomial.DivisionResultThis class stores the result of the euclidian division of two polynomials.static classPolynomial.DoubleThis class implements polynomials with one unknown and real coefficients.static classPolynomial.RationalThis class implements polynomials with one unknown and rational coefficients.
-
Constructor Summary
Constructors Constructor and Description Polynomial()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description Polynomialdivide(java.math.BigInteger i)Divide the instance by a constant.Polynomialdivide(long l)Divide the instance by a constant.Polynomialdivide(RationalNumber r)Divide the instance by a constant.abstract intgetDegree()Get the polynomial degree.abstract PolynomialgetDerivative()Get the derivative of the instance with respect to the unknown.abstract booleanisIdentity()Check if the instance is the identity polynomial.abstract booleanisOne()Check if the instance is the constant unit polynomial.abstract booleanisZero()Check if the instance is the null polynomial.Polynomialmultiply(java.math.BigInteger i)Multiply the instance by a constant.abstract Polynomialmultiply(long l)Multiply the instance by a constant.abstract Polynomialmultiply(RationalNumber r)Multiply the instance by a constant.abstract Polynomialnegate()Negate the instance.abstract doublevalueAt(double x)Get the value of the polynomial for a specified unknown.
-
-
-
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(java.math.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:
java.lang.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:
java.lang.ArithmeticException- if the constant is zero
-
divide
public Polynomial divide(java.math.BigInteger i)
Divide the instance by a constant.- Parameters:
i- constant to multiply by- Returns:
- a new polynomial
- Throws:
java.lang.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
-
-
DataMelt 3.0 © DataMelt by jWork.ORG