public final class Term extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<Term>, javolution.lang.ValueType, javolution.lang.Realtime
polynomial
such as x·y²
.Modifier and Type | Field and Description |
---|---|
static Term |
ONE
Holds the multiplicative identity.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Term that)
Compares this term with the one specified for order.
|
Term |
copy()
Returns an entierely new copy of this term
allocated
by the calling thread (possibly on the stack). |
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(int index)
Returns the power of the variable at the specified position.
|
int |
getPower(Variable<?> v)
Returns the power of the specified variable.
|
Variable<?> |
getVariable(int index)
Returns the variable at the specified index (variables are
lexically ordered).
|
int |
hashCode()
Returns a hash code for this term.
|
int |
size()
Returns the number of variables for this term.
|
Term |
times(Term that)
Return the product of this term with the one specified.
|
java.lang.String |
toString()
Returns the text representation of this term as a
java.lang.String . |
javolution.text.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.
|
public static Term valueOf(Variable<?> v, int n)
v
- the variable.n
- the power.vn
java.lang.IllegalArgumentException
- if n < 0
public int size()
public Variable<?> getVariable(int index)
index
- the variable index.java.lang.IndexOutOfBoundsException
- if
(index < 0) || (index >= size())
public int getPower(int index)
index
- the variable index.java.lang.IndexOutOfBoundsException
- if
(index < 0) || (index >= size())
public int getPower(Variable<?> v)
v
- the variable for which the power is returned.0
if
this term does not hold the specified variable.public Term times(Term that)
that
- the term multiplier.this · that
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.public Term divide(Term that)
that
- the term divisor.this / that
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.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare for equality.true
if this term and the specified object are
considered equal; false
otherwise.public final int hashCode()
hashCode
in class java.lang.Object
public final java.lang.String toString()
java.lang.String
.toString
in class java.lang.Object
toText().toString()
public javolution.text.Text toText()
toText
in interface javolution.lang.Realtime
public Term copy()
allocated
by the calling thread (possibly on the stack).copy
in interface javolution.lang.ValueType
public int compareTo(Term that)
compareTo
in interface java.lang.Comparable<Term>
that
- the term to be compared to.