E
- the type of objects that may be operated by this ringpublic interface Ring<E> extends Comparator<E>, Iterable<E>, ToStringSupport<E>, ElementParser<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).plain
Modifier and Type | Method and Description |
---|---|
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 |
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 |
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 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 a,
E b)
Returns the least common multiple of two elements
|
default E |
multiply(E... elements)
Multiplies the array of elements
|
E |
multiply(E a,
E b)
Multiplies two 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 |
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 |
default String |
toString(E element)
Gives string representation of specified element
|
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, thenComparingLong
forEach, spliterator
plain, withVariables
boolean 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 + 1
element
- the elementelement + 1
default E decrement(E element)
element - 1
element
- the elementelement - 1
E subtract(E a, E b)
b
from a
a
- the first elementb
- the second elementE multiply(E a, E b)
a
- the first elementb
- the second elementdefault E multiply(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 a
a
- the first element (may be destroyed)b
- the second elementdefault E multiplyMutable(E a, E b)
a
a
- the first element (may be destroyed)b
- the second elementdefault E negateMutable(E element)
element
element
- 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 / divider
dividend
- the dividenddivider
- the divider{quotient, remainder}
default E quotient(E dividend, E divider)
dividend / divider
dividend
- the dividenddivider
- the dividerdividend / divider
default E remainder(E dividend, E divider)
dividend / divider
dividend
- the dividenddivider
- the dividerdividend / divider
default 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 / divider
ArithmeticException
- 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 lcm(E a, E b)
a
- the first elementb
- the second elementdefault 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)
long
val
- machine integerlong
E valueOfBigInteger(BigInteger val)
val
- integerdefault E[] valueOf(long[] elements)
valueOf(long)
elements
- array of machine integersE valueOf(E val)
val
- some element from any ringval
default void setToValueOf(E[] elements)
valueOf(Object)
inplace to the specified arrayelements
- the arraydefault E parse(String string)
parse
in interface ElementParser<E>
string
- stringdefault E[] createArray(int length)
length
- array lengthlength
default E[][] createArray2d(int length)
length
- array lengthlength
default E[][] createArray2d(int m, int n)
m
- result lengthn
- length of each array in the resultdefault E[] createZeroesArray(int length)
length
- array lengthlength
default 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 exponent
default E pow(E base, long exponent)
base
in a power of exponent
(non negative)base
- baseexponent
- exponent (non negative)base
in a power of exponent
default E pow(E base, BigInteger exponent)
base
in a power of exponent
(non negative)base
- baseexponent
- exponent (non negative)base
in a power of exponent
default 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 randomNonZeroElement(org.apache.commons.math3.random.RandomGenerator rnd)
rnd
- the source of randomnessdefault String toString(E element)
ToStringSupport
toString
in interface ToStringSupport<E>
element
- the elementCopyright © 2017. All rights reserved.