public final class Rationals<E> extends Object implements Ring<Rational<E>>
| Modifier and Type | Field and Description |
|---|---|
Ring<E> |
ring
Ring that numerator and denominator belongs to
|
| Modifier and Type | Method and Description |
|---|---|
Rational<E> |
add(Rational<E> a,
Rational<E> b)
Add two elements
|
BigInteger |
cardinality()
Returns the number of elements in this ring (cardinality) or null if ring is infinite
|
BigInteger |
characteristic()
Returns characteristic of this ring
|
int |
compare(Rational<E> o1,
Rational<E> o2) |
Rational<E> |
copy(Rational<E> element)
Makes a deep copy of the specified element (for immutable instances the same reference returned).
|
Rational<E>[] |
createArray(int length)
Creates generic array of ring elements of specified length
|
Rational<E>[][] |
createArray2d(int length)
Creates 2d array of ring elements of specified length
|
Rational<E>[][] |
createArray2d(int m,
int n)
Creates 2d array of ring elements of specified shape
|
Rational<E>[] |
divideAndRemainder(Rational<E> dividend,
Rational<E> divider)
Returns quotient and remainder of
dividend / divider |
boolean |
equals(Object o) |
FactorDecomposition<Rational<E>> |
factor(Rational<E> element)
Factor specified element
|
FactorDecomposition<Rational<E>> |
factorSquareFree(Rational<E> element)
Square-free factorization of specified element
|
Rational<E> |
gcd(Rational<E> a,
Rational<E> b)
Returns the greatest common divisor of two elements
|
Rational<E> |
getNegativeOne()
Returns negative unit element of this ring (minus one)
|
Rational<E> |
getOne()
Returns unit element of this ring (one)
|
Rational<E> |
getZero()
Returns zero element of this ring
|
int |
hashCode() |
boolean |
isEuclideanRing()
Returns whether this ring is a Euclidean ring
|
boolean |
isField()
Returns whether this ring is a field
|
boolean |
isOne(Rational<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(Rational<E> element)
Tests whether specified element is a ring unit
|
boolean |
isZero(Rational<E> element)
Tests whether specified element is zero
|
Iterator<Rational<E>> |
iterator()
Returns iterator over ring elements (for finite rings, otherwise throws exception)
|
Rational<E> |
mk(E num,
E den)
Gives rational with a given numerator and denominator
|
Rational<E> |
mk(long num,
long den)
Gives rational with a given numerator and denominator
|
Rational<E> |
mkDenominator(E den)
Gives rational with a given denominator and unit numerator
|
Rational<E> |
mkDenominator(long den)
Gives rational with a given denominator and unit numerator
|
Rational<E> |
mkNumerator(E num)
Gives rational with a given numerator and unit denominator
|
Rational<E> |
mkNumerator(long num)
Gives rational with a given numerator and unit denominator
|
Rational<E> |
multiply(Rational<E> a,
Rational<E> b)
Multiplies two elements
|
Rational<E> |
negate(Rational<E> element)
Negates the given 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 |
Rational<E> |
randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Returns a random element from this ring
|
Rational<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.
|
Rational<E> |
reciprocal(Rational<E> element)
Gives the inverse element
element ^ (-1) |
int |
signum(Rational<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) |
Rational<E> |
subtract(Rational<E> a,
Rational<E> b)
Subtracts
b from a |
String |
toString() |
String |
toString(IStringifier<Rational<E>> stringifier)
convert this to string with the use of stringifier
|
Rational<E> |
valueOf(long val)
Returns ring element associated with specified
long |
Rational<E> |
valueOf(Rational<E> val)
Converts a value from other ring to this ring.
|
Rational<E> |
valueOfBigInteger(BigInteger val)
Returns ring element associated with specified integer
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitabs, add, addMutable, createArray, createArray, createArray, createZeroesArray, createZeroesArray2d, decrement, divideExact, divideExactMutable, divideOrNull, extendedGCD, factorial, fillZeros, firstBezoutCoefficient, gcd, gcd, increment, isFinite, isFiniteField, isMinusOne, isUnitOrZero, lcm, lcm, lcm, max, min, multiply, multiply, multiply, multiplyMutable, negateMutable, parse, pow, pow, pow, quotient, randomElement, randomElementTree, randomNonZeroElement, remainder, setToValueOf, subtractMutable, valueOfcomparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongforEach, spliteratorpublic Rational<E> mkNumerator(E num)
public Rational<E> mkNumerator(long num)
public Rational<E> mkDenominator(E den)
public Rational<E> mkDenominator(long den)
public boolean isField()
Ringpublic boolean isEuclideanRing()
RingisEuclideanRing in interface Ring<Rational<E>>public BigInteger cardinality()
Ringcardinality in interface Ring<Rational<E>>public BigInteger characteristic()
Ringcharacteristic in interface Ring<Rational<E>>public boolean isPerfectPower()
RingisPerfectPower in interface Ring<Rational<E>>public BigInteger perfectPowerBase()
Ringbase so that cardinality == base^exponent or null if cardinality is not finiteperfectPowerBase in interface Ring<Rational<E>>base so that cardinality == base^exponent or null if cardinality is not finitepublic BigInteger perfectPowerExponent()
Ringexponent so that cardinality == base^exponent or null if cardinality is not finiteperfectPowerExponent in interface Ring<Rational<E>>exponent so that cardinality == base^exponent or null if cardinality is not finitepublic Rational<E> add(Rational<E> a, Rational<E> b)
Ringpublic Rational<E> subtract(Rational<E> a, Rational<E> b)
Ringb from apublic Rational<E> multiply(Rational<E> a, Rational<E> b)
Ringpublic Rational<E> negate(Rational<E> element)
Ringpublic int signum(Rational<E> element)
Ringelement < 0, 0 if element == 0 and 1 if element > 0, where comparison is
specified by Comparator.compare(Object, Object)public Rational<E>[] divideAndRemainder(Rational<E> dividend, Rational<E> divider)
Ringdividend / dividerdivideAndRemainder in interface Ring<Rational<E>>dividend - the dividenddivider - the divider{quotient, remainder}public Rational<E> reciprocal(Rational<E> element)
Ringelement ^ (-1) reciprocal in interface Ring<Rational<E>>element - the elementelement ^ (-1)public Rational<E> gcd(Rational<E> a, Rational<E> b)
Ringpublic FactorDecomposition<Rational<E>> factorSquareFree(Rational<E> element)
RingfactorSquareFree in interface Ring<Rational<E>>public FactorDecomposition<Rational<E>> factor(Rational<E> element)
Ringpublic Rational<E> getZero()
Ringpublic Rational<E> getOne()
Ringpublic boolean isZero(Rational<E> element)
Ringpublic boolean isOne(Rational<E> element)
RingisOne in interface Ring<Rational<E>>element - the ring elementRing.isUnit(Object)public boolean isUnit(Rational<E> element)
RingisUnit in interface Ring<Rational<E>>element - the ring elementRing.isOne(Object)public Rational<E> valueOf(long val)
Ringlongpublic Rational<E> valueOfBigInteger(BigInteger val)
RingvalueOfBigInteger in interface Ring<Rational<E>>val - integerpublic Rational<E> copy(Rational<E> element)
Ringpublic Rational<E> valueOf(Rational<E> val)
Ringval
== valueOf(val) is possible).public Rational<E>[][] createArray2d(int length)
RingcreateArray2d in interface Ring<Rational<E>>length - array lengthlengthpublic Rational<E>[][] createArray2d(int m, int n)
RingcreateArray2d in interface Ring<Rational<E>>m - result lengthn - length of each array in the resultpublic int compare(Rational<E> o1, Rational<E> o2)
compare in interface Comparator<Rational<E>>public Rational<E> getNegativeOne()
RinggetNegativeOne in interface Ring<Rational<E>>public Rational<E>[] createArray(int length)
RingcreateArray in interface Ring<Rational<E>>length - array lengthlengthpublic Rational<E> randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
RingrandomElement in interface Ring<Rational<E>>rnd - the source of randomnesspublic Rational<E> randomElementTree(org.apache.commons.math3.random.RandomGenerator rnd)
RingrandomElementTree in interface Ring<Rational<E>>public Iterator<Rational<E>> iterator()
Ringpublic boolean equals(Object o)
public String toString(IStringifier<Rational<E>> stringifier)
StringifiabletoString in interface Stringifiable<Rational<E>>Copyright © 2022. All rights reserved.