Class Term
- java.lang.Object
-
- org.jscience.mathematics.function.Term
-
- All Implemented Interfaces:
Serializable,Comparable<Term>,javolution.lang.Immutable,javolution.lang.Realtime,javolution.lang.ValueType
public final class Term extends Object implements Serializable, Comparable<Term>, javolution.lang.ValueType, javolution.lang.Realtime
This class represents the term of apolynomialsuch asx·y².- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Term that)Compares this term with the one specified for order.Termcopy()Returns an entierely new copy of this termallocatedby the calling thread (possibly on the stack).Termdivide(Term that)Return the division of this term with the one specified.booleanequals(Object obj)Indicates if this term is equal to the object specified.intgetPower(int index)Returns the power of the variable at the specified position.intgetPower(Variable<?> v)Returns the power of the specified variable.Variable<?>getVariable(int index)Returns the variable at the specified index (variables are lexically ordered).inthashCode()Returns a hash code for this term.intsize()Returns the number of variables for this term.Termtimes(Term that)Return the product of this term with the one specified.StringtoString()Returns the text representation of this term as ajava.lang.String.javolution.text.TexttoText()Returns the text representation of this term.static TermvalueOf(Variable<?> v, int n)Return the term corresponding to the specified variable raised to the specified power.
-
-
-
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:
IllegalArgumentException- ifn < 0
-
size
public int size()
Returns the number of variables for this term.- Returns:
- the number of variables.
-
getVariable
public Variable<?> getVariable(int index)
Returns the variable at the specified index (variables are lexically ordered).- Parameters:
index- the variable index.- Returns:
- this term variables at specified position.
- Throws:
IndexOutOfBoundsException- if(index < 0) || (index >= size())
-
getPower
public int getPower(int index)
Returns the power of the variable at the specified position.- Parameters:
index- the variable index.- Returns:
- the power of the variable at the specified index.
- Throws:
IndexOutOfBoundsException- if(index < 0) || (index >= size())
-
getPower
public int getPower(Variable<?> v)
Returns the power of the specified variable.- Parameters:
v- the variable for which the power is returned.- Returns:
- the power of the corresponding variable or
0if this term does not hold the specified variable.
-
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:
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:
UnsupportedOperationException- if this division would result in negative power.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(Object obj)
Indicates if this term is equal to the object specified.
-
hashCode
public final int hashCode()
Returns a hash code for this term.
-
toString
public final String toString()
Returns the text representation of this term as ajava.lang.String.
-
toText
public javolution.text.Text toText()
Returns the text representation of this term.- Specified by:
toTextin interfacejavolution.lang.Realtime
-
copy
public Term copy()
Returns an entierely new copy of this termallocatedby the calling thread (possibly on the stack).- Specified by:
copyin interfacejavolution.lang.ValueType- Returns:
- an identical and independant copy of this term.
-
compareTo
public int compareTo(Term that)
Compares this term with the one specified for order.- Specified by:
compareToin interfaceComparable<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.
-
-