Class Polynomial<R extends Ring<R>>
- All Implemented Interfaces:
Serializable
,javolution.lang.Immutable
,javolution.lang.Realtime
,javolution.lang.ValueType
,GroupAdditive<Polynomial<R>>
,Ring<Polynomial<R>>
,Structure<Polynomial<R>>
- Direct Known Subclasses:
Constant
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]
Variable<Amount<?>> varX = new Variable.Local<Amount<?>>("x");
Polynomial<Amount<?>> x = Polynomial.valueOf(Amount.valueOf(1, SI.METER), varX);
and
Variablemeasures
,
whereas the second operates on
complex
numbers.
Terms (others than ONE
) having zero (additive identity)
for coefficient are automatically removed.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionReturns the composition of this function with the one specified.compose
(Polynomial<R> that) Returns the composition of this polynomial with the one specified.copy()
Returns a copy of this polynomialallocated
by the calling thread (possibly on the stack).differentiate
(Variable<R> v) Returns the first derivative of this function with respect to the specified variable.boolean
Indicates if this function is equals to the specified object.evaluate()
Evaluates this function using itsvariables
current values.final R
getCoefficient
(Term term) Returns the coefficient for the specified term.int
Returns the order of this polynomial for the specified variable.getTerms()
Returns the terms of this polynomial.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 withFunction.equals(Object)
.Returns an integral of this function with respect to the specified variable.Returns the difference of this function with the one specified.minus
(Polynomial<R> that) Returns the difference of two polynomials.opposite()
Returns the opposite of this polynomial.Returns the sum of this function with the one specified.plus
(Polynomial<R> that) Returns the sum of two polynomials.Returns the sum of this polynomial with a constant polynomial having the specified value (convenience method).pow
(int n) Returns this function raised at the specified exponent.Returns the product of this function with the one specified.times
(Polynomial<R> that) Returns the product of two polynomials.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 totoString
except that the returned value can be allocated from the local context space).static <R extends Ring<R>>
Polynomial<R>Returns a polynomial corresponding to the specifiedterm
with the specified coefficient multiplier.static <R extends Ring<R>>
Polynomial<R>Returns an univariate polynomial of degree one with the specified coefficient multiplier.
-
Method Details
-
valueOf
Returns an univariate polynomial of degree one with the specified coefficient multiplier.- Parameters:
coefficient
- the coefficient for the variable of degree 1.variable
- the variable for this polynomial.- Returns:
valueOf(coefficient, Term.valueOf(variable, 1))
-
valueOf
Returns a polynomial corresponding to the specifiedterm
with the specified coefficient multiplier.- Parameters:
coefficient
- the coefficient multiplier.term
- the term multiplicand.- Returns:
coefficient * term
-
getTerms
Returns the terms of this polynomial.- Returns:
- this polynomial's terms.
-
getCoefficient
Returns the coefficient for the specified term.- Parameters:
term
- the term for which the coefficient is returned.- Returns:
- the coefficient for the specified term or
null
if this polynomial does not contain the specified term.
-
getOrder
Returns the order of this polynomial for the specified variable.- Returns:
- the polynomial order relative to the specified variable.
-
plus
Returns the sum of this polynomial with a constant polynomial having the specified value (convenience method).- Parameters:
constantValue
- the value of the constant polynomial to add.- Returns:
this + Constant.valueOf(constantValue)
-
times
Returns the product of this polynomial with a constant polynomial having the specified value (convenience method).- Parameters:
constantValue
- the value of the constant polynomial to multiply.- Returns:
this · Constant.valueOf(constantValue)
-
plus
Returns the sum of two polynomials.- Specified by:
plus
in interfaceGroupAdditive<R extends Ring<R>>
- Parameters:
that
- the polynomial being added.- Returns:
this + that
-
opposite
Returns the opposite of this polynomial.- Specified by:
opposite
in interfaceGroupAdditive<R extends Ring<R>>
- Returns:
- this
-
minus
Returns the difference of two polynomials.- Parameters:
that
- the polynomial being subtracted.- Returns:
this - that
-
times
Returns the product of two polynomials. -
compose
Returns the composition of this polynomial with the one specified.- Parameters:
that
- the polynomial for which the return value is passed as argument to this function.- Returns:
- the polynomial
(this o that)
- Throws:
FunctionException
- if this function is not univariate.
-
compose
Description copied from class:Function
Returns the composition of this function with the one specified. -
differentiate
Description copied from class:Function
Returns the first derivative of this function with respect to the specified variable. -
integrate
Description copied from class:Function
Returns an integral of this function with respect to the specified variable. -
plus
Description copied from class:Function
Returns the sum of this function with the one specified. -
minus
Description copied from class:Function
Returns the difference of this function with the one specified. -
times
Description copied from class:Function
Returns the product of this function with the one specified. -
pow
Description copied from class:Function
Returns this function raised at the specified exponent. -
getVariables
Description copied from class:Function
Returns a lexically ordered list of the variables (or arguments) for this function (empty list for constant functions). -
evaluate
Description copied from class:Function
Evaluates this function using itsvariables
current values. -
equals
Description copied from class:Function
Indicates if this function is equals to the specified object. -
hashCode
public int hashCode()Description copied from class:Function
Returns the hash code for this function (consistent withFunction.equals(Object)
. -
toText
public javolution.text.Text toText()Description copied from class:Function
Returns the textual representation of this real-time object (equivalent totoString
except that the returned value can be allocated from the local context space). -
copy
Returns a copy of this polynomialallocated
by the calling thread (possibly on the stack).- Specified by:
copy
in interfacejavolution.lang.ValueType
- Returns:
- an identical and independant copy of this polynomial.
-