Package cc.redberry.rings
Class ImageRing<F,I>
- java.lang.Object
-
- cc.redberry.rings.ImageRing<F,I>
-
- All Implemented Interfaces:
IParser<I>
,Stringifiable<I>
,Ring<I>
,Serializable
,Iterable<I>
,Comparator<I>
- Direct Known Subclasses:
MultipleFieldExtension
public class ImageRing<F,I> extends Object implements Ring<I>
A ring obtained via isomorphism specified byimage(Object)
andinverse(Object)
functions.- See Also:
- Serialized Form
-
-
Method Summary
Modifier and Type Method Description I
abs(I el)
Returns the abs value of element (no copy)I
add(I... elements)
Total of the array of elementsI
add(I a, I b)
Add two elementsBigInteger
cardinality()
Returns the number of elements in this ring (cardinality) or null if ring is infiniteBigInteger
characteristic()
Returns characteristic of this ringint
compare(I o1, I o2)
I
copy(I element)
Makes a deep copy of the specified element (for immutable instances the same reference returned).I
decrement(I element)
Returnselement - 1
I[]
divideAndRemainder(I dividend, I divider)
Returns quotient and remainder ofdividend / divider
boolean
equals(Object o)
I[]
extendedGCD(I a, I b)
Returns array of[gcd(a,b), s, t]
such thats * a + t * b = gcd(a, b)
FactorDecomposition<I>
factor(I element)
Factor specified elementI
factorial(long num)
Gives a product ofvalueOf(1) * valueOf(2) * .... * valueOf(num)
FactorDecomposition<I>
factorSquareFree(I element)
Square-free factorization of specified elementI
gcd(I... elements)
Returns greatest common divisor of specified elementsI
gcd(I a, I b)
Returns the greatest common divisor of two elementsI
gcd(Iterable<I> elements)
Returns greatest common divisor of specified elementsI
getOne()
Returns unit element of this ring (one)I
getZero()
Returns zero element of this ringint
hashCode()
I
image(F el)
I[]
image(F[] el)
I
increment(I element)
Returnselement + 1
F
inverse(I el)
F[]
inverse(I[] el)
boolean
isEuclideanRing()
Returns whether this ring is a Euclidean ringboolean
isField()
Returns whether this ring is a fieldboolean
isOne(I element)
Tests whether specified element is one (exactly)boolean
isPerfectPower()
Returns whether the cardinality is a perfect power (p^k with k > 1)boolean
isUnit(I element)
Tests whether specified element is a ring unitboolean
isZero(I element)
Tests whether specified element is zeroIterator<I>
iterator()
Returns iterator over ring elements (for finite rings, otherwise throws exception)I
lcm(I a, I b)
Returns the least common multiple of two elementsI
multiply(I... elements)
Multiplies the array of elementsI
multiply(I a, I b)
Multiplies two elementsI
negate(I element)
Negates the given elementI
parse(String string)
Parse string into ring elementBigInteger
perfectPowerBase()
Returnsbase
so thatcardinality == base^exponent
or null if cardinality is not finiteBigInteger
perfectPowerExponent()
Returnsexponent
so thatcardinality == base^exponent
or null if cardinality is not finiteI
pow(I base, int exponent)
Returnsbase
in a power ofexponent
(non negative)I
pow(I base, long exponent)
Returnsbase
in a power ofexponent
(non negative)I
pow(I base, BigInteger exponent)
Returnsbase
in a power ofexponent
(non negative)I
quotient(I dividend, I divider)
Returns the quotient ofdividend / divider
I
randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Returns a random element from this ringI
reciprocal(I element)
Gives the inverse elementelement ^ (-1)
I
remainder(I dividend, I divider)
Returns the remainder ofdividend / divider
int
signum(I element)
Returns -1 ifelement < 0
, 0 ifelement == 0
and 1 ifelement > 0
, where comparison is specified byComparator.compare(Object, Object)
I
subtract(I a, I b)
Subtractsb
froma
I
valueOf(long val)
Returns ring element associated with specifiedlong
I
valueOf(I val)
Converts a value from other ring to this ring.I
valueOfBigInteger(BigInteger val)
Returns ring element associated with specified integer-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface cc.redberry.rings.Ring
addMutable, createArray, createArray, createArray, createArray, createArray2d, createArray2d, createZeroesArray, createZeroesArray2d, divideExact, divideExactMutable, divideOrNull, fillZeros, firstBezoutCoefficient, getNegativeOne, isFinite, isFiniteField, isMinusOne, isUnitOrZero, lcm, lcm, max, min, multiply, multiply, multiplyMutable, negateMutable, randomElement, randomElementTree, randomElementTree, randomNonZeroElement, setToValueOf, subtractMutable, valueOf
-
Methods inherited from interface cc.redberry.rings.io.Stringifiable
toString
-
-
-
-
Method Detail
-
isField
public boolean isField()
Description copied from interface:Ring
Returns whether this ring is a field
-
isEuclideanRing
public boolean isEuclideanRing()
Description copied from interface:Ring
Returns whether this ring is a Euclidean ring- Specified by:
isEuclideanRing
in interfaceRing<F>
- Returns:
- whether this ring is a Euclidean ring
-
cardinality
public BigInteger cardinality()
Description copied from interface:Ring
Returns the number of elements in this ring (cardinality) or null if ring is infinite- Specified by:
cardinality
in interfaceRing<F>
- Returns:
- the number of elements in this ring (cardinality) or null if ring is infinite
-
characteristic
public BigInteger characteristic()
Description copied from interface:Ring
Returns characteristic of this ring- Specified by:
characteristic
in interfaceRing<F>
- Returns:
- characteristic of this ring
-
isPerfectPower
public boolean isPerfectPower()
Description copied from interface:Ring
Returns whether the cardinality is a perfect power (p^k with k > 1)- Specified by:
isPerfectPower
in interfaceRing<F>
- Returns:
- whether the cardinality is a perfect power (p^k with k > 1)
-
perfectPowerBase
public BigInteger perfectPowerBase()
Description copied from interface:Ring
Returnsbase
so thatcardinality == base^exponent
or null if cardinality is not finite- Specified by:
perfectPowerBase
in interfaceRing<F>
- Returns:
base
so thatcardinality == base^exponent
or null if cardinality is not finite
-
perfectPowerExponent
public BigInteger perfectPowerExponent()
Description copied from interface:Ring
Returnsexponent
so thatcardinality == base^exponent
or null if cardinality is not finite- Specified by:
perfectPowerExponent
in interfaceRing<F>
- Returns:
exponent
so thatcardinality == base^exponent
or null if cardinality is not finite
-
multiply
public I multiply(I a, I b)
Description copied from interface:Ring
Multiplies two elements
-
negate
public I negate(I element)
Description copied from interface:Ring
Negates the given element
-
increment
public I increment(I element)
Description copied from interface:Ring
Returnselement + 1
-
decrement
public I decrement(I element)
Description copied from interface:Ring
Returnselement - 1
-
add
public I add(I... elements)
Description copied from interface:Ring
Total of the array of elements
-
multiply
public I multiply(I... elements)
Description copied from interface:Ring
Multiplies the array of elements
-
abs
public I abs(I el)
Description copied from interface:Ring
Returns the abs value of element (no copy)
-
copy
public I copy(I element)
Description copied from interface:Ring
Makes a deep copy of the specified element (for immutable instances the same reference returned).
-
divideAndRemainder
public I[] divideAndRemainder(I dividend, I divider)
Description copied from interface:Ring
Returns quotient and remainder ofdividend / divider
- Specified by:
divideAndRemainder
in interfaceRing<F>
- Parameters:
dividend
- the dividenddivider
- the divider- Returns:
{quotient, remainder}
-
quotient
public I quotient(I dividend, I divider)
Description copied from interface:Ring
Returns the quotient ofdividend / divider
-
remainder
public I remainder(I dividend, I divider)
Description copied from interface:Ring
Returns the remainder ofdividend / divider
-
reciprocal
public I reciprocal(I element)
Description copied from interface:Ring
Gives the inverse elementelement ^ (-1)
- Specified by:
reciprocal
in interfaceRing<F>
- Parameters:
element
- the element- Returns:
element ^ (-1)
-
getZero
public I getZero()
Description copied from interface:Ring
Returns zero element of this ring
-
getOne
public I getOne()
Description copied from interface:Ring
Returns unit element of this ring (one)
-
isZero
public boolean isZero(I element)
Description copied from interface:Ring
Tests whether specified element is zero
-
isOne
public boolean isOne(I element)
Description copied from interface:Ring
Tests whether specified element is one (exactly)- Specified by:
isOne
in interfaceRing<F>
- Parameters:
element
- the ring element- Returns:
- whether specified element is exactly one
- See Also:
Ring.isUnit(Object)
-
isUnit
public boolean isUnit(I element)
Description copied from interface:Ring
Tests whether specified element is a ring unit- Specified by:
isUnit
in interfaceRing<F>
- Parameters:
element
- the ring element- Returns:
- whether specified element is a ring unit
- See Also:
Ring.isOne(Object)
-
valueOf
public I valueOf(long val)
Description copied from interface:Ring
Returns ring element associated with specifiedlong
-
valueOfBigInteger
public I valueOfBigInteger(BigInteger val)
Description copied from interface:Ring
Returns ring element associated with specified integer- Specified by:
valueOfBigInteger
in interfaceRing<F>
- Parameters:
val
- integer- Returns:
- ring element associated with specified integer
-
valueOf
public I valueOf(I val)
Description copied from interface:Ring
Converts a value from other ring to this ring. The result is not guarantied to be a new instance (i.e.val == valueOf(val)
is possible).
-
iterator
public Iterator<I> iterator()
Description copied from interface:Ring
Returns iterator over ring elements (for finite rings, otherwise throws exception)
-
gcd
public I gcd(I a, I b)
Description copied from interface:Ring
Returns the greatest common divisor of two elements
-
extendedGCD
public I[] extendedGCD(I a, I b)
Description copied from interface:Ring
Returns array of[gcd(a,b), s, t]
such thats * a + t * b = gcd(a, b)
- Specified by:
extendedGCD
in interfaceRing<F>
-
lcm
public I lcm(I a, I b)
Description copied from interface:Ring
Returns the least common multiple of two elements
-
gcd
public I gcd(I... elements)
Description copied from interface:Ring
Returns greatest common divisor of specified elements
-
gcd
public I gcd(Iterable<I> elements)
Description copied from interface:Ring
Returns greatest common divisor of specified elements
-
signum
public int signum(I element)
Description copied from interface:Ring
Returns -1 ifelement < 0
, 0 ifelement == 0
and 1 ifelement > 0
, where comparison is specified byComparator.compare(Object, Object)
-
factorSquareFree
public FactorDecomposition<I> factorSquareFree(I element)
Description copied from interface:Ring
Square-free factorization of specified element- Specified by:
factorSquareFree
in interfaceRing<F>
-
factor
public FactorDecomposition<I> factor(I element)
Description copied from interface:Ring
Factor specified element
-
parse
public I parse(String string)
Description copied from interface:Ring
Parse string into ring element
-
pow
public I pow(I base, int exponent)
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative)
-
pow
public I pow(I base, long exponent)
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative)
-
pow
public I pow(I base, BigInteger exponent)
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative)
-
factorial
public I factorial(long num)
Description copied from interface:Ring
Gives a product ofvalueOf(1) * valueOf(2) * .... * valueOf(num)
-
randomElement
public I randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Description copied from interface:Ring
Returns a random element from this ring- Specified by:
randomElement
in interfaceRing<F>
- Parameters:
rnd
- the source of randomness- Returns:
- random element from this ring
-
compare
public int compare(I o1, I o2)
- Specified by:
compare
in interfaceComparator<F>
-
equals
public boolean equals(Object o)
- Specified by:
equals
in interfaceComparator<F>
- Overrides:
equals
in classObject
-
-