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 by
image(Object)
and inverse(Object)
functions.- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
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 integerMethods 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
-
Field Details
-
ring
the ring -
imageFunc
-
inverseFunc
-
-
Constructor Details
-
ImageRing
-
-
Method Details
-
image
-
image
-
inverse
-
inverse
-
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
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
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
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
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
-
add
Description copied from interface:Ring
Add two elements -
subtract
Description copied from interface:Ring
Subtractsb
froma
-
multiply
Description copied from interface:Ring
Multiplies two elements -
negate
Description copied from interface:Ring
Negates the given element -
increment
Description copied from interface:Ring
Returnselement + 1
-
decrement
Description copied from interface:Ring
Returnselement - 1
-
add
Description copied from interface:Ring
Total of the array of elements -
multiply
Description copied from interface:Ring
Multiplies the array of elements -
abs
Description copied from interface:Ring
Returns the abs value of element (no copy) -
copy
Description copied from interface:Ring
Makes a deep copy of the specified element (for immutable instances the same reference returned). -
divideAndRemainder
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
Description copied from interface:Ring
Returns the quotient ofdividend / divider
-
remainder
Description copied from interface:Ring
Returns the remainder ofdividend / divider
-
reciprocal
Description copied from interface:Ring
Gives the inverse elementelement ^ (-1)
- Specified by:
reciprocal
in interfaceRing<F>
- Parameters:
element
- the element- Returns:
element ^ (-1)
-
getZero
Description copied from interface:Ring
Returns zero element of this ring -
getOne
Description copied from interface:Ring
Returns unit element of this ring (one) -
isZero
Description copied from interface:Ring
Tests whether specified element is zero -
isOne
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
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
Description copied from interface:Ring
Returns ring element associated with specifiedlong
-
valueOfBigInteger
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
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
Description copied from interface:Ring
Returns iterator over ring elements (for finite rings, otherwise throws exception) -
gcd
Description copied from interface:Ring
Returns the greatest common divisor of two elements -
extendedGCD
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
Description copied from interface:Ring
Returns the least common multiple of two elements -
gcd
Description copied from interface:Ring
Returns greatest common divisor of specified elements -
gcd
Description copied from interface:Ring
Returns greatest common divisor of specified elements -
signum
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
Description copied from interface:Ring
Square-free factorization of specified element- Specified by:
factorSquareFree
in interfaceRing<F>
-
factor
Description copied from interface:Ring
Factor specified element -
parse
Description copied from interface:Ring
Parse string into ring element -
pow
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative) -
pow
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative) -
pow
Description copied from interface:Ring
Returnsbase
in a power ofexponent
(non negative) -
factorial
Description copied from interface:Ring
Gives a product ofvalueOf(1) * valueOf(2) * .... * valueOf(num)
-
randomElement
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
- Specified by:
compare
in interfaceComparator<F>
-
equals
- Specified by:
equals
in interfaceComparator<F>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
-