001/*
002 * $Id: Factorization.java 3068 2010-04-11 17:27:16Z kredel $
003 */
004
005package edu.jas.ufd;
006
007
008import java.io.Serializable;
009import java.util.List;
010import java.util.SortedMap;
011
012import edu.jas.poly.GenPolynomial;
013import edu.jas.structure.GcdRingElem;
014
015
016/**
017 * Factorization algorithms interface.
018 * @usage To create objects that implement the <code>Factorization</code>
019 *        interface use the <code>FactorFactory</code>. It will select an
020 *        appropriate implementation based on the types of polynomial
021 *        coefficients C. To obtain an implementation use
022 *        <code>getImplementation()</code>, it returns an object of a class
023 *        which extends the <code>FactorAbstract</code> class which implements
024 *        the <code>Factorization</code> interface.
025 * 
026 * <pre>
027 * Factorization&lt;CT&gt; engine;
028 * engine = FactorFactory.&lt;CT&gt; getImplementation(cofac);
029 * c = engine.factors(a);
030 * </pre>
031 * 
032 * For example, if the coefficient type is BigInteger, the usage looks
033 *        like
034 * 
035 * <pre>
036 * BigInteger cofac = new BigInteger();
037 * Factorization&lt;BigInteger&gt; engine;
038 * engine = FactorFactory.getImplementation(cofac);
039 * Sm = engine.factors(poly);
040 * </pre>
041 * 
042 * @see edu.jas.ufd.FactorFactory#getImplementation
043 * @author Heinz Kredel
044 * @param <C> coefficient type
045 */
046
047public interface Factorization<C extends GcdRingElem<C>> extends Serializable {
048
049
050    /**
051     * GenPolynomial test if is irreducible.
052     * @param P GenPolynomial.
053     * @return true if P is irreducible, else false.
054     */
055    public boolean isIrreducible(GenPolynomial<C> P);
056
057
058    /**
059     * GenPolynomial test if a non trivial factorization exsists.
060     * @param P GenPolynomial.
061     * @return true if P is reducible, else false.
062     */
063    public boolean isReducible(GenPolynomial<C> P);
064
065
066    /**
067     * GenPolynomial test if is squarefree.
068     * @param P GenPolynomial.
069     * @return true if P is squarefree, else false.
070     */
071    public boolean isSquarefree(GenPolynomial<C> P);
072
073
074    /**
075     * GenPolynomial factorization of a squarefree polynomial.
076     * @param P squarefree and primitive! or monic! GenPolynomial.
077     * @return [p_1,...,p_k] with P = prod_{i=1,...,r} p_i.
078     */
079    public List<GenPolynomial<C>> factorsSquarefree(GenPolynomial<C> P);
080
081
082    /**
083     * GenPolynomial factorization.
084     * @param P GenPolynomial.
085     * @return [p_1 -&gt; e_1, ..., p_k -&gt; e_k] with P = prod_{i=1,...,k} p_i**e_i.
086     */
087    public SortedMap<GenPolynomial<C>, Long> factors(GenPolynomial<C> P);
088
089
090    /**
091     * GenPolynomial factorization ignoring multiplicities.
092     * @param P GenPolynomial.
093     * @return [p_1, ..., p_k] with P = prod_{i=1,...,k} p_i**{e_i} for some e_i.
094     */
095    public List<GenPolynomial<C>> factorsRadical(GenPolynomial<C> P);
096
097
098    /**
099     * GenPolynomial greatest squarefree divisor.
100     * @param P GenPolynomial.
101     * @return squarefree(P).
102     */
103    public GenPolynomial<C> squarefreePart(GenPolynomial<C> P);
104
105
106    /**
107     * GenPolynomial squarefree factorization.
108     * @param P GenPolynomial.
109     * @return [p_1 -&gt; e_1, ..., p_k -&gt; e_k] with P = prod_{i=1,...,k} p_i^{e_i}
110     *         and p_i squarefree.
111     */
112    public SortedMap<GenPolynomial<C>, Long> squarefreeFactors(GenPolynomial<C> P);
113
114
115    /**
116     * GenPolynomial is factorization.
117     * @param P GenPolynomial
118     * @param F = [p_1,...,p_k].
119     * @return true if P = prod_{i=1,...,r} p_i, else false.
120     */
121    public boolean isFactorization(GenPolynomial<C> P, List<GenPolynomial<C>> F);
122
123
124    /**
125     * GenPolynomial is factorization.
126     * @param P GenPolynomial.
127     * @param F = [p_1 -&gt; e_1, ..., p_k -&gt; e_k].
128     * @return true if P = prod_{i=1,...,k} p_i**e_i , else false.
129     */
130    public boolean isFactorization(GenPolynomial<C> P, SortedMap<GenPolynomial<C>, Long> F);
131
132}