Class SGCDFactory
Usage: To create objects that implement the
GreatestCommonDivisor
interface use the
SGCDFactory
. 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 GreatestCommonDivisor
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 = SGCDFactory.<CT> getImplementation(cofac); or engine = SGCDFactory.<CT> getProxy(cofac); c = engine.leftGcd(a, b);
For example, if the coefficient type is BigInteger
, the usage
looks like
BigInteger cofac = new BigInteger(); GreatestCommonDivisor<BigInteger> engine; engine = SGCDFactory.getImplementation(cofac); or engine = SGCDFactory.getProxy(cofac); c = engine.leftGcd(a, b);
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends GcdRingElem<C>>
GreatestCommonDivisorAbstract<C> getFakeImplementation
(RingFactory<C> fac) Determine fake implementation of gcd algorithms, other cases.Determine suitable implementation of gcd algorithms, case BigInteger.Determine suitable implementation of gcd algorithms, case BigRational.Determine suitable implementation of gcd algorithms, case ModInteger.static GreatestCommonDivisorAbstract
<ModLong> Determine suitable implementation of gcd algorithms, case ModLong.static <C extends GcdRingElem<C>>
GreatestCommonDivisorAbstract<C> getImplementation
(RingFactory<C> fac) Determine suitable implementation of gcd algorithms, other cases.getProxy
(BigInteger fac) Determine suitable proxy for gcd algorithms, case BigInteger.getProxy
(BigRational fac) Determine suitable proxy for gcd algorithms, case BigRational.getProxy
(ModIntegerRing fac) Determine suitable proxy for gcd algorithms, case ModInteger.static GreatestCommonDivisorAbstract
<ModLong> getProxy
(ModLongRing fac) Determine suitable proxy for gcd algorithms, case ModLong.static <C extends GcdRingElem<C>>
GreatestCommonDivisorAbstract<C> getProxy
(RingFactory<C> fac) Determine suitable proxy for gcd algorithms, other cases.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger
-
-
Constructor Details
-
SGCDFactory
protected SGCDFactory()Protected factory constructor.
-
-
Method Details
-
getImplementation
Determine suitable implementation of gcd algorithms, case ModLong.- Parameters:
fac
- ModLongRing.- Returns:
- gcd algorithm implementation.
-
getProxy
Determine suitable proxy for gcd algorithms, case ModLong.- Parameters:
fac
- ModLongRing.- Returns:
- gcd algorithm implementation.
-
getImplementation
Determine suitable implementation of gcd algorithms, case ModInteger.- Parameters:
fac
- ModIntegerRing.- Returns:
- gcd algorithm implementation.
-
getProxy
Determine suitable proxy for gcd algorithms, case ModInteger.- Parameters:
fac
- ModIntegerRing.- Returns:
- gcd algorithm implementation.
-
getImplementation
Determine suitable implementation of gcd algorithms, case BigInteger.- Parameters:
fac
- BigInteger.- Returns:
- gcd algorithm implementation.
-
getProxy
Determine suitable proxy for gcd algorithms, case BigInteger.- Parameters:
fac
- BigInteger.- Returns:
- gcd algorithm implementation.
-
getImplementation
Determine suitable implementation of gcd algorithms, case BigRational.- Parameters:
fac
- BigRational.- Returns:
- gcd algorithm implementation.
-
getProxy
Determine suitable proxy for gcd algorithms, case BigRational.- Parameters:
fac
- BigRational.- Returns:
- gcd algorithm implementation.
-
getImplementation
public static <C extends GcdRingElem<C>> GreatestCommonDivisorAbstract<C> getImplementation(RingFactory<C> fac) Determine suitable implementation of gcd algorithms, other cases.- Parameters:
fac
- RingFactory<C>.- Returns:
- gcd algorithm implementation.
-
getFakeImplementation
public static <C extends GcdRingElem<C>> GreatestCommonDivisorAbstract<C> getFakeImplementation(RingFactory<C> fac) Determine fake implementation of gcd algorithms, other cases.- Parameters:
fac
- RingFactory<C>.- Returns:
- fake gcd algorithm implementation.
-
getProxy
public static <C extends GcdRingElem<C>> GreatestCommonDivisorAbstract<C> getProxy(RingFactory<C> fac) Determine suitable proxy for gcd algorithms, other cases.- Parameters:
fac
- RingFactory<C>.- Returns:
- gcd algorithm implementation. Note: This method contains a hack for Google app engine to not use threads.
- See Also:
-