public class Rational<E> extends Object implements Comparable<Rational<E>>, Stringifiable<Rational<E>>, Serializable
Constructor and Description |
---|
Rational(Ring<E> ring,
E numerator) |
Rational(Ring<E> ring,
E numerator,
E denominator) |
Modifier and Type | Method and Description |
---|---|
Rational<E> |
abs()
Returns the absolute value of this
Rational . |
Rational<E> |
add(E that)
Add that to this
|
Rational<E> |
add(Rational<E> that)
Add that to this
|
int |
compareTo(Rational<E> object) |
E |
denominator()
Denominator of this rational
|
Rational<E> |
divide(E oth)
Divide this by oth
|
Rational<E> |
divide(Rational<E> oth)
Divide this by oth
|
boolean |
equals(Object o) |
FactorDecomposition<E> |
factorDenominator()
Factor decomposition of denominator
|
FactorDecomposition<E> |
factorNumerator()
Factor decomposition of denominator
|
int |
hashCode() |
boolean |
isIntegral()
whether this rational is integral
|
boolean |
isOne()
whether this rational is one
|
boolean |
isZero()
whether this rational is zero
|
<O> Rational<O> |
map(Ring<O> ring,
Function<E,O> function)
Maps rational to a new ring
|
Rational<E> |
multiply(E oth)
Multiply this by oth
|
Rational<E> |
multiply(Rational<E> oth)
Multiply this by oth
|
Rational<E> |
negate()
Negate this fraction
|
Rational<E>[] |
normal()
Reduces this rational to normal form by doing division with remainder, that is if
numerator = div *
denominator + rem then the array (div, rem/denominator) will be returned. |
E |
numerator()
Numerator of this rational
|
E |
numeratorExact()
Numerator of this rational
|
static <E> Rational<E> |
one(Ring<E> ring)
Constructs one
|
Rational<E> |
pow(BigInteger exponent)
Raise this in a power
exponent |
Rational<E> |
pow(int exponent)
Raise this in a power
exponent |
Rational<E> |
pow(long exponent)
Raise this in a power
exponent |
Rational<E> |
reciprocal()
Reciprocal of this
|
int |
signum()
Signum of this rational
|
Stream<E> |
stream()
Stream of numerator and denominator
|
Rational<E> |
subtract(E that)
Subtract that from this
|
Rational<E> |
subtract(Rational<E> that)
Add that to this
|
String |
toString() |
String |
toString(IStringifier<Rational<E>> stringifier)
convert this to string with the use of stringifier
|
static <E> Rational<E> |
zero(Ring<E> ring)
Constructs zero
|
public boolean isZero()
public boolean isOne()
public boolean isIntegral()
public E numerator()
public E numeratorExact()
public E denominator()
public FactorDecomposition<E> factorDenominator()
public FactorDecomposition<E> factorNumerator()
public Rational<E>[] normal()
numerator = div *
denominator + rem
then the array (div, rem/denominator)
will be returned. If either div or rem is zero
an singleton array with this instance will be returned.public int signum()
public Rational<E> abs()
Rational
.Rational
.public int compareTo(Rational<E> object)
compareTo
in interface Comparable<Rational<E>>
public Rational<E> pow(int exponent)
exponent
exponent
- exponentpublic Rational<E> pow(long exponent)
exponent
exponent
- exponentpublic Rational<E> pow(BigInteger exponent)
exponent
exponent
- exponentpublic String toString(IStringifier<Rational<E>> stringifier)
Stringifiable
toString
in interface Stringifiable<Rational<E>>
Copyright © 2018. All rights reserved.