edu.jas.arith
Class BigRational

java.lang.Object
  extended by edu.jas.arith.BigRational
All Implemented Interfaces:
Coefficient, java.io.Serializable, java.lang.Comparable

public class BigRational
extends java.lang.Object
implements Coefficient, java.lang.Comparable, java.io.Serializable

BigRational class based on BigInteger implementing the Coefficient interface and with the familiar SAC method names.

See Also:
Serialized Form

Field Summary
static java.math.BigInteger IONE
           
static java.math.BigInteger IZERO
           
static BigRational ONE
           
static BigRational RNONE
           
static BigRational RNZERO
           
static BigRational ZERO
           
 
Constructor Summary
  BigRational()
           
  BigRational(java.math.BigInteger n)
           
protected BigRational(java.math.BigInteger n, java.math.BigInteger d)
          Constructors for BigRational
  BigRational(long n)
           
  BigRational(long n, long d)
           
  BigRational(java.lang.String s)
           
 
Method Summary
 Coefficient abs()
          Rational number absolute value.
 BigRational add(BigRational S)
           
 Coefficient add(Coefficient S)
          Rational number sum.
 int compareTo(java.lang.Object b)
          Rational number comparison.
 java.math.BigInteger denominator()
           
 BigRational divide(BigRational S)
           
 Coefficient divide(Coefficient S)
          Rational number quotient.
 boolean equals(java.lang.Object b)
           
 Coefficient fromInteger(java.math.BigInteger a)
           
 Coefficient fromInteger(long a)
           
 Coefficient inverse()
          Rational number inverse.
 boolean isONE()
           
 boolean isZERO()
           
 BigRational multiply(BigRational S)
           
 Coefficient multiply(Coefficient S)
          Rational number product.
 Coefficient negate()
          Rational number negative.
 java.math.BigInteger numerator()
           
 Coefficient random(int n)
          Rational number, random.
static BigRational RNABS(BigRational R)
           
static int RNCOMP(BigRational R, BigRational S)
           
static java.math.BigInteger RNDEN(BigRational R)
          Rational number denominator.
static BigRational RNDIF(BigRational R, BigRational S)
           
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)
           
static BigRational RNNEG(BigRational R)
           
static java.math.BigInteger RNNUM(BigRational R)
          Rational number numerator.
static BigRational RNPROD(BigRational R, BigRational S)
           
static BigRational RNQ(BigRational R, BigRational S)
           
static BigRational RNRAND(int NL)
           
static BigRational RNRED(java.math.BigInteger n, java.math.BigInteger d)
          Rational number reduction to lowest terms.
static int RNSIGN(BigRational R)
           
static BigRational RNSUM(BigRational R, BigRational S)
           
 int signum()
          Rational number sign.
 BigRational subtract(BigRational S)
           
 Coefficient subtract(Coefficient S)
          Rational number difference.
 java.lang.String toString()
           
static BigRational valueOf(java.math.BigInteger a)
           
static BigRational valueOf(long a)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IZERO

public static final java.math.BigInteger IZERO

IONE

public static final java.math.BigInteger IONE

RNZERO

public static final BigRational RNZERO

RNONE

public static final BigRational RNONE

ZERO

public static final BigRational ZERO

ONE

public static final BigRational ONE
Constructor Detail

BigRational

protected BigRational(java.math.BigInteger n,
                      java.math.BigInteger d)
Constructors for BigRational


BigRational

public BigRational(java.math.BigInteger n)

BigRational

public BigRational(long n,
                   long d)

BigRational

public BigRational(long n)

BigRational

public BigRational()

BigRational

public BigRational(java.lang.String s)
            throws java.lang.NumberFormatException
Throws:
java.lang.NumberFormatException
Method Detail

numerator

public java.math.BigInteger numerator()

denominator

public java.math.BigInteger denominator()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

fromInteger

public Coefficient fromInteger(java.math.BigInteger a)
Specified by:
fromInteger in interface Coefficient

valueOf

public static BigRational valueOf(java.math.BigInteger a)

fromInteger

public Coefficient fromInteger(long a)
Specified by:
fromInteger in interface Coefficient

valueOf

public static BigRational valueOf(long a)

isZERO

public boolean isZERO()
Specified by:
isZERO in interface Coefficient

isONE

public boolean isONE()
Specified by:
isONE in interface Coefficient

equals

public boolean equals(java.lang.Object b)
Overrides:
equals in class java.lang.Object

RNRED

public static BigRational RNRED(java.math.BigInteger n,
                                java.math.BigInteger d)
Rational number reduction to lowest terms. A and B are integers, B non-zero. R is the rational number A/B in canonical form.


abs

public Coefficient abs()
Rational number absolute value. R is a rational number. S is the absolute value of R.

Specified by:
abs in interface Coefficient

RNABS

public static BigRational RNABS(BigRational R)

compareTo

public int compareTo(java.lang.Object b)
Rational number comparison. R and S are rational numbers. t=SIGN(R-S).

Specified by:
compareTo in interface Coefficient
Specified by:
compareTo in interface java.lang.Comparable

RNCOMP

public static int RNCOMP(BigRational R,
                         BigRational S)

RNDEN

public static java.math.BigInteger RNDEN(BigRational R)
Rational number denominator. R is a rational number. b is the denominator of R, a positive integer.


subtract

public Coefficient subtract(Coefficient S)
Rational number difference. R and S are rational numbers. T=R-S.

Specified by:
subtract in interface Coefficient

subtract

public BigRational subtract(BigRational S)

RNDIF

public static BigRational RNDIF(BigRational R,
                                BigRational S)

RNDWR

public static void RNDWR(BigRational R,
                         int NL)
Rational number decimal write. R is a rational number. n is a non-negative integer. R is approximated by a decimal fraction D with n decimal digits following the decimal point and D is written in the output stream. The inaccuracy of the approximation is at most (1/2)*10**-n. If ABS(D) is greater than ABS(R) then the last digit is followed by a minus sign, if ABS(D) is less than ABS(R) then by a plus sign.


RNINT

public static BigRational RNINT(java.math.BigInteger A)
Rational number from integer. A is an integer. R is the rational number A/1.


inverse

public Coefficient inverse()
Rational number inverse. R is a non-zero rational number. S=1/R.

Specified by:
inverse in interface Coefficient

RNINV

public static BigRational RNINV(BigRational R)

negate

public Coefficient negate()
Rational number negative. R is a rational number. S=-R.

Specified by:
negate in interface Coefficient

RNNEG

public static BigRational RNNEG(BigRational R)

RNNUM

public static java.math.BigInteger RNNUM(BigRational R)
Rational number numerator. R is a rational number. a is the numerator of R, an integer.


multiply

public Coefficient multiply(Coefficient S)
Rational number product. R and S are rational numbers. T=R*S.

Specified by:
multiply in interface Coefficient

multiply

public BigRational multiply(BigRational S)

RNPROD

public static BigRational RNPROD(BigRational R,
                                 BigRational S)

divide

public Coefficient divide(Coefficient S)
Rational number quotient. R and S are rational numbers, S non-zero. T=R/S.

Specified by:
divide in interface Coefficient

divide

public BigRational divide(BigRational S)

RNQ

public static BigRational RNQ(BigRational R,
                              BigRational S)

random

public Coefficient random(int n)
Rational number, random. n is a positive beta-integer. Random integers A and B are generated using IRAND(n). Then R=A/(ABS(B)+1), reduced to lowest terms.

Specified by:
random in interface Coefficient

RNRAND

public static BigRational RNRAND(int NL)

signum

public int signum()
Rational number sign. R is a rational number. s=SIGN(R).

Specified by:
signum in interface Coefficient

RNSIGN

public static int RNSIGN(BigRational R)

add

public Coefficient add(Coefficient S)
Rational number sum. R and S are rational numbers. T=R+S.

Specified by:
add in interface Coefficient

add

public BigRational add(BigRational S)

RNSUM

public static BigRational RNSUM(BigRational R,
                                BigRational S)