001/*
002 * $Id$
003 */
004
005package edu.jas.structure;
006
007
008/**
009 * Ring element interface. Combines additive and multiplicative methods. Adds
010 * also gcd because of polynomials.
011 * @param <C> ring element type
012 * @author Heinz Kredel
013 */
014
015public interface RingElem<C extends RingElem<C>> extends AbelianGroupElem<C>, MonoidElem<C> {
016
017
018    /**
019     * Greatest common divisor.
020     * @param b other element.
021     * @return gcd(this,b).
022     */
023    public C gcd(C b);
024
025
026    /**
027     * Extended greatest common divisor.
028     * @param b other element.
029     * @return [ gcd(this,b), c1, c2 ] with c1*this + c2*b = gcd(this,b).
030     */
031    public C[] egcd(C b);
032
033
034    /**
035     * Left greatest common divisor.
036     * Returns commutative greatest common divisor if not overwritten.
037     * @param b other element.
038     * @return leftGcd(this,b).
039     */
040    default public C leftGcd(C b) {
041        return gcd(b);
042    }
043
044
045    /**
046     * Right greatest common divisor.
047     * Returns commutative greatest common divisor if not overwritten.
048     * @param b other element.
049     * @return rightGcd(this,b).
050     */
051    default public C rightGcd(C b) {
052        return gcd(b);
053    }
054
055}