001/*
002 * $Id: GreatestCommonDivisor.java 3843 2011-12-29 11:56:02Z kredel $
003 */
004
005package edu.jas.ufd;
006
007
008import java.util.List;
009import java.io.Serializable;
010
011import edu.jas.poly.GenPolynomial;
012import edu.jas.structure.GcdRingElem;
013
014
015/**
016 * Greatest common divisor algorithm interface.
017 * @param <C> coefficient type
018 * @author Heinz Kredel
019 * @usage To create classes that implement this interface use the
020 *        GreatestCommonDivisorFactory. It will select an appropriate
021 *        implementation based on the types of polynomial coefficients CT.
022 * 
023 * <pre>
024 * GreatestCommonDivisor&lt;CT&gt; engine = GCDFactory.&lt;CT&gt; getImplementation(cofac);
025 * c = engine.gcd(a, b);
026 * </pre>
027 * 
028 * For example, if the coefficient type is BigInteger, the usage looks
029 *        like
030 * 
031 * <pre>
032 * BigInteger cofac = new BigInteger();
033 * GreatestCommonDivisor&lt;BigInteger&gt; engine = GCDFactory.getImplementation(cofac);
034 * c = engine.gcd(a, b);
035 * </pre>
036 * 
037 * @see edu.jas.ufd.GCDFactory#getImplementation
038 */
039
040public interface GreatestCommonDivisor<C extends GcdRingElem<C>> extends Serializable {
041
042
043    /**
044     * GenPolynomial content.
045     * @param P GenPolynomial.
046     * @return cont(P).
047     */
048    public GenPolynomial<C> content(GenPolynomial<C> P);
049
050
051    /**
052     * GenPolynomial primitive part.
053     * @param P GenPolynomial.
054     * @return pp(P).
055     */
056    public GenPolynomial<C> primitivePart(GenPolynomial<C> P);
057
058
059    /**
060     * GenPolynomial greatest comon divisor.
061     * @param P GenPolynomial.
062     * @param S GenPolynomial.
063     * @return gcd(P,S).
064     */
065    public GenPolynomial<C> gcd(GenPolynomial<C> P, GenPolynomial<C> S);
066
067
068    /**
069     * GenPolynomial least comon multiple.
070     * @param P GenPolynomial.
071     * @param S GenPolynomial.
072     * @return lcm(P,S).
073     */
074    public GenPolynomial<C> lcm(GenPolynomial<C> P, GenPolynomial<C> S);
075
076
077    /**
078     * GenPolynomial resultant.
079     * The input polynomials are considered as univariate polynomials in the main variable. 
080     * @param P GenPolynomial.
081     * @param S GenPolynomial.
082     * @return res(P,S).
083     * @throws UnsupportedOperationException if there is no implementation in the sub-class.
084     */
085    public GenPolynomial<C> resultant(GenPolynomial<C> P, GenPolynomial<C> S);
086
087
088    /**
089     * GenPolynomial co-prime list.
090     * @param A list of GenPolynomials.
091     * @return B with gcd(b,c) = 1 for all b != c in B and for all non-constant
092     *         a in A there exists b in B with b|a. B does not contain zero or
093     *         constant polynomials.
094     */
095    public List<GenPolynomial<C>> coPrime(List<GenPolynomial<C>> A);
096
097
098    /**
099     * GenPolynomial test for co-prime list.
100     * @param A list of GenPolynomials.
101     * @return true if gcd(b,c) = 1 for all b != c in B, else false.
102     */
103    public boolean isCoPrime(List<GenPolynomial<C>> A);
104
105}