public final class BigRational extends java.lang.Object implements GcdRingElem<BigRational>, RingFactory<BigRational>, Rational, java.lang.Iterable<BigRational>
Modifier and Type | Field and Description |
---|---|
java.math.BigInteger |
den
Denominator part of the data structure.
|
static BigRational |
HALF
The Constant 1/2.
|
java.math.BigInteger |
num
Numerator part of the data structure.
|
static BigRational |
ONE
The Constant 1.
|
static BigRational |
ZERO
The Constant 0.
|
Modifier | Constructor and Description |
---|---|
|
BigRational()
Constructor for a BigRational with no arguments.
|
|
BigRational(java.math.BigInteger n)
Constructor for a BigRational from math.BigIntegers.
|
|
BigRational(BigInteger n)
Constructor for a BigRational from jas.arith.BigIntegers.
|
protected |
BigRational(java.math.BigInteger n,
java.math.BigInteger d)
Constructor for a BigRational from math.BigIntegers.
|
|
BigRational(BigInteger n,
BigInteger d)
Constructor for a BigRational from jas.arith.BigIntegers.
|
|
BigRational(long n)
Constructor for a BigRational from longs.
|
|
BigRational(long n,
long d)
Constructor for a BigRational from longs.
|
|
BigRational(java.lang.String s)
Constructor for a BigRational from String.
|
Modifier and Type | Method and Description |
---|---|
BigRational |
abs()
Rational number absolute value.
|
long |
bitLength()
Returns the number of bits in the representation of this BigRational,
including a sign bit.
|
java.math.BigInteger |
ceil()
BigRational ceiling.
|
java.math.BigInteger |
characteristic()
Characteristic of this ring.
|
int |
compareTo(BigRational S)
Rational number comparison.
|
BigRational |
copy()
Clone this.
|
BigRational |
copy(BigRational c)
Copy BigRational element c.
|
java.math.BigInteger |
denominator()
Get the denominator.
|
BigRational |
divide(BigRational S)
Rational number quotient.
|
double |
doubleValue()
Get this as a double.
|
BigRational[] |
egcd(BigRational S)
BigRational extended greatest common divisor.
|
boolean |
equals(java.lang.Object b)
Comparison with any other object.
|
BigRational |
factory()
Get the corresponding element factory.
|
java.math.BigInteger |
floor()
BigRational floor.
|
BigRational |
fromInteger(java.math.BigInteger a)
Get a BigRational element from a math.BigInteger.
|
BigRational |
fromInteger(BigInteger a)
Get a BigRational element from a arith.BigInteger.
|
BigRational |
fromInteger(long a)
Get a BigRational element from a long.
|
BigRational |
gcd(BigRational S)
Rational number greatest common divisor.
|
java.util.List<BigRational> |
generators()
Get a list of the generating elements.
|
BigDecimal |
getDecimal()
Get the decimal representation.
|
BigRational |
getONE()
Get the one element.
|
BigRational |
getRational()
Return a BigRational approximation of this Element.
|
BigRational |
getZERO()
Get the zero element.
|
int |
hashCode()
Hash code for this BigRational.
|
BigRational |
inverse()
Rational number inverse.
|
boolean |
isAssociative()
Query if this ring is associative.
|
boolean |
isCommutative()
Query if this ring is commutative.
|
boolean |
isEntier()
Is BigRational entier.
|
boolean |
isField()
Query if this ring is a field.
|
boolean |
isFinite()
Is this structure finite or infinite.
|
boolean |
isONE()
Is BigRational one.
|
boolean |
isUnit()
Is BigRational unit.
|
boolean |
isZERO()
Is BigRational zero.
|
java.util.Iterator<BigRational> |
iterator()
Get a BigRational iterator.
|
BigRational |
multiply(BigRational S)
Rational number product.
|
BigRational |
negate()
Rational number negative.
|
java.math.BigInteger |
numerator()
Get the numerator.
|
BigRational |
parse(java.io.Reader r)
Parse rational number from Reader.
|
BigRational |
parse(java.lang.String s)
Parse rational number from String.
|
BigRational[] |
quotientRemainder(BigRational S)
Quotient and remainder by division of this by S.
|
BigRational |
random(int n)
Rational number, random.
|
BigRational |
random(int n,
java.util.Random rnd)
Rational number, random.
|
static BigRational |
reduction(java.math.BigInteger n,
java.math.BigInteger d)
Rational number reduction to lowest terms.
|
BigRational |
remainder(BigRational S)
Rational number remainder.
|
static BigRational |
RNABS(BigRational R)
Rational number absolute value.
|
static int |
RNCOMP(BigRational R,
BigRational S)
Rational number comparison.
|
static java.math.BigInteger |
RNDEN(BigRational R)
Rational number denominator.
|
static BigRational |
RNDIF(BigRational R,
BigRational S)
Rational number difference.
|
static void |
RNDWR(BigRational R,
int NL)
Rational number decimal write.
|
static BigRational |
RNINT(java.math.BigInteger A)
Rational number from integer.
|
static BigRational |
RNINV(BigRational R)
Rational number inverse.
|
static BigRational |
RNNEG(BigRational R)
Rational number negative.
|
static java.math.BigInteger |
RNNUM(BigRational R)
Rational number numerator.
|
static BigRational |
RNPROD(BigRational R,
BigRational S)
Rational number product.
|
static BigRational |
RNQ(BigRational R,
BigRational S)
Rational number quotient.
|
static BigRational |
RNRAND(int NL)
Rational number, random.
|
static BigRational |
RNRED(java.math.BigInteger n,
java.math.BigInteger d)
Rational number reduction to lowest terms.
|
static int |
RNSIGN(BigRational R)
Rational number sign.
|
static BigRational |
RNSUM(BigRational R,
BigRational S)
Rational number sum.
|
void |
setAllIterator()
Set the iteration algorithm to all elements.
|
void |
setDuplicatesIterator()
Set the iteration algorithm to allow duplicate elements.
|
void |
setNoDuplicatesIterator()
Set the iteration algorithm to no duplicate elements.
|
void |
setNonNegativeIterator()
Set the iteration algorithm to non-negative elements.
|
int |
signum()
Rational number sign.
|
BigRational |
subtract(BigRational S)
Rational number difference.
|
BigRational |
sum(BigRational S)
Rational number sum.
|
java.lang.String |
toScript()
Get a scripting compatible string representation.
|
java.lang.String |
toScriptFactory()
Get a scripting compatible string representation of the factory.
|
java.lang.String |
toString()
Get the string representation.
|
java.lang.String |
toString(int n)
Get the decimal string representation with given precision.
|
java.util.Iterator<BigRational> |
uniqueIterator()
Get a BigRational iterator with no duplicates.
|
static BigRational |
valueOf(java.math.BigInteger a)
Get a BigRational element from a math.BigInteger.
|
static BigRational |
valueOf(long a)
Get a BigRational element from a long.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
leftDivide, leftRemainder, power, rightDivide, rightRemainder, twosidedDivide, twosidedRemainder
public final java.math.BigInteger num
public final java.math.BigInteger den
public static final BigRational ZERO
public static final BigRational ONE
public static final BigRational HALF
protected BigRational(java.math.BigInteger n, java.math.BigInteger d)
n
- math.BigInteger.d
- math.BigInteger.public BigRational(java.math.BigInteger n)
n
- math.BigInteger.public BigRational(BigInteger n)
n
- edu.jas.arith.BigInteger.public BigRational(BigInteger n, BigInteger d)
n
- edu.jas.arith.BigInteger.d
- edu.jas.arith.BigInteger.public BigRational(long n, long d)
n
- long.d
- long.public BigRational(long n)
n
- long.public BigRational()
public BigRational(java.lang.String s) throws java.lang.NumberFormatException
s
- String.java.lang.NumberFormatException
public BigRational factory()
factory
in interface Element<BigRational>
Element.factory()
public java.util.List<BigRational> generators()
generators
in interface ElemFactory<BigRational>
ElemFactory.generators()
public boolean isFinite()
isFinite
in interface ElemFactory<BigRational>
ElemFactory.isFinite()
public BigRational copy()
copy
in interface Element<BigRational>
Object.clone()
public BigRational copy(BigRational c)
copy
in interface ElemFactory<BigRational>
c
- BigRational.public BigRational getRational()
getRational
in interface Rational
Rational.getRational()
public java.math.BigInteger numerator()
public java.math.BigInteger denominator()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.lang.String toString(int n)
n
- precision.public BigDecimal getDecimal()
public double doubleValue()
Number.doubleValue()
public java.lang.String toScript()
toScript
in interface Element<BigRational>
toScript
in interface ElemFactory<BigRational>
Element.toScript()
public java.lang.String toScriptFactory()
toScriptFactory
in interface Element<BigRational>
Element.toScriptFactory()
public BigRational getZERO()
getZERO
in interface AbelianGroupFactory<BigRational>
public BigRational getONE()
getONE
in interface MonoidFactory<BigRational>
public boolean isCommutative()
isCommutative
in interface MonoidFactory<BigRational>
public boolean isAssociative()
isAssociative
in interface MonoidFactory<BigRational>
public boolean isField()
isField
in interface RingFactory<BigRational>
public java.math.BigInteger characteristic()
characteristic
in interface RingFactory<BigRational>
public BigRational fromInteger(java.math.BigInteger a)
fromInteger
in interface ElemFactory<BigRational>
a
- math.BigInteger.public BigRational fromInteger(BigInteger a)
a
- arith.BigInteger.public static BigRational valueOf(java.math.BigInteger a)
a
- math.BigInteger.public BigRational fromInteger(long a)
fromInteger
in interface ElemFactory<BigRational>
a
- long.public static BigRational valueOf(long a)
a
- long.public boolean isZERO()
isZERO
in interface AbelianGroupElem<BigRational>
AbelianGroupElem.isZERO()
public boolean isONE()
isONE
in interface MonoidElem<BigRational>
MonoidElem.isONE()
public boolean isUnit()
isUnit
in interface MonoidElem<BigRational>
MonoidElem.isUnit()
public boolean isEntier()
public boolean equals(java.lang.Object b)
equals
in interface Element<BigRational>
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
hashCode
in interface Element<BigRational>
hashCode
in class java.lang.Object
Object.hashCode()
public static BigRational RNRED(java.math.BigInteger n, java.math.BigInteger d)
n
- BigInteger.d
- BigInteger.public static BigRational reduction(java.math.BigInteger n, java.math.BigInteger d)
n
- BigInteger.d
- BigInteger.public BigRational abs()
abs
in interface AbelianGroupElem<BigRational>
AbelianGroupElem.abs()
public static BigRational RNABS(BigRational R)
R
- is a rational number.public int compareTo(BigRational S)
compareTo
in interface Element<BigRational>
compareTo
in interface java.lang.Comparable<BigRational>
S
- BigRational.public static int RNCOMP(BigRational R, BigRational S)
R
- BigRational.S
- BigRational.public static java.math.BigInteger RNDEN(BigRational R)
R
- BigRational.public BigRational subtract(BigRational S)
subtract
in interface AbelianGroupElem<BigRational>
S
- BigRational.public static BigRational RNDIF(BigRational R, BigRational S)
R
- BigRational.S
- BigRational.public static void RNDWR(BigRational R, int NL)
R
- NL
- public static BigRational RNINT(java.math.BigInteger A)
A
- BigInteger.public BigRational inverse()
inverse
in interface MonoidElem<BigRational>
MonoidElem.inverse()
public static BigRational RNINV(BigRational R)
R
- BigRational.public BigRational negate()
negate
in interface AbelianGroupElem<BigRational>
AbelianGroupElem.negate()
public static BigRational RNNEG(BigRational R)
R
- BigRational.public static java.math.BigInteger RNNUM(BigRational R)
R
- BigRational.public BigRational multiply(BigRational S)
multiply
in interface MonoidElem<BigRational>
S
- BigRational.public static BigRational RNPROD(BigRational R, BigRational S)
R
- BigRational.S
- BigRational.public BigRational divide(BigRational S)
divide
in interface MonoidElem<BigRational>
S
- BigRational.public static BigRational RNQ(BigRational R, BigRational S)
R
- BigRational.S
- BigRational.public BigRational remainder(BigRational S)
remainder
in interface MonoidElem<BigRational>
S
- BigRational.public BigRational[] quotientRemainder(BigRational S)
quotientRemainder
in interface MonoidElem<BigRational>
S
- a rational numberpublic BigRational random(int n)
random
in interface ElemFactory<BigRational>
n
- such that 0 ≤ A, B ≤ (2n-1).public BigRational random(int n, java.util.Random rnd)
random
in interface ElemFactory<BigRational>
n
- such that 0 ≤ A, B ≤ (2n-1).rnd
- is a source for random bits.public static BigRational RNRAND(int NL)
NL
- such that 0 ≤ A, B ≤ (2n-1).public int signum()
signum
in interface AbelianGroupElem<BigRational>
AbelianGroupElem.signum()
public static int RNSIGN(BigRational R)
R
- BigRational.public BigRational sum(BigRational S)
sum
in interface AbelianGroupElem<BigRational>
S
- BigRational.public static BigRational RNSUM(BigRational R, BigRational S)
R
- BigRational.S
- BigRational.public BigRational parse(java.lang.String s)
parse
in interface ElemFactory<BigRational>
s
- String.public BigRational parse(java.io.Reader r)
parse
in interface ElemFactory<BigRational>
r
- Reader.public BigRational gcd(BigRational S)
gcd
in interface RingElem<BigRational>
S
- BigRational.public BigRational[] egcd(BigRational S)
egcd
in interface RingElem<BigRational>
S
- BigRational.public java.math.BigInteger ceil()
public java.math.BigInteger floor()
public long bitLength()
num.bitLength()+den.bitLength()
.)public void setAllIterator()
public void setNonNegativeIterator()
public void setNoDuplicatesIterator()
public void setDuplicatesIterator()
public java.util.Iterator<BigRational> iterator()
iterator
in interface java.lang.Iterable<BigRational>
public java.util.Iterator<BigRational> uniqueIterator()