001/*
002 * $Id: MonoidElem.java 4868 2014-07-21 11:34:36Z kredel $
003 */
004
005package edu.jas.structure;
006
007
008/**
009 * Monoid element interface. Defines the multiplicative methods.
010 * @param <C> element type
011 * @author Heinz Kredel
012 */
013
014public interface MonoidElem<C extends MonoidElem<C>> extends Element<C> {
015
016
017    /**
018     * Test if this is one.
019     * @return true if this is 1, else false.
020     */
021    public boolean isONE();
022
023
024    /**
025     * Test if this is a unit. I.e. there exists x with this.multiply(x).isONE()
026     * == true.
027     * @return true if this is a unit, else false.
028     */
029    public boolean isUnit();
030
031
032    /**
033     * Multiply this with S.
034     * @param S
035     * @return this * S.
036     */
037    public C multiply(C S);
038
039
040    /**
041     * Divide this by S.
042     * @param S
043     * @return this / S.
044     */
045    public C divide(C S);
046
047
048    /**
049     * Remainder after division of this by S.
050     * @param S
051     * @return this - (this / S) * S.
052     */
053    public C remainder(C S);
054
055
056    /* for a later release:
057     * Quotient and remainder by division of this by S.
058     * @param S
059     * @return [this/S, this - (this/S)*S].
060     */
061    //public C[] quotientRemainder(C S);
062
063
064    /**
065     * Inverse of this. Some implementing classes will throw
066     * NotInvertibleException if the element is not invertible.
067     * @return x with this * x = 1, if it exists.
068     */
069    public C inverse(); /*throws NotInvertibleException*/
070
071
072    /*
073     * Power of this to the n-th.
074     * @param n integer exponent.
075     * @return a**n, with 0**0 = 0, a**0 = 1 and a**{-n} = {1/a}**n.
076     * Java 8 only
077     */ 
078    //default public C power(long n) {
079    //  //System.out.println("this = " + this + ", n = " + n);
080    //  return Power.<C>power((MonoidFactory<C>)factory(),(C)this,n);
081    //}
082
083}