JADE v6.1

com.dautelle.math.functions
Class Polynomial

java.lang.Object
  extended bycom.dautelle.realtime.RealtimeObject
      extended bycom.dautelle.math.functions.Function
          extended bycom.dautelle.math.functions.Polynomial
All Implemented Interfaces:
Operable, Realtime, java.io.Serializable
Direct Known Subclasses:
Constant

public class Polynomial
extends Function

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 also characterized by the type of variable they operate upon. For example:

   Polynomial x = Polynomial.valueOf(Scalar.ONE, Variable.X);
and
   Polynomial x = Polynomial.valueOf(Complex.ONE, Variable.X);
are two different polynomials, the first operates on dimensionless quantities, whereas the second operates on complex numbers.

Version:
6.0, March 17, 2004
Author:
Jean-Marie Dautelle
See Also:
Polynomial -- from MathWorld, Serialized Form

Nested Class Summary
static class Polynomial.Term
          This class represents the term of a polynomial such as x·y².
 
Nested classes inherited from class com.dautelle.math.functions.Function
Function.Variable
 
Nested classes inherited from class com.dautelle.realtime.RealtimeObject
RealtimeObject.Factory
 
Method Summary
 java.lang.StringBuffer appendTo(java.lang.StringBuffer sb)
          Appends the text representation of this function to the StringBuffer argument.
 Function compose(Function f)
          Returns the composition of this function with the one specified.
 Function differentiate(Function.Variable v)
          Returns the first derivative of this function with respect to the specified variable.
 boolean equals(java.lang.Object that)
          Compares this polynomial against the specified object.
 Operable evaluate()
          Evaluates this function by replacing its variables by their current (context-local) values.
 java.lang.Object export()
          Exports this object out of the current pool context.
 Operable getCoefficient(Polynomial.Term term)
          Returns the coefficient for the specified term.
 int getOrder(Function.Variable v)
          Returns the order of this polynomial for the specified variable.
 java.util.Collection getTerms()
          Returns the terms of this polynomial.
 java.util.Set getVariables()
          Returns a set containing this function variables.
 int hashCode()
          Returns the hash code for this polynomial.
 Function integrate(Function.Variable v)
          Returns an integral of this function with respect to the specified variable.
 Operable opposite()
          Returns the additive inverse of this object.
 Operable plus(Operable o)
          Returns the sum of this object with the one specified.
 Operable times(Operable o)
          Returns the product of this object with the one specified.
 java.lang.Object toHeap()
          Moves this object to the heap.
static Polynomial valueOf(Operable coefficient, Function.Variable variable)
          Returns an univariate polynomial of degree one with the specified coefficient multiplier.
static Polynomial valueOf(Operable coefficient, Polynomial.Term term)
          Returns a polynomial corresponding to the specified term with the specified coefficient multiplier.
 
Methods inherited from class com.dautelle.math.functions.Function
pow, reciprocal, toString
 
Methods inherited from class com.dautelle.realtime.RealtimeObject
clone, isLocalObject, isPoolObject, recycle
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

valueOf

public static Polynomial valueOf(Operable coefficient,
                                 Function.Variable variable)
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

public static Polynomial valueOf(Operable coefficient,
                                 Polynomial.Term term)
Returns a polynomial corresponding to the specified term with the specified coefficient multiplier.

Parameters:
coefficient - the coefficient multiplier.
term - the term multiplicand.
Returns:
coefficient * term

getTerms

public java.util.Collection getTerms()
Returns the terms of this polynomial.

Returns:
this polynomial's terms.

getCoefficient

public Operable getCoefficient(Polynomial.Term term)
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

public int getOrder(Function.Variable v)
Returns the order of this polynomial for the specified variable.

Returns:
the polynomial order relative to the specified variable.

equals

public boolean equals(java.lang.Object that)
Compares this polynomial against the specified object.

Parameters:
that - the object to compare with.
Returns:
true if the objects are the same; false otherwise.

hashCode

public int hashCode()
Returns the hash code for this polynomial.

Returns:
the hash code value.

getVariables

public java.util.Set getVariables()
Description copied from class: Function
Returns a set containing this function variables.

Specified by:
getVariables in class Function
Returns:
the variables for this function.

evaluate

public Operable evaluate()
Description copied from class: Function
Evaluates this function by replacing its variables by their current (context-local) values.

Specified by:
evaluate in class Function
Returns:
the evaluation of this function.

appendTo

public java.lang.StringBuffer appendTo(java.lang.StringBuffer sb)
Description copied from class: Function
Appends the text representation of this function to the StringBuffer argument.

Overrides:
appendTo in class Function
Parameters:
sb - the StringBuffer to append.
Returns:
sb

plus

public Operable plus(Operable o)
Description copied from interface: Operable
Returns the sum of this object with the one specified.

Specified by:
plus in interface Operable
Overrides:
plus in class Function

opposite

public Operable opposite()
Description copied from interface: Operable
Returns the additive inverse of this object. It is the object such as this.plus(this.opposite()) == ZERO, with ZERO being the additive identity.

Specified by:
opposite in interface Operable
Overrides:
opposite in class Function

times

public Operable times(Operable o)
Description copied from interface: Operable
Returns the product of this object with the one specified.

Specified by:
times in interface Operable
Overrides:
times in class Function

compose

public Function compose(Function f)
Description copied from class: Function
Returns the composition of this function with the one specified.

Overrides:
compose in class Function
Parameters:
f - the function for which the return value is passed as argument to this function.
Returns:
the function (this o that)

differentiate

public Function differentiate(Function.Variable v)
Description copied from class: Function
Returns the first derivative of this function with respect to the specified variable.

Overrides:
differentiate in class Function
Parameters:
v - the variable for which the derivative is calculated.
Returns:
d[this]/dv
See Also:
Derivative -- from MathWorld

integrate

public Function integrate(Function.Variable v)
Description copied from class: Function
Returns an integral of this function with respect to the specified variable.

Overrides:
integrate in class Function
Parameters:
v - the variable for which the integral is calculated.
Returns:
S[this·dv]
See Also:
Integral -- from MathWorld

export

public java.lang.Object export()
Description copied from interface: Realtime
Exports this object out of the current pool context. Realtime members are exported as well (recursion). This method affects only objects belonging to the current pool context. To avoid pool depletion, a "free" object from the outer pool is moved to replace the object being exported.

Specified by:
export in interface Realtime
Overrides:
export in class RealtimeObject

toHeap

public java.lang.Object toHeap()
Description copied from interface: Realtime
Moves this object to the heap. Realtime members are moved to the heap as well (recursion). This method affects only objects belonging to a pool context (current or not).

Specified by:
toHeap in interface Realtime
Overrides:
toHeap in class RealtimeObject

JADE v6.1

Copyright © 2004 Jean-Marie Dautelle.