Package edu.jas.poly
Class Word
- java.lang.Object
-
- edu.jas.poly.Word
-
- All Implemented Interfaces:
Element<Word>,MonoidElem<Word>,java.io.Serializable,java.lang.Comparable<Word>
public final class Word extends java.lang.Object implements MonoidElem<Word>
Word implements strings of letters for polynomials.- Author:
- Heinz Kredel
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected inthashStored hash code.WordFactorymonoDefining alphabet in WordFactory.
-
Constructor Summary
Constructors Constructor Description Word(WordFactory m)Constructor for Word.Word(WordFactory m, java.lang.String s)Constructor for Word.Word(WordFactory m, java.lang.String s, boolean translate)Constructor for Word.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(Word V)Word compareTo.Wordcopy()Copy this.longdegree()Word degree.java.util.SortedMap<java.lang.String,java.lang.Integer>dependencyOnVariables()Word dependency on letters.Worddivide(Word V)Word divide.WorddivideLeft(Word V)Word divide left.WorddivideRight(Word V)Word divide right.booleandivides(Word V)Word divides test.Word[]divideWord(Word V)Word divide with prefix and suffix.Word[]divideWord(Word V, boolean first)Word divide with prefix and suffix.booleanequals(java.lang.Object B)Comparison with any other object.MonoidFactory<Word>factory()Get the corresponding element factory.chargetVal(int i)Get the letter at position i.intgradCompareTo(Word V)Word graded comparison.intgradInvlexCompareTo(Word V)Word graded comparison.inthashCode()hashCode.static java.util.SortedMap<java.lang.String,java.lang.Integer>histogram(java.lang.String v)String dependency on letters.Wordinverse()Word inverse.booleanisONE()Is Word one.booleanisOverlap(Overlap ol, Word V)Is word overlap.booleanisUnit()Is Word unit.Wordlcm(Word V)Word pseudo least common multiple.ExpVectorleadingExpVector()Word leading exponent vector.intlength()Get the length of this word.booleanmultipleOf(Word V)Word multiple test.Wordmultiply(Word V)Word multiplication.OverlapListoverlap(Word V)Word overlap list.Word[]quotientRemainder(Word S)Quotient and remainder by division of this by S.Wordreductum()Word without leading exponent vector.Wordremainder(Word V)Word remainder.intsignum()Word signum.java.lang.StringtoScript()Get a scripting compatible string representation.java.lang.StringtoScriptFactory()Get a scripting compatible string representation of the factory.java.lang.StringtoString()Get the string representation.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.jas.structure.MonoidElem
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
-
-
-
-
Field Detail
-
mono
public final WordFactory mono
Defining alphabet in WordFactory.
-
hash
protected int hash
Stored hash code.
-
-
Constructor Detail
-
Word
public Word(WordFactory m)
Constructor for Word.- Parameters:
m- factory for words.
-
Word
public Word(WordFactory m, java.lang.String s)
Constructor for Word.- Parameters:
m- factory for words.s- String
-
Word
public Word(WordFactory m, java.lang.String s, boolean translate)
Constructor for Word.- Parameters:
m- factory for words.s- Stringtranslate- indicator if s needs translation
-
-
Method Detail
-
factory
public MonoidFactory<Word> factory()
Get the corresponding element factory.- Specified by:
factoryin interfaceElement<Word>- Returns:
- factory for this Element.
- See Also:
Element.factory()
-
getVal
public char getVal(int i)
Get the letter at position i.- Parameters:
i- position.- Returns:
- val[i].
-
length
public int length()
Get the length of this word.- Returns:
- val.length.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toScript
public java.lang.String toScript()
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElement<Word>- Returns:
- script compatible representation for this Element.
- See Also:
Element.toScript()
-
toScriptFactory
public java.lang.String toScriptFactory()
Get a scripting compatible string representation of the factory.- Specified by:
toScriptFactoryin interfaceElement<Word>- Returns:
- script compatible representation for this ElemFactory.
- See Also:
Element.toScriptFactory()
-
equals
public boolean equals(java.lang.Object B)
Comparison with any other object.
-
hashCode
public int hashCode()
hashCode.
-
isONE
public boolean isONE()
Is Word one.- Specified by:
isONEin interfaceMonoidElem<Word>- Returns:
- If this is the empty word then true is returned, else false.
-
isUnit
public boolean isUnit()
Is Word unit.- Specified by:
isUnitin interfaceMonoidElem<Word>- Returns:
- If this is a unit then true is returned, else false.
-
multiply
public Word multiply(Word V)
Word multiplication.- Specified by:
multiplyin interfaceMonoidElem<Word>- Parameters:
V- other word.- Returns:
- this * V.
-
divide
public Word divide(Word V)
Word divide.- Specified by:
dividein interfaceMonoidElem<Word>- Parameters:
V- other word.- Returns:
- this / V.
-
divideLeft
public Word divideLeft(Word V)
Word divide left.- Parameters:
V- other word.- Returns:
- this / V = left, with left * V = this.
-
divideRight
public Word divideRight(Word V)
Word divide right.- Parameters:
V- other word.- Returns:
- this / V = right, with V * right = this.
-
divideWord
public Word[] divideWord(Word V)
Word divide with prefix and suffix.- Parameters:
V- other word.- Returns:
- [left,right] with left * V * right = this.
-
divideWord
public Word[] divideWord(Word V, boolean first)
Word divide with prefix and suffix.- Parameters:
V- other word.first- is true for first index, false for last index.- Returns:
- [left,right] with left * V * right = this.
-
remainder
public Word remainder(Word V)
Word remainder.- Specified by:
remainderin interfaceMonoidElem<Word>- Parameters:
V- other word.- Returns:
- this (this/V). Note: not useful.
-
quotientRemainder
public Word[] quotientRemainder(Word S)
Quotient and remainder by division of this by S.- Specified by:
quotientRemainderin interfaceMonoidElem<Word>- Parameters:
S- a Word- Returns:
- [this/S, this - (this/S)*S]. Note: not useful.
-
inverse
public Word inverse()
Word inverse.- Specified by:
inversein interfaceMonoidElem<Word>- Returns:
- 1 / this.
-
signum
public int signum()
Word signum.- Returns:
- 0 if this is one, 1 if it is non empty.
-
degree
public long degree()
Word degree.- Returns:
- total degree of all letters.
-
dependencyOnVariables
public java.util.SortedMap<java.lang.String,java.lang.Integer> dependencyOnVariables()
Word dependency on letters.- Returns:
- sorted map of letters and the number of its occurences.
-
histogram
public static java.util.SortedMap<java.lang.String,java.lang.Integer> histogram(java.lang.String v)
String dependency on letters.- Parameters:
v- string.- Returns:
- sorted map of letters and the number of its occurences.
-
leadingExpVector
public ExpVector leadingExpVector()
Word leading exponent vector.- Returns:
- an ExpVector for the first power of a letter.
-
reductum
public Word reductum()
Word without leading exponent vector.- Returns:
- an Word without the first power of a letter.
-
multipleOf
public boolean multipleOf(Word V)
Word multiple test.- Parameters:
V- other word.- Returns:
- true if this is a multiple of V, else false.
-
divides
public boolean divides(Word V)
Word divides test.- Parameters:
V- other word.- Returns:
- true if this divides V, else false.
-
gradCompareTo
public int gradCompareTo(Word V)
Word graded comparison. Compares first be degree, then lexicographical.- Parameters:
V- other word.- Returns:
- 0 if U == V, -1 if U < V, 1 if U > V.
-
gradInvlexCompareTo
public int gradInvlexCompareTo(Word V)
Word graded comparison. Compares first be degree, then inverse lexicographical.- Parameters:
V- other word.- Returns:
- 0 if U == V, -1 if U < V, 1 if U > V.
-
isOverlap
public boolean isOverlap(Overlap ol, Word V)
Is word overlap.- Parameters:
ol- = [l1,r1,l2,r2] an Overlap container of four wordsV- word- Returns:
- true if l1 * this * r1 = l2 * V * r2, else false.
-
overlap
public OverlapList overlap(Word V)
Word overlap list.- Parameters:
V- other word.- Returns:
- list of overlaps [l1,r1,l2,r2] with l1 * this * r1 = l2 * V * r2. If no such overlaps exist the empty overlap list is returned.
-
-