JScience v3.3

org.jscience.mathematics.functions
Class Term

java.lang.Object
  extended by javolution.context.RealtimeObject
      extended by org.jscience.mathematics.functions.Term
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Term>, Realtime

public final class Term
extends RealtimeObject
implements java.io.Serializable, java.lang.Comparable<Term>

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

Version:
3.0, February 13, 2006
Author:
Jean-Marie Dautelle
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javolution.context.RealtimeObject
RealtimeObject.Factory<T extends RealtimeObject>
 
Nested classes/interfaces inherited from interface javolution.context.Realtime
Realtime.ObjectSpace
 
Field Summary
static Term ONE
          Holds the multiplicative identity.
 
Method Summary
 int compareTo(Term that)
          Compares this term with the one specified for order.
 Term divide(Term that)
          Return the division of this term with the one specified.
 boolean equals(java.lang.Object obj)
          Indicates if this term is equal to the object specified.
 int getPower(Variable var)
          Returns the power of the specified variable.
 java.util.List<Variable> getVariables()
          Returns the variables for this term (lexically ordered).
 int hashCode()
          Returns a hash code for this term.
 Term times(Term that)
          Return the product of this term with the one specified.
 Text toText()
          Returns the text representation of this term.
static Term valueOf(Variable v, int n)
          Return the term corresponding to the specified variable raised to the specified power.
 
Methods inherited from class javolution.context.RealtimeObject
export, isLocal, move, moveHeap, preserve, toString, unpreserve
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ONE

public static Term ONE
Holds the multiplicative identity.

Method Detail

valueOf

public static Term valueOf(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

getVariables

public java.util.List<Variable> getVariables()
Returns the variables for this term (lexically ordered).

Returns:
this term variables.

getPower

public int getPower(Variable var)
Returns the power of the specified variable.

Parameters:
var - the variable for which the power is returned.
Returns:
the power of the corresponding variable or 0 if this term does not hold the specified variable.
Throws:
java.lang.IllegalArgumentException - if (i < 0) || (i >= length())

times

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

Parameters:
that - the term multiplier.
Returns:
this · that
Throws:
java.lang.IllegalArgumentException - if the specified term holds a variable having the same symbol as one of the variable of this term; but both variables are distinct.

divide

public Term divide(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.
java.lang.IllegalArgumentException - if the specified term holds a variable having the same symbol as one of the variable of this term; but both variables are distinct.

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
obj - 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.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toText

public Text toText()
Returns the text representation of this term.

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

compareTo

public int compareTo(Term that)
Compares this term with the one specified for order.

Specified by:
compareTo in interface java.lang.Comparable<Term>
Parameters:
that - the term to be compared to.
Returns:
a negative integer, zero, or a positive integer as this term is less than, equal to, or greater than the specified term.

JScience v3.3

Copyright © 2006 JScience.