public class Polynomial<R extends Ring<R>> extends Function<R,R> implements Ring<Polynomial<R>>
This class represents a mathematical expression involving a sum of powers
in one or more variables
multiplied by
coefficients (such as x² + x·y + 3y²
).
Polynomials are characterized by the type of variable they operate
upon. For example:[code]
Variablemeasures
,
whereas the second operates on
complex
numbers.
Terms (others than ONE
) having zero (additive identity)
for coefficient are automatically removed.
Modifier and Type | Method and Description |
---|---|
<Z> Function<Z,R> |
compose(Function<Z,R> that)
Returns the composition of this function with the one specified.
|
Polynomial<R> |
compose(Polynomial<R> that)
Returns the composition of this polynomial with the one specified.
|
Polynomial<R> |
copy()
Returns a copy of this polynomial
allocated
by the calling thread (possibly on the stack). |
Polynomial<R> |
differentiate(Variable<R> v)
Returns the first derivative of this function with respect to
the specified variable.
|
boolean |
equals(Object obj)
Indicates if this function is equals to the specified object.
|
R |
evaluate()
Evaluates this function using its
variables current
values. |
R |
getCoefficient(Term term)
Returns the coefficient for the specified term.
|
int |
getOrder(Variable<R> v)
Returns the order of this polynomial for the specified variable.
|
Set<Term> |
getTerms()
Returns the terms of this polynomial.
|
List<Variable<R>> |
getVariables()
Returns a lexically ordered list of the variables (or arguments)
for this function (empty list for constant functions).
|
int |
hashCode()
Returns the hash code for this function (consistent with
Function.equals(Object) . |
Polynomial<R> |
integrate(Variable<R> v)
Returns an integral of this function with respect to
the specified variable.
|
Function<R,R> |
minus(Function<R,R> that)
Returns the difference of this function with the one specified.
|
Polynomial<R> |
minus(Polynomial<R> that)
Returns the difference of two polynomials.
|
Polynomial<R> |
opposite()
Returns the opposite of this polynomial.
|
Function<R,R> |
plus(Function<R,R> that)
Returns the sum of this function with the one specified.
|
Polynomial<R> |
plus(Polynomial<R> that)
Returns the sum of two polynomials.
|
Polynomial<R> |
plus(R constantValue)
Returns the sum of this polynomial with a constant polynomial
having the specified value (convenience method).
|
Polynomial<R> |
pow(int n)
Returns this function raised at the specified exponent.
|
Function<R,R> |
times(Function<R,R> that)
Returns the product of this function with the one specified.
|
Polynomial<R> |
times(Polynomial<R> that)
Returns the product of two polynomials.
|
Polynomial<R> |
times(R constantValue)
Returns the product of this polynomial with a constant polynomial
having the specified value (convenience method).
|
javolution.text.Text |
toText()
Returns the textual representation of this real-time object
(equivalent to
toString except that the returned value
can be allocated from the local context space). |
static <R extends Ring<R>> |
valueOf(R coefficient,
Term term)
Returns a polynomial corresponding to the specified
term
with the specified coefficient multiplier. |
static <R extends Ring<R>> |
valueOf(R coefficient,
Variable<R> variable)
Returns an univariate polynomial of degree one with the specified
coefficient multiplier.
|
public static <R extends Ring<R>> Polynomial<R> valueOf(R coefficient, Variable<R> variable)
coefficient
- the coefficient for the variable of degree 1.variable
- the variable for this polynomial.valueOf(coefficient, Term.valueOf(variable, 1))
public static <R extends Ring<R>> Polynomial<R> valueOf(R coefficient, Term term)
term
with the specified coefficient multiplier.coefficient
- the coefficient multiplier.term
- the term multiplicand.coefficient * term
public Set<Term> getTerms()
public final R getCoefficient(Term term)
term
- the term for which the coefficient is returned.null
if this polynomial does not contain the specified term.public int getOrder(Variable<R> v)
public Polynomial<R> plus(R constantValue)
constantValue
- the value of the constant polynomial to add.this + Constant.valueOf(constantValue)
public Polynomial<R> times(R constantValue)
constantValue
- the value of the constant polynomial to multiply.this · Constant.valueOf(constantValue)
public Polynomial<R> plus(Polynomial<R> that)
plus
in interface GroupAdditive<Polynomial<R extends Ring<R>>>
that
- the polynomial being added.this + that
public Polynomial<R> opposite()
opposite
in interface GroupAdditive<Polynomial<R extends Ring<R>>>
- this
public Polynomial<R> minus(Polynomial<R> that)
that
- the polynomial being subtracted.this - that
public Polynomial<R> times(Polynomial<R> that)
public Polynomial<R> compose(Polynomial<R> that)
that
- the polynomial for which the return value is passed as
argument to this function.(this o that)
FunctionException
- if this function is not univariate.public <Z> Function<Z,R> compose(Function<Z,R> that)
Function
public Polynomial<R> differentiate(Variable<R> v)
Function
differentiate
in class Function<R extends Ring<R>,R extends Ring<R>>
v
- the variable for which the derivative is calculated.d[this]/dv
public Polynomial<R> integrate(Variable<R> v)
Function
public Function<R,R> plus(Function<R,R> that)
Function
public Function<R,R> minus(Function<R,R> that)
Function
public Function<R,R> times(Function<R,R> that)
Function
public Polynomial<R> pow(int n)
Function
public List<Variable<R>> getVariables()
Function
public R evaluate()
Function
variables
current
values.public boolean equals(Object obj)
Function
public int hashCode()
Function
Function.equals(Object)
.public javolution.text.Text toText()
Function
toString
except that the returned value
can be allocated from the local context space).public Polynomial<R> copy()
allocated
by the calling thread (possibly on the stack).copy
in interface javolution.lang.ValueType
Copyright © 2012. All Rights Reserved.