|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcommon.Polynomial
public class Polynomial
Provides an implementation for a univariate polynomial P(x)
.
Constructor Summary | |
---|---|
Polynomial(java.math.BigInteger[] coefficients)
Constructing the univariate polynomial with given coefficients in Java BigInteger type. |
|
Polynomial(int highestDegree)
Constructing the univariate polynomial with a given highest degree that the polynomial can have. |
|
Polynomial(int[] coefficients)
Constructing the univariate polynomial with given coefficients in integer type. |
Method Summary | |
---|---|
Polynomial |
add(Polynomial p)
Returns a new univariate polynomial as the sum of this polynomial and another polynomial. |
static Polynomial |
createLagrange(int[] x,
int i)
Creates a univariate polynomial in Lagrange form. |
int |
degree()
Returns the polynomial degree. |
java.math.BigInteger |
getCoefficient(int degree)
Returns coefficient corresponding the given degree. |
java.math.BigInteger[] |
getCoefficients()
Returns all coefficients of the polynomial. |
static void |
main(java.lang.String[] args)
For testing purpose. |
Polynomial |
mod(java.math.BigInteger m)
Returns a new univariate polynomial by mod-ing all coefficients of this polynomial by a given modulus. |
Polynomial |
multiply(java.math.BigInteger k)
Returns a new univariate polynomial by multiplying this polynomial with a scalar value in Java BigInteger type. |
Polynomial |
multiply(int k)
Returns a new univariate polynomial by multiplying this polynomial with a scalar value in integer type. |
Polynomial |
multiply(Polynomial p)
Returns a new univariate polynomial by multiplying this polynomial with another polynomial. |
Polynomial |
negate()
Returns a new univariate polynomial by negating this polynomial. |
Polynomial |
pow(int exponent)
Returns a new univariate polynomial as an exponentiation of this polynomial. |
void |
setCoefficient(int degree,
java.math.BigInteger coeff)
Sets coefficient at a specified degree with given value in Java BigInteger type. |
void |
setCoefficient(int degree,
int coeff)
Sets coefficient of a specified degree with given value in integer type. |
Polynomial |
subtract(Polynomial p)
Returns a new univariate polynomial as the result of subtracting this polynomial by another polynomial. |
java.lang.String |
toString()
Returns a string representing this polynomial. |
java.math.BigInteger |
value(java.math.BigInteger x)
Evaluates the polynomial at a given point. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Polynomial(int highestDegree)
highestDegree
- the highest degree.public Polynomial(java.math.BigInteger[] coefficients)
BigInteger
type.
The polynomial degree is determined based on the values of the given coefficients.
coefficients
- given coefficients.public Polynomial(int[] coefficients)
coefficients
- given coefficients.Method Detail |
---|
public int degree()
public java.math.BigInteger getCoefficient(int degree)
degree
- degree of the queried coefficient.
public java.math.BigInteger[] getCoefficients()
public void setCoefficient(int degree, java.math.BigInteger coeff)
BigInteger
type.
degree
- specified degree.coeff
- new value for the coefficient.public void setCoefficient(int degree, int coeff)
degree
- specified degree.coeff
- new value for the coefficient.public java.math.BigInteger value(java.math.BigInteger x)
x
- given value x
.
P(x)
.public Polynomial add(Polynomial p)
p
- another polynomial.
public Polynomial subtract(Polynomial p)
p
- another polynomial.
public Polynomial negate()
public Polynomial multiply(java.math.BigInteger k)
k
- scalar value.
public Polynomial multiply(int k)
k
- scalar value.
public Polynomial multiply(Polynomial p)
p
- another polynomial.
public Polynomial pow(int exponent)
exponent
- desired exponent.
public Polynomial mod(java.math.BigInteger m)
m
- the modulus.
public java.lang.String toString()
toString
in class java.lang.Object
public static Polynomial createLagrange(int[] x, int i)
x
- array of all points \f$x_m\f$.i
- index \f$i\f$ of \f$x_i\f$.public static void main(java.lang.String[] args)
args
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |