示例#1
0
文件: Quotient.java 项目: rjolly/jas
 /**
  * Quotient multiplication.
  *
  * @param S Quotient.
  * @return this*S.
  */
 public Quotient<C> multiply(Quotient<C> S) {
   if (S == null || S.isZERO()) {
     return S;
   }
   if (num.isZERO()) {
     return this;
   }
   if (S.isONE()) {
     return this;
   }
   if (this.isONE()) {
     return S;
   }
   C n = num.multiply(S.num);
   C d = den.multiply(S.den);
   return new Quotient<C>(ring, n, d, false);
 }
示例#2
0
文件: Quotient.java 项目: rjolly/jas
 /**
  * Quotient subtraction.
  *
  * @param S Quotient.
  * @return this-S.
  */
 public Quotient<C> subtract(Quotient<C> S) {
   if (S == null || S.isZERO()) {
     return this;
   }
   C n = num.multiply(S.den);
   n = n.subtract(den.multiply(S.num));
   C d = den.multiply(S.den);
   return new Quotient<C>(ring, n, d, false);
 }
示例#3
0
文件: Quotient.java 项目: rjolly/jas
 // JAVA6only: @Override
 public int compareTo(Quotient<C> b) {
   if (b == null || b.isZERO()) {
     return this.signum();
   }
   C r = num.multiply(b.den);
   C s = den.multiply(b.num);
   C x = r.subtract(s);
   return x.signum();
 }
示例#4
0
文件: Quotient.java 项目: rjolly/jas
 /**
  * Quotient division.
  *
  * @param S Quotient.
  * @return this/S.
  */
 public Quotient<C> divide(Quotient<C> S) {
   return multiply(S.inverse());
 }