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