E
- typepublic final class Rational<E> extends Object implements Comparable<Rational<E>>, Serializable
Modifier and Type | Field and Description |
---|---|
E |
denominator
The denominator.
|
E |
numerator
The numerator.
|
Ring<E> |
ring
The ring.
|
Constructor and Description |
---|
Rational(Ring<E> ring,
E numerator)
Constructs rational with the specified numerator and unit denominator
|
Rational(Ring<E> ring,
E numerator,
E denominator)
Constructs rational with the specified numerator and denominator
|
Modifier and Type | Method and Description |
---|---|
Rational<E> |
abs()
Returns the absolute value of this
Rational . |
Rational<E> |
add(E val)
Add
other to this |
Rational<E> |
add(long other)
Add
other to this |
Rational<E> |
add(Rational<E> other)
Add
other to this |
int |
compareTo(Rational<E> object) |
Rational<E> |
divide(E other)
Divide this by
other |
Rational<E> |
divide(long l)
Divide this by
other |
Rational<E> |
divide(Rational other)
Divide this by
other |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
isIntegral()
Tests whether the denominator is one
|
boolean |
isOne()
Whether this is one
|
boolean |
isZero()
Whether this is zero
|
<O> Rational<O> |
map(Ring<O> ring,
Function<E,O> function)
Maps rational to a new ring
|
Rational<E> |
multiply(E other)
Multiply this by
other |
Rational<E> |
multiply(long other)
Multiply this by
other |
Rational<E> |
multiply(Rational<E> other)
Multiply this by
other |
Rational<E> |
negate()
Negates this
|
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. |
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()
Return the multiplicative inverse of this rational.
|
int |
signum()
Signum of this rational
|
Stream<E> |
stream()
Stream of numerator and denominator
|
Rational<E> |
subtract(E other)
Subtracts
other from this |
Rational<E> |
subtract(long l)
Subtracts
other from this |
Rational<E> |
subtract(Rational<E> other)
Subtracts
other from this |
String |
toString() |
String |
toString(ToStringSupport<E> toString) |
static <E> Rational<E> |
zero(Ring<E> ring)
Constructs zero
|
public final E numerator
public final E denominator
public Rational(Ring<E> ring, E numerator, E denominator)
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 boolean isIntegral()
public boolean isZero()
public boolean isOne()
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(ToStringSupport<E> toString)
Copyright © 2018. All rights reserved.