E - the type of objects that may be operated by this ringpublic interface Ring<E> extends Comparator<E>, Iterable<E>, IParser<E>, Stringifiable<E>, Serializable
Ring interface include all field operations,
though the particular implementations may represent a more restricted rings (general rings, Euclidean rings etc.), in
which case some field operations (e.g. reciprocal) are not applicable (will throw exception).| Modifier and Type | Method and Description |
|---|---|
default E |
abs(E el)
Returns the abs value of element (no copy)
|
default E |
add(E... elements)
Total of the array of elements
|
E |
add(E a,
E b)
Add two elements
|
default E |
addMutable(E a,
E b)
Adds two elements and destroys the initial content of
a. |
BigInteger |
cardinality()
Returns the number of elements in this ring (cardinality) or null if ring is infinite
|
BigInteger |
characteristic()
Returns characteristic of this ring
|
E |
copy(E element)
Makes a deep copy of the specified element (for immutable instances the same reference returned).
|
default E[] |
createArray(E element)
Creates generic array with single element
|
default E[] |
createArray(E a,
E b)
Creates generic array of
{a, b} |
default E[] |
createArray(E a,
E b,
E c)
Creates generic array of
{a, b, c} |
default E[] |
createArray(int length)
Creates generic array of ring elements of specified length
|
default E[][] |
createArray2d(int length)
Creates 2d array of ring elements of specified length
|
default E[][] |
createArray2d(int m,
int n)
Creates 2d array of ring elements of specified shape
|
default E[] |
createZeroesArray(int length)
Creates array filled with zero elements
|
default E[][] |
createZeroesArray2d(int m,
int n)
Creates 2d array of ring elements of specified shape filled with zero elements
|
default E |
decrement(E element)
Returns
element - 1 |
E[] |
divideAndRemainder(E dividend,
E divider)
Returns quotient and remainder of
dividend / divider |
default E |
divideExact(E dividend,
E divider)
Divides
dividend by divider or throws ArithmeticException if exact division is not
possible |
default E |
divideExactMutable(E dividend,
E divider)
Internal API
|
default E |
divideOrNull(E dividend,
E divider)
Divides
dividend by divider or returns null if exact division is not possible |
default E[] |
extendedGCD(E a,
E b)
Returns array of
[gcd(a,b), s, t] such that s * a + t * b = gcd(a, b) |
default FactorDecomposition<E> |
factor(E element)
Factor specified element
|
default E |
factorial(long num)
Gives a product of {@code valueOf(1) * valueOf(2) * ....
|
default FactorDecomposition<E> |
factorSquareFree(E element)
Square-free factorization of specified element
|
default void |
fillZeros(E[] array)
Fills array with zeros
|
default E[] |
firstBezoutCoefficient(E a,
E b)
Returns array of
[gcd(a,b), s] such that s * a + t * b = gcd(a, b) |
default E |
gcd(E... elements)
Returns greatest common divisor of specified elements
|
default E |
gcd(E a,
E b)
Returns the greatest common divisor of two elements
|
default E |
gcd(Iterable<E> elements)
Returns greatest common divisor of specified elements
|
default E |
getNegativeOne()
Returns negative unit element of this ring (minus one)
|
E |
getOne()
Returns unit element of this ring (one)
|
E |
getZero()
Returns zero element of this ring
|
default E |
increment(E element)
Returns
element + 1 |
boolean |
isEuclideanRing()
Returns whether this ring is a Euclidean ring
|
boolean |
isField()
Returns whether this ring is a field
|
default boolean |
isFinite()
Returns whether this ring is finite
|
default boolean |
isFiniteField()
Returns whether this ring is a finite field
|
default boolean |
isMinusOne(E e)
Tests whether specified element is minus one
|
boolean |
isOne(E 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(E element)
Tests whether specified element is a ring unit
|
default boolean |
isUnitOrZero(E element)
Tests whether specified element is a ring unit or zero
|
boolean |
isZero(E element)
Tests whether specified element is zero
|
Iterator<E> |
iterator()
Returns iterator over ring elements (for finite rings, otherwise throws exception)
|
default E |
lcm(E... elements)
Returns the least common multiple of two elements
|
default E |
lcm(E a,
E b)
Returns the least common multiple of two elements
|
default E |
lcm(Iterable<E> elements)
Returns the least common multiple of two elements
|
default E |
max(E a,
E b)
Returns the max value (no copy)
|
default E |
min(E a,
E b)
Returns the min value (no copy)
|
default E |
multiply(E... elements)
Multiplies the array of elements
|
E |
multiply(E a,
E b)
Multiplies two elements
|
default E |
multiply(E a,
long b)
Multiplies two elements
|
default E |
multiply(Iterable<E> elements)
Multiplies the array of elements
|
default E |
multiplyMutable(E a,
E b)
Multiplies two elements and destroys the initial content of
a |
E |
negate(E element)
Negates the given element
|
default E |
negateMutable(E element)
Negates the given element and destroys the initial content of
element |
default E |
parse(String string)
Parse string into ring element
|
BigInteger |
perfectPowerBase()
Returns
base so that cardinality == base^exponent or null if cardinality is not finite |
BigInteger |
perfectPowerExponent()
Returns
exponent so that cardinality == base^exponent or null if cardinality is not finite |
default E |
pow(E base,
BigInteger exponent)
Returns
base in a power of exponent (non negative) |
default E |
pow(E base,
int exponent)
Returns
base in a power of exponent (non negative) |
default E |
pow(E base,
long exponent)
Returns
base in a power of exponent (non negative) |
default E |
quotient(E dividend,
E divider)
Returns the quotient of
dividend / divider |
default E |
randomElement()
Returns a random element from this ring
|
default E |
randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Returns a random element from this ring
|
default E |
randomElementTree()
If this ring has a complicated nested structure, this method guaranties that the resulting random element will
reflect ring complicated structure, i.e.
|
default E |
randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)
If this ring has a complicated nested structure, this method guaranties that the resulting random element will
reflect ring complicated structure, i.e.
|
default E |
randomNonZeroElement(org.apache.commons.math3.random.RandomGenerator rnd)
Returns a random non zero element from this ring
|
E |
reciprocal(E element)
Gives the inverse element
element ^ (-1) |
default E |
remainder(E dividend,
E divider)
Returns the remainder of
dividend / divider |
default void |
setToValueOf(E[] elements)
Applies
valueOf(Object) inplace to the specified array |
default int |
signum(E element)
Returns -1 if
element < 0, 0 if element == 0 and 1 if element > 0, where comparison is
specified by Comparator.compare(Object, Object) |
E |
subtract(E a,
E b)
Subtracts
b from a |
default E |
subtractMutable(E a,
E b)
Subtracts
b from a and destroys the initial content of a |
E |
valueOf(E val)
Converts a value from other ring to this ring.
|
E |
valueOf(long val)
Returns ring element associated with specified
long |
default E[] |
valueOf(long[] elements)
Converts array of machine integers to ring elements via
valueOf(long) |
E |
valueOfBigInteger(BigInteger val)
Returns ring element associated with specified integer
|
compare, comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongforEach, spliteratortoStringboolean isField()
boolean isEuclideanRing()
default boolean isFinite()
default boolean isFiniteField()
BigInteger cardinality()
BigInteger characteristic()
boolean isPerfectPower()
BigInteger perfectPowerBase()
base so that cardinality == base^exponent or null if cardinality is not finitebase so that cardinality == base^exponent or null if cardinality is not finiteBigInteger perfectPowerExponent()
exponent so that cardinality == base^exponent or null if cardinality is not finiteexponent so that cardinality == base^exponent or null if cardinality is not finiteE add(E a, E b)
a - the first elementb - the second elementdefault E add(E... elements)
elements - elements to sumdefault E increment(E element)
element + 1element - the elementelement + 1default E decrement(E element)
element - 1element - the elementelement - 1E subtract(E a, E b)
b from aa - the first elementb - the second elementE multiply(E a, E b)
a - the first elementb - the second elementdefault E multiply(E a, long b)
a - the first elementb - the second elementdefault E multiply(E... elements)
elements - the elementsdefault E multiply(Iterable<E> elements)
elements - the elementsE negate(E element)
element - the ring elementdefault E addMutable(E a, E b)
a.a - the first element (may be destroyed)b - the second elementdefault E subtractMutable(E a, E b)
b from a and destroys the initial content of aa - the first element (may be destroyed)b - the second elementdefault E multiplyMutable(E a, E b)
aa - the first element (may be destroyed)b - the second elementdefault E negateMutable(E element)
elementelement - the ring element (may be destroyed)E copy(E element)
element - the elementdefault int signum(E element)
element < 0, 0 if element == 0 and 1 if element > 0, where comparison is
specified by Comparator.compare(Object, Object)element - the elementelement < 0, 0 if element == 0 and 1 otherwiseE[] divideAndRemainder(E dividend, E divider)
dividend / dividerdividend - the dividenddivider - the divider{quotient, remainder}default E quotient(E dividend, E divider)
dividend / dividerdividend - the dividenddivider - the dividerdividend / dividerdefault E remainder(E dividend, E divider)
dividend / dividerdividend - the dividenddivider - the dividerdividend / dividerdefault E divideOrNull(E dividend, E divider)
dividend by divider or returns null if exact division is not possibledividend - the dividenddivider - the dividerdividend / divider or null if exact division is not possibledefault E divideExact(E dividend, E divider)
dividend by divider or throws ArithmeticException if exact division is not
possibledividend - the dividenddivider - the dividerdividend / dividerArithmeticException - if exact division is not possibleE reciprocal(E element)
element ^ (-1) element - the elementelement ^ (-1)default E gcd(E a, E b)
a - the first elementb - the second elementdefault E[] extendedGCD(E a, E b)
[gcd(a,b), s, t] such that s * a + t * b = gcd(a, b)UnsupportedOperationException - if this is not the Euclidean ring and there is no special implementation
provided by particular subtypedefault E[] firstBezoutCoefficient(E a, E b)
[gcd(a,b), s] such that s * a + t * b = gcd(a, b)a - the first ring element (for which the Bezout coefficient is computed)b - the second ring element[gcd(a,b), s] such that s * a + t * b = gcd(a, b)default E lcm(E a, E b)
a - the first elementb - the second elementdefault E lcm(E... elements)
elements - the elementsdefault E lcm(Iterable<E> elements)
elements - the elementsdefault E gcd(E... elements)
elements - the elementsdefault E gcd(Iterable<E> elements)
elements - the elementsdefault FactorDecomposition<E> factorSquareFree(E element)
default FactorDecomposition<E> factor(E element)
E getZero()
E getOne()
default E getNegativeOne()
boolean isZero(E element)
element - the ring elementboolean isOne(E element)
element - the ring elementisUnit(Object)boolean isUnit(E element)
element - the ring elementisOne(Object)default boolean isUnitOrZero(E element)
element - the ring elementdefault boolean isMinusOne(E e)
e - the ring elementE valueOf(long val)
longval - machine integerlongE valueOfBigInteger(BigInteger val)
val - integerdefault E[] valueOf(long[] elements)
valueOf(long)elements - array of machine integersE valueOf(E val)
val
== valueOf(val) is possible).val - some element from any ringvaldefault void setToValueOf(E[] elements)
valueOf(Object) inplace to the specified arrayelements - the arraydefault E[] createArray(int length)
length - array lengthlengthdefault E[][] createArray2d(int length)
length - array lengthlengthdefault E[][] createArray2d(int m, int n)
m - result lengthn - length of each array in the resultdefault E[] createZeroesArray(int length)
length - array lengthlengthdefault void fillZeros(E[] array)
default E[][] createZeroesArray2d(int m, int n)
m - result lengthn - length of each array in the resultdefault E[] createArray(E a, E b)
{a, b}a - the first element of arrayb - the second element of array{a,b}default E[] createArray(E element)
element - the elementdefault E pow(E base, int exponent)
base in a power of exponent (non negative)base - baseexponent - exponent (non negative)base in a power of exponentdefault E pow(E base, long exponent)
base in a power of exponent (non negative)base - baseexponent - exponent (non negative)base in a power of exponentdefault E pow(E base, BigInteger exponent)
base in a power of exponent (non negative)base - baseexponent - exponent (non negative)base in a power of exponentdefault E factorial(long num)
valueOf(1) * valueOf(2) * .... * valueOf(num) num - the numbervalueOf(1) * valueOf(2) * .... * valueOf(num) Iterator<E> iterator()
default E randomElement()
default E randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
rnd - the source of randomnessdefault E randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)
default E randomElementTree()
default E randomNonZeroElement(org.apache.commons.math3.random.RandomGenerator rnd)
rnd - the source of randomnessCopyright © 2022. All rights reserved.