JADE v6.1

com.dautelle.math.functions
Class Polynomial.Term

java.lang.Object
  extended bycom.dautelle.realtime.RealtimeObject
      extended bycom.dautelle.math.functions.Polynomial.Term
All Implemented Interfaces:
java.lang.Comparable, Realtime, java.io.Serializable
Enclosing class:
Polynomial

public static final class Polynomial.Term
extends RealtimeObject
implements java.lang.Comparable

This class represents the term of a polynomial such as x·y².

See Also:
Term -- from MathWorld, Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.dautelle.realtime.RealtimeObject
RealtimeObject.Factory
 
Field Summary
static Polynomial.Term CONSTANT
          Holds the term representing no variables.
 
Method Summary
 java.lang.StringBuffer appendTo(java.lang.StringBuffer sb)
          Appends the text representation of this term to the StringBuffer argument.
 int compareTo(java.lang.Object o)
          Compares this term with the specified term for order.
 Polynomial.Term divide(Polynomial.Term that)
          Return the division of this term with the one specified.
 boolean equals(java.lang.Object o)
          Indicates if this term is equal to the object specified.
 Operable evaluate()
          Evaluates this term by replacing its variables by their current (context-local) values.
 java.lang.Object export()
          Exports this object out of the current pool context.
 int getPower(Function.Variable v)
          Return the power of the specified variable within this term.
 int hashCode()
          Returns a hash code for this term.
 Polynomial.Term multiply(Polynomial.Term that)
          Return the product of this term with the one specified.
 java.lang.Object toHeap()
          Moves this object to the heap.
 java.lang.String toString()
          Returns the string representation of this term.
static Polynomial.Term valueOf(Function.Variable v, int n)
          Return the term corresponding to the specified variable raised to the specified power.
 
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
 

Field Detail

CONSTANT

public static final Polynomial.Term CONSTANT
Holds the term representing no variables.

Method Detail

valueOf

public static Polynomial.Term valueOf(Function.Variable v,
                                      int n)
Return the term corresponding to the specified variable raised to the specified power.

Parameters:
v - the variable.
n - the power.
Returns:
the term for vn
Throws:
java.lang.IllegalArgumentException - if n <= 0

getPower

public int getPower(Function.Variable v)
Return the power of the specified variable within this term.

Parameters:
v - the variable.
Returns:
the the power of v or 0 if v is not part of this term.

multiply

public Polynomial.Term multiply(Polynomial.Term that)
Return the product of this term with the one specified.

Parameters:
that - the term multiplier.
Returns:
this·that

divide

public Polynomial.Term divide(Polynomial.Term that)
Return the division of this term with the one specified.

Parameters:
that - the term divisor.
Returns:
this/that
Throws:
java.lang.UnsupportedOperationException - if this division would result in negative power.

evaluate

public Operable evaluate()
Evaluates this term by replacing its variables by their current (context-local) values.

Returns:
the evaluation of this term or null if constant term.
Throws:
FunctionException - if any of this term's variable is not set.

equals

public boolean equals(java.lang.Object o)
Indicates if this term is equal to the object specified.

Parameters:
o - the object to compare for equality.
Returns:
true if this term and the specified object are considered equal; false otherwise.

hashCode

public final int hashCode()
Returns a hash code for this term.

Returns:
a hash code value for this object.

compareTo

public int compareTo(java.lang.Object o)
Compares this term with the specified term for order.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - the term to compare with.
Returns:
a negative integer, zero, or a positive integer as this term is less than, equal to, or greater than the specified term.
Throws:
java.lang.ClassCastException - if the specified object is not a term.

appendTo

public java.lang.StringBuffer appendTo(java.lang.StringBuffer sb)
Appends the text representation of this term to the StringBuffer argument.

Parameters:
sb - the StringBuffer to append.
Returns:
sb

toString

public java.lang.String toString()
Returns the string representation of this term.

Returns:
this term representation.

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.