001 /* 002 * $Id: GreatestCommonDivisor.java 3079 2010-04-19 20:53:23Z kredel $ 003 */ 004 005 package edu.jas.ufd; 006 007 008 import java.util.List; 009 import java.io.Serializable; 010 011 import edu.jas.poly.GenPolynomial; 012 import 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<CT> engine = GCDFactory.<CT> 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<BigInteger> engine = GCDFactory.getImplementation(cofac); 034 * c = engine.gcd(a, b); 035 * </pre> 036 * 037 * @see edu.jas.ufd.GCDFactory#getImplementation 038 */ 039 040 public 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 * @see edu.jas.ufd.GreatestCommonDivisorSubres#recursiveResultant 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 co-prime list. 100 * @param a GenPolynomial. 101 * @param P co-prime list of GenPolynomials. 102 * @return B with gcd(b,c) = 1 for all b != c in B and for non-constant a 103 * there exists b in P with b|a. B does not contain zero or constant 104 * polynomials. 105 */ 106 public List<GenPolynomial<C>> coPrime(GenPolynomial<C> a, List<GenPolynomial<C>> P); 107 108 109 /** 110 * GenPolynomial test for co-prime list. 111 * @param A list of GenPolynomials. 112 * @return true if gcd(b,c) = 1 for all b != c in B, else false. 113 */ 114 public boolean isCoPrime(List<GenPolynomial<C>> A); 115 116 117 /** 118 * GenPolynomial test for co-prime list of given list. 119 * @param A list of GenPolynomials. 120 * @param P list of co-prime GenPolynomials. 121 * @return true if isCoPrime(P) and for all a in A exists p in P with p | a, 122 * else false. 123 */ 124 public boolean isCoPrime(List<GenPolynomial<C>> P, List<GenPolynomial<C>> A); 125 126 }