Package edu.jas.ufd

Class GCDFactory


  • public class GCDFactory
    extends java.lang.Object
    Greatest common divisor algorithms factory. Select appropriate GCD engine based on the coefficient types.

    Usage: To create objects that implement the GreatestCommonDivisor interface use the GCDFactory. It will select an appropriate implementation based on the types of polynomial coefficients C. There are two methods to obtain an implementation: getProxy() and getImplementation(). getImplementation() returns an object of a class which implements the GreatestCommonDivisor interface. getProxy() returns a proxy object of a class which implements the GreatestCommonDivisorr interface. The proxy will run two implementations in parallel, return the first computed result and cancel the second running task. On systems with one CPU the computing time will be two times the time of the fastest algorithm implementation. On systems with more than two CPUs the computing time will be the time of the fastest algorithm implementation.

     GreatestCommonDivisor<CT> engine;
     engine = GCDFactory.<CT> getImplementation(cofac);
     or engine = GCDFactory.<CT> getProxy(cofac);
     c = engine.gcd(a, b);
     

    For example, if the coefficient type is BigInteger, the usage looks like

     BigInteger cofac = new BigInteger();
     GreatestCommonDivisor<BigInteger> engine;
     engine = GCDFactory.getImplementation(cofac);
     or engine = GCDFactory.getProxy(cofac);
     c = engine.gcd(a, b);
     

    TODO: Base decision also on degree vectors and number of variables of polynomials. Incorporate also number of CPUs / threads available (done with GCDProxy).

    Author:
    Heinz Kredel
    See Also:
    GreatestCommonDivisor.gcd(edu.jas.poly.GenPolynomial P, edu.jas.poly.GenPolynomial S)