Package edu.jas.poly
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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface edu.jas.structure.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
The translation reference string.- See Also:
-
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
String getVal()Get the alphabet String.- Returns:
- alphabet.
-
getTrans
String[] getTrans()Get the translation array of Strings.- Returns:
- alphabet.
-
getVal
public char getVal(int i) Get the alphabet letter at position i.- Parameters:
i- position.- Returns:
- val[i].
-
getVars
Get the variable names.- Returns:
- array of variable names
-
extend
Extend variables. Extend number of variables by length(vn).- Parameters:
vn- names for extended variables.- Returns:
- extended word ring factory.
-
toString
Get the string representation. -
toScript
Get a scripting compatible string representation.- Specified by:
toScriptin interfaceElemFactory<Word>- Returns:
- script compatible representation for this Element.
- See Also:
-
equals
Comparison with any other object. -
hashCode
public int hashCode()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
Get the Element for an ExpVector.- Parameters:
e- ExpVector.- Returns:
- element corresponding to e.
-
valueOf
Get the element from an other word.- Parameters:
w- other word.- Returns:
- w in this word factory.
-
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
Contract word to this word factory.this.isSubFactory(w.mono)must be true, otherwise null is returned.- Parameters:
w- other word to contract.- Returns:
- w with this factory, or null if not contractable.
-
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
Prepare parse from String.- Parameters:
s- String.- Returns:
- a Element corresponding to s.
-
clean
Prepare parse from String.- Parameters:
s- String.- Returns:
- a Element corresponding to s.
-
cleanAll
Prepare parse from String array.- Parameters:
v- String array.- Returns:
- an array of cleaned strings.
-
concat
Concat variable names.- Parameters:
v- an array of strings.- Returns:
- the concatenation of the strings in v.
-
trimAll
Trim all variable names.- Parameters:
v- an array of strings.- Returns:
- an array of strings with all elements trimmed.
-
indexOf
IndexOf for String array.- Parameters:
v- an array of strings.s- string.- Returns:
- index of s in v, or -1 if s is not contained in v.
-
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
Translate variable names.- Parameters:
v- an array of strings.- Returns:
- the translated string of v with respect to t.
-
transVar
Translate variable name.- Parameters:
c- internal char.- Returns:
- the external translated string.
-