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
|
plain
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) |
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 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 element)
Tests whether specified element is a ring unit
|
boolean |
isZero(Rational element)
Tests whether specified element is zero
|
Iterator<Rational<E>> |
iterator()
Returns iterator over ring elements (for finite rings, otherwise throws exception)
|
Rational<E> |
multiply(Rational<E> a,
Rational<E> b)
Multiplies two elements
|
Rational<E> |
negate(Rational<E> element)
Negates the given element
|
Rational<E> |
parse(ElementParser<E> parser,
String string) |
Rational<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 |
Rational<E> |
randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Returns a random element from this ring
|
Rational<E> |
randomNonTrivialElement(org.apache.commons.math3.random.RandomGenerator rnd) |
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() |
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, wait
abs, add, addMutable, createArray, createArray, createArray, createZeroesArray, createZeroesArray2d, decrement, divideExact, divideOrNull, extendedGCD, factor, factorial, factorSquareFree, gcd, gcd, increment, isFinite, isFiniteField, isMinusOne, isUnitOrZero, lcm, lcm, lcm, max, min, multiply, multiply, multiply, multiplyMutable, negateMutable, pow, pow, pow, quotient, randomElement, randomNonZeroElement, remainder, setToValueOf, subtractMutable, toString, valueOf
comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
forEach, spliterator
plain, withVariables
public boolean isField()
Ring
public boolean isEuclideanRing()
Ring
isEuclideanRing
in interface Ring<Rational<E>>
public BigInteger cardinality()
Ring
cardinality
in interface Ring<Rational<E>>
public BigInteger characteristic()
Ring
characteristic
in interface Ring<Rational<E>>
public boolean isPerfectPower()
Ring
isPerfectPower
in interface Ring<Rational<E>>
public BigInteger perfectPowerBase()
Ring
base
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()
Ring
exponent
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)
Ring
public Rational<E> subtract(Rational<E> a, Rational<E> b)
Ring
b
from a
public Rational<E> multiply(Rational<E> a, Rational<E> b)
Ring
public Rational<E> negate(Rational<E> element)
Ring
public int signum(Rational<E> element)
Ring
element < 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)
Ring
dividend / divider
divideAndRemainder
in interface Ring<Rational<E>>
dividend
- the dividenddivider
- the divider{quotient, remainder}
public Rational<E> reciprocal(Rational<E> element)
Ring
element ^ (-1)
reciprocal
in interface Ring<Rational<E>>
element
- the elementelement ^ (-1)
public Rational<E> gcd(Rational<E> a, Rational<E> b)
Ring
public Rational<E> getZero()
Ring
public Rational<E> getOne()
Ring
public boolean isZero(Rational element)
Ring
public boolean isOne(Rational element)
Ring
isOne
in interface Ring<Rational<E>>
element
- the ring elementRing.isUnit(Object)
public boolean isUnit(Rational element)
Ring
isUnit
in interface Ring<Rational<E>>
element
- the ring elementRing.isOne(Object)
public Rational<E> valueOf(long val)
Ring
long
public Rational<E> valueOfBigInteger(BigInteger val)
Ring
valueOfBigInteger
in interface Ring<Rational<E>>
val
- integerpublic Rational<E> copy(Rational<E> element)
Ring
public Rational<E> valueOf(Rational<E> val)
Ring
val
== valueOf(val)
is possible).public Rational<E>[][] createArray2d(int length)
Ring
createArray2d
in interface Ring<Rational<E>>
length
- array lengthlength
public Rational<E>[][] createArray2d(int m, int n)
Ring
createArray2d
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()
Ring
getNegativeOne
in interface Ring<Rational<E>>
public Rational<E>[] createArray(int length)
Ring
createArray
in interface Ring<Rational<E>>
length
- array lengthlength
public Rational<E> randomElement(org.apache.commons.math3.random.RandomGenerator rnd)
Ring
randomElement
in interface Ring<Rational<E>>
rnd
- the source of randomnesspublic Rational<E> randomNonTrivialElement(org.apache.commons.math3.random.RandomGenerator rnd)
public Rational<E> parse(ElementParser<E> parser, String string)
public Rational<E> parse(String string)
Ring
public Iterator<Rational<E>> iterator()
Ring
public boolean equals(Object o)
Copyright © 2018. All rights reserved.