Class WordFactory
java.lang.Object
edu.jas.poly.WordFactory
- All Implemented Interfaces:
ElemFactory<Word>, MonoidFactory<Word>, Serializable
WordFactory implements alphabet related methods.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final StringThe data structure is a String of characters which defines the alphabet.private static final WordFactory.WordComparatorDefined descending order comparator.private static final org.apache.logging.log4j.LoggerLog4j logger object.private static final WordFactory.WordComparatorDefined ascending order comparator.final WordThe empty word for this monoid.private static final RandomRandom number generator.final String[]The translation array of Strings.static final StringThe translation reference string. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for WordFactory.Constructor for WordFactory.WordFactory(String[] S) Constructor for WordFactory. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringPrepare parse from String.static String[]Prepare parse from String array.static StringcleanSpace(String s) Prepare parse from String.static StringConcat variable names.Contract word to this word factory.Copy word.booleanComparison with any other object.Extend variables.fromInteger(long a) Get the Element for a.Get the Element for a.Get a list of the generating elements.Get the ascending order comparator.Get the descending order comparator.getONE()Get the one element, the empty word.(package private) String[]getTrans()Get the translation array of Strings.(package private) StringgetVal()Get the alphabet String.chargetVal(int i) Get the alphabet letter at position i.String[]getVars()Get the variable names.inthashCode()hashCode.intindexOf(char s) IndexOf for letter in alphabet.static intIndexOf for String array.booleanQuery if this monoid is associative.booleanQuery if this monoid is commutative.booleanisFinite()Is this structure finite or infinite.static booleanisSingleLetters(String[] v) Test if all variables are single letters.booleanTest if the alphabet of w is a subalphabet of this.intlength()Get the alphabet length.Parse from Reader.Parse from String.random(int n) Generate a random Element with size less equal to n.Generate a random Element with size less equal to n.toScript()Get a scripting compatible string representation.toString()Get the string representation.Translate variable names.transVar(char c) Translate variable name.static String[]Trim all variable names.Get the Element for an ExpVector.Get the element from an other word.Methods inherited from interface ElemFactory
valueOf
-
Field Details
-
alphabet
The data structure is a String of characters which defines the alphabet. -
ONE
The empty word for this monoid. -
transRef
-
translation
The translation array of Strings. -
random
Random number generator. -
logger
private static final org.apache.logging.log4j.Logger loggerLog4j logger object. -
horder
Defined descending order comparator. Sorts the highest terms first. -
lorder
Defined ascending order comparator. Sorts the lowest terms first.
-
-
Constructor Details
-
WordFactory
public WordFactory()Constructor for WordFactory. -
WordFactory
Constructor for WordFactory.- Parameters:
s- String of single letters for alphabet
-
WordFactory
Constructor for WordFactory.- Parameters:
S- String array for alphabet
-
-
Method Details
-
isFinite
public boolean isFinite()Is this structure finite or infinite.- Specified by:
isFinitein interfaceElemFactory<Word>- Returns:
- true if this structure is finite, else false.
- See Also:
-
isCommutative
public boolean isCommutative()Query if this monoid is commutative.- Specified by:
isCommutativein interfaceMonoidFactory<Word>- Returns:
- true if this monoid is commutative, else false.
-
isAssociative
public boolean isAssociative()Query if this monoid is associative.- Specified by:
isAssociativein interfaceMonoidFactory<Word>- Returns:
- true if this monoid is associative, else false.
-
getONE
Get the one element, the empty word.- Specified by:
getONEin interfaceMonoidFactory<Word>- Returns:
- 1 as Word.
-
copy
Copy word.- Specified by:
copyin interfaceElemFactory<Word>- Parameters:
w- word to copy.- Returns:
- copy of w.
-
length
public int length()Get the alphabet length.- Returns:
- alphabet.length.
-
getVal
-
getTrans
-
getVal
public char getVal(int i) Get the alphabet letter at position i.- Parameters:
i- position.- Returns:
- val[i].
-
getVars
-
extend
Extend variables. Extend number of variables by length(vn).- Parameters:
vn- names for extended variables.- Returns:
- extended word ring factory.
-
toString
-
toScript
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElemFactory<Word>- Returns:
- script compatible representation for this Element.
- See Also:
-
equals
-
hashCode
-
generators
Get a list of the generating elements.- Specified by:
generatorsin interfaceElemFactory<Word>- Returns:
- list of generators for the algebraic structure.
-
fromInteger
Get the Element for a.- Specified by:
fromIntegerin interfaceElemFactory<Word>- Parameters:
a- long- Returns:
- element corresponding to a.
-
fromInteger
Get the Element for a.- Specified by:
fromIntegerin interfaceElemFactory<Word>- Parameters:
a- java.math.BigInteger.- Returns:
- element corresponding to a.
-
valueOf
-
valueOf
-
indexOf
public int indexOf(char s) IndexOf for letter in alphabet.- Parameters:
s- letter character.- Returns:
- index of s in the alphabet, or -1 if s is not contained in the alphabet.
-
random
Generate a random Element with size less equal to n.- Specified by:
randomin interfaceElemFactory<Word>- Parameters:
n-- Returns:
- a random element.
-
random
Generate a random Element with size less equal to n.- Specified by:
randomin interfaceElemFactory<Word>- Parameters:
n-random- is a source for random bits.- Returns:
- a random element.
-
parse
Parse from String.- Specified by:
parsein interfaceElemFactory<Word>- Parameters:
s- String.- Returns:
- a Element corresponding to s.
-
parse
Parse from Reader. White space is delimiter for word.- Specified by:
parsein interfaceElemFactory<Word>- Parameters:
r- Reader.- Returns:
- the next Element found on r.
-
isSubFactory
Test if the alphabet of w is a subalphabet of this.- Parameters:
w- other word factory to test.- Returns:
- true, if w is a subalphabet of this, else false.
-
contract
-
getDescendComparator
Get the descending order comparator. Sorts the highest terms first.- Returns:
- horder.
-
getAscendComparator
Get the ascending order comparator. Sorts the lowest terms first.- Returns:
- lorder.
-
cleanSpace
-
clean
-
cleanAll
-
concat
-
trimAll
-
indexOf
-
isSingleLetters
Test if all variables are single letters.- Parameters:
v- an array of strings.- Returns:
- true, if all variables have length 1, else false.
-
translate
-
transVar
Translate variable name.- Parameters:
c- internal char.- Returns:
- the external translated string.
-