|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.spaceroots.mantissa.algebra.Polynomial
org.spaceroots.mantissa.algebra.Polynomial.Rational
This class implements polynomials with one unknown and rational coefficients.
In addition to classical algebra operations, euclidian division and remainder are handled.
| Nested Class Summary |
| Nested classes inherited from class org.spaceroots.mantissa.algebra.Polynomial |
Polynomial.DivisionResult, Polynomial.Double, Polynomial.Rational |
| Field Summary | |
protected RationalNumber[] |
a
Coefficients array. |
| Constructor Summary | |
Polynomial.Rational()
Simple constructor. |
|
Polynomial.Rational(long value)
Simple constructor. |
|
Polynomial.Rational(long a1,
long a0)
Simple constructor. |
|
Polynomial.Rational(long a2,
long a1,
long a0)
Simple constructor. |
|
Polynomial.Rational(long a3,
long a2,
long a1,
long a0)
Simple constructor. |
|
Polynomial.Rational(RationalNumber value)
Simple constructor. |
|
Polynomial.Rational(RationalNumber[] a)
Simple constructor. |
|
Polynomial.Rational(RationalNumber c,
int degree)
Simple constructor. |
|
Polynomial.Rational(RationalNumber a1,
RationalNumber a0)
Simple constructor. |
|
Polynomial.Rational(RationalNumber a2,
RationalNumber a1,
RationalNumber a0)
Simple constructor. |
|
Polynomial.Rational(RationalNumber a3,
RationalNumber a2,
RationalNumber a1,
RationalNumber a0)
Simple constructor. |
|
| Method Summary | |
Polynomial.Rational |
add(Polynomial.Rational p)
Add a polynomial to the instance |
static Polynomial.DivisionResult |
euclidianDivision(Polynomial.Rational dividend,
Polynomial.Rational divisor)
Perform the euclidian division of two polynomials. |
RationalNumber[] |
getCoefficients()
Get the coefficients of the polynomial. |
int |
getDegree()
Get the polynomial degree. |
BigInteger |
getDenominatorsLCM()
Get the Least Common Multiple of the coefficients denominators. |
Polynomial |
getDerivative()
Get the derivative of the instance with respect to the unknown. |
boolean |
isIdentity()
Check if the instance is the identity polynomial. |
boolean |
isOne()
Check if the instance is the constant unit polynomial. |
boolean |
isZero()
Check if the instance is the null polynomial. |
Polynomial |
multiply(long l)
Multiply the instance by a constant. |
Polynomial.Rational |
multiply(Polynomial.Rational p)
Multiply the instance by a polynomial. |
Polynomial |
multiply(RationalNumber r)
Multiply the instance by a constant. |
Polynomial |
negate()
Negate the instance. |
Polynomial.Rational |
subtract(Polynomial.Rational p)
Subtract a polynomial from the instance. |
String |
toString()
Returns a string representation of the polynomial. |
double |
valueAt(double x)
Get the value of the polynomial for a specified unknown. |
| Methods inherited from class org.spaceroots.mantissa.algebra.Polynomial |
divide, divide, divide, multiply |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected RationalNumber[] a
| Constructor Detail |
public Polynomial.Rational()
public Polynomial.Rational(long value)
value - constant value of the polynomialpublic Polynomial.Rational(RationalNumber value)
value - constant value of the polynomial
public Polynomial.Rational(long a1,
long a0)
a1 - leeding degree coefficienta0 - constant term
public Polynomial.Rational(RationalNumber a1,
RationalNumber a0)
a1 - leeding degree coefficienta0 - constant term
public Polynomial.Rational(long a2,
long a1,
long a0)
a2 - leeding degree coefficienta1 - first degree coefficienta0 - constant term
public Polynomial.Rational(RationalNumber a2,
RationalNumber a1,
RationalNumber a0)
a2 - leeding degree coefficienta1 - first degree coefficienta0 - constant term
public Polynomial.Rational(long a3,
long a2,
long a1,
long a0)
a3 - leeding degree coefficienta2 - second degree coefficienta1 - first degree coefficienta0 - constant term
public Polynomial.Rational(RationalNumber a3,
RationalNumber a2,
RationalNumber a1,
RationalNumber a0)
a3 - leeding degree coefficienta2 - second degree coefficienta1 - first degree coefficienta0 - constant termpublic Polynomial.Rational(RationalNumber[] a)
a - coefficients array, the a[0] array element is the
constant term while the a[a.length-1] element is the leeding
degree coefficient. The array is copied in a new array, so it
can be changed once the constructor as returned.
public Polynomial.Rational(RationalNumber c,
int degree)
c - coefficientdegree - degree associated with the coefficient| Method Detail |
public boolean isZero()
isZero in class Polynomialpublic boolean isOne()
isOne in class Polynomialpublic boolean isIdentity()
isIdentity in class Polynomialpublic int getDegree()
getDegree in class Polynomialpublic RationalNumber[] getCoefficients()
public Polynomial.Rational add(Polynomial.Rational p)
p - polynomial to add
public Polynomial.Rational subtract(Polynomial.Rational p)
p - polynomial to subtract
public Polynomial negate()
negate in class Polynomialpublic Polynomial.Rational multiply(Polynomial.Rational p)
p - polynomial to multiply by
public Polynomial multiply(long l)
multiply in class Polynomiall - constant to multiply by
public Polynomial multiply(RationalNumber r)
multiply in class Polynomialr - constant to multiply by
public double valueAt(double x)
valueAt in class Polynomialx - value of the unknown
public Polynomial getDerivative()
getDerivative in class Polynomial
public static Polynomial.DivisionResult euclidianDivision(Polynomial.Rational dividend,
Polynomial.Rational divisor)
dividend - numerator polynomialdivisor - denominator polynomial
public BigInteger getDenominatorsLCM()
public String toString()
The representation is user oriented. Terms are displayed lowest
degrees first. The multiplications signs, coefficients equals to
one and null terms are not displayed (except if the polynomial is 0,
in which case the 0 constant term is displayed). Addition of terms
with negative coefficients are replaced by subtraction of terms
with positive coefficients except for the first displayed term
(i.e. we display -3 for a constant negative polynomial,
but 1 - 3 x + x^2 if the negative coefficient is not
the first one displayed).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||