Package edu.jas.poly

Class WordFactory

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  WordFactory.WordComparator
      Comparator for Words.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.String alphabet
      The data structure is a String of characters which defines the alphabet.
      private static WordFactory.WordComparator horder
      Defined descending order comparator.
      private static org.apache.logging.log4j.Logger logger
      Log4j logger object.
      private static WordFactory.WordComparator lorder
      Defined ascending order comparator.
      Word ONE
      The empty word for this monoid.
      private static java.util.Random random
      Random number generator.
      java.lang.String[] translation
      The translation array of Strings.
      static java.lang.String transRef
      The translation reference string.
    • Constructor Summary

      Constructors 
      Constructor Description
      WordFactory()
      Constructor for WordFactory.
      WordFactory​(java.lang.String s)
      Constructor for WordFactory.
      WordFactory​(java.lang.String[] S)
      Constructor for WordFactory.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String clean​(java.lang.String s)
      Prepare parse from String.
      static java.lang.String[] cleanAll​(java.lang.String[] v)
      Prepare parse from String array.
      static java.lang.String cleanSpace​(java.lang.String s)
      Prepare parse from String.
      static java.lang.String concat​(java.lang.String[] v)
      Concat variable names.
      Word contract​(Word w)
      Contract word to this word factory.
      Word copy​(Word w)
      Copy word.
      boolean equals​(java.lang.Object B)
      Comparison with any other object.
      WordFactory extend​(java.lang.String[] vn)
      Extend variables.
      Word fromInteger​(long a)
      Get the Element for a.
      Word fromInteger​(java.math.BigInteger a)
      Get the Element for a.
      java.util.List<Word> generators()
      Get a list of the generating elements.
      WordFactory.WordComparator getAscendComparator()
      Get the ascending order comparator.
      WordFactory.WordComparator getDescendComparator()
      Get the descending order comparator.
      Word getONE()
      Get the one element, the empty word.
      (package private) java.lang.String[] getTrans()
      Get the translation array of Strings.
      (package private) java.lang.String getVal()
      Get the alphabet String.
      char getVal​(int i)
      Get the alphabet letter at position i.
      java.lang.String[] getVars()
      Get the variable names.
      int hashCode()
      hashCode.
      int indexOf​(char s)
      IndexOf for letter in alphabet.
      static int indexOf​(java.lang.String[] v, java.lang.String s)
      IndexOf for String array.
      boolean isAssociative()
      Query if this monoid is associative.
      boolean isCommutative()
      Query if this monoid is commutative.
      boolean isFinite()
      Is this structure finite or infinite.
      static boolean isSingleLetters​(java.lang.String[] v)
      Test if all variables are single letters.
      boolean isSubFactory​(WordFactory w)
      Test if the alphabet of w is a subalphabet of this.
      int length()
      Get the alphabet length.
      Word parse​(java.io.Reader r)
      Parse from Reader.
      Word parse​(java.lang.String s)
      Parse from String.
      Word random​(int n)
      Generate a random Element with size less equal to n.
      Word random​(int n, java.util.Random random)
      Generate a random Element with size less equal to n.
      java.lang.String toScript()
      Get a scripting compatible string representation.
      java.lang.String toString()
      Get the string representation.
      java.lang.String translate​(java.lang.String[] v)
      Translate variable names.
      java.lang.String transVar​(char c)
      Translate variable name.
      static java.lang.String[] trimAll​(java.lang.String[] v)
      Trim all variable names.
      Word valueOf​(ExpVector e)
      Get the Element for an ExpVector.
      Word valueOf​(Word w)
      Get the element from an other word.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • alphabet

        final java.lang.String alphabet
        The data structure is a String of characters which defines the alphabet.
      • ONE

        public final Word ONE
        The empty word for this monoid.
      • transRef

        public static final java.lang.String transRef
        The translation reference string.
        See Also:
        Constant Field Values
      • translation

        public final java.lang.String[] translation
        The translation array of Strings.
      • random

        private static final java.util.Random random
        Random number generator.
      • logger

        private static final org.apache.logging.log4j.Logger logger
        Log4j logger object.
      • horder

        private static final WordFactory.WordComparator horder
        Defined descending order comparator. Sorts the highest terms first.
      • lorder

        private static final WordFactory.WordComparator lorder
        Defined ascending order comparator. Sorts the lowest terms first.
    • Constructor Detail

      • WordFactory

        public WordFactory()
        Constructor for WordFactory.
      • WordFactory

        public WordFactory​(java.lang.String s)
        Constructor for WordFactory.
        Parameters:
        s - String of single letters for alphabet
      • WordFactory

        public WordFactory​(java.lang.String[] S)
        Constructor for WordFactory.
        Parameters:
        S - String array for alphabet
    • Method Detail

      • isCommutative

        public boolean isCommutative()
        Query if this monoid is commutative.
        Specified by:
        isCommutative in interface MonoidFactory<Word>
        Returns:
        true if this monoid is commutative, else false.
      • isAssociative

        public boolean isAssociative()
        Query if this monoid is associative.
        Specified by:
        isAssociative in interface MonoidFactory<Word>
        Returns:
        true if this monoid is associative, else false.
      • getONE

        public Word getONE()
        Get the one element, the empty word.
        Specified by:
        getONE in interface MonoidFactory<Word>
        Returns:
        1 as Word.
      • copy

        public Word copy​(Word w)
        Copy word.
        Specified by:
        copy in interface ElemFactory<Word>
        Parameters:
        w - word to copy.
        Returns:
        copy of w.
      • length

        public int length()
        Get the alphabet length.
        Returns:
        alphabet.length.
      • getVal

        java.lang.String getVal()
        Get the alphabet String.
        Returns:
        alphabet.
      • getTrans

        java.lang.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

        public java.lang.String[] getVars()
        Get the variable names.
        Returns:
        array of variable names
      • extend

        public WordFactory extend​(java.lang.String[] vn)
        Extend variables. Extend number of variables by length(vn).
        Parameters:
        vn - names for extended variables.
        Returns:
        extended word ring factory.
      • toString

        public java.lang.String toString()
        Get the string representation.
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()
      • toScript

        public java.lang.String toScript()
        Get a scripting compatible string representation.
        Specified by:
        toScript in interface ElemFactory<Word>
        Returns:
        script compatible representation for this Element.
        See Also:
        Element.toScript()
      • equals

        public boolean equals​(java.lang.Object B)
        Comparison with any other object.
        Overrides:
        equals in class java.lang.Object
        See Also:
        Object.equals(java.lang.Object)
      • hashCode

        public int hashCode()
        hashCode.
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • generators

        public java.util.List<Word> generators()
        Get a list of the generating elements.
        Specified by:
        generators in interface ElemFactory<Word>
        Returns:
        list of generators for the algebraic structure.
      • fromInteger

        public Word fromInteger​(long a)
        Get the Element for a.
        Specified by:
        fromInteger in interface ElemFactory<Word>
        Parameters:
        a - long
        Returns:
        element corresponding to a.
      • fromInteger

        public Word fromInteger​(java.math.BigInteger a)
        Get the Element for a.
        Specified by:
        fromInteger in interface ElemFactory<Word>
        Parameters:
        a - java.math.BigInteger.
        Returns:
        element corresponding to a.
      • valueOf

        public Word valueOf​(ExpVector e)
        Get the Element for an ExpVector.
        Parameters:
        e - ExpVector.
        Returns:
        element corresponding to e.
      • valueOf

        public Word valueOf​(Word w)
        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

        public Word random​(int n)
        Generate a random Element with size less equal to n.
        Specified by:
        random in interface ElemFactory<Word>
        Parameters:
        n -
        Returns:
        a random element.
      • random

        public Word random​(int n,
                           java.util.Random random)
        Generate a random Element with size less equal to n.
        Specified by:
        random in interface ElemFactory<Word>
        Parameters:
        n -
        random - is a source for random bits.
        Returns:
        a random element.
      • parse

        public Word parse​(java.lang.String s)
        Parse from String.
        Specified by:
        parse in interface ElemFactory<Word>
        Parameters:
        s - String.
        Returns:
        a Element corresponding to s.
      • parse

        public Word parse​(java.io.Reader r)
        Parse from Reader. White space is delimiter for word.
        Specified by:
        parse in interface ElemFactory<Word>
        Parameters:
        r - Reader.
        Returns:
        the next Element found on r.
      • isSubFactory

        public boolean isSubFactory​(WordFactory w)
        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

        public Word contract​(Word w)
        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

        public WordFactory.WordComparator getDescendComparator()
        Get the descending order comparator. Sorts the highest terms first.
        Returns:
        horder.
      • getAscendComparator

        public WordFactory.WordComparator getAscendComparator()
        Get the ascending order comparator. Sorts the lowest terms first.
        Returns:
        lorder.
      • cleanSpace

        public static java.lang.String cleanSpace​(java.lang.String s)
        Prepare parse from String.
        Parameters:
        s - String.
        Returns:
        a Element corresponding to s.
      • clean

        public static java.lang.String clean​(java.lang.String s)
        Prepare parse from String.
        Parameters:
        s - String.
        Returns:
        a Element corresponding to s.
      • cleanAll

        public static java.lang.String[] cleanAll​(java.lang.String[] v)
        Prepare parse from String array.
        Parameters:
        v - String array.
        Returns:
        an array of cleaned strings.
      • concat

        public static java.lang.String concat​(java.lang.String[] v)
        Concat variable names.
        Parameters:
        v - an array of strings.
        Returns:
        the concatenation of the strings in v.
      • trimAll

        public static java.lang.String[] trimAll​(java.lang.String[] v)
        Trim all variable names.
        Parameters:
        v - an array of strings.
        Returns:
        an array of strings with all elements trimmed.
      • indexOf

        public static int indexOf​(java.lang.String[] v,
                                  java.lang.String s)
        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

        public static boolean isSingleLetters​(java.lang.String[] v)
        Test if all variables are single letters.
        Parameters:
        v - an array of strings.
        Returns:
        true, if all variables have length 1, else false.
      • translate

        public java.lang.String translate​(java.lang.String[] v)
        Translate variable names.
        Parameters:
        v - an array of strings.
        Returns:
        the translated string of v with respect to t.
      • transVar

        public java.lang.String transVar​(char c)
        Translate variable name.
        Parameters:
        c - internal char.
        Returns:
        the external translated string.