Android Open Source - simple-matrix Rational Calc






From Project

Back to project page simple-matrix.

License

The source code is released under:

MIT License

If you think the Android project simple-matrix listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.alexkang.x3matrixcalculator.calculations;
// w  w  w  . j ava 2s. com
public class RationalCalc {
  
  public static Rational addRat(Rational x, Rational y) {
    int denom = x.getDenom() * y.getDenom();
    
    Rational sum = new Rational(
        x.getNum() * y.getDenom() + y.getNum() * x.getDenom(), 
        denom
        );
    
    return sum;
  }
  
  public static Rational subRat(Rational x, Rational y) {
    Rational negativeY = mulRat(new Rational(-1), y);
    return addRat(x, negativeY);
  }
  
  public static Rational mulRat(Rational x, Rational y) {
    return new Rational(
        x.getNum() * y.getNum(),
        x.getDenom() * y.getDenom());
  }
  
  public static Rational divRat(Rational x, Rational y) {
    Rational inverseY = new Rational(y.getDenom(), y.getNum());
    return mulRat(x, inverseY);
  }
}




Java Source Code List

com.alexkang.x3matrixcalculator.DisplayResultActivity.java
com.alexkang.x3matrixcalculator.MainActivity.java
com.alexkang.x3matrixcalculator.MatrixRational.java
com.alexkang.x3matrixcalculator.Matrix.java
com.alexkang.x3matrixcalculator.SettingsActivity.java
com.alexkang.x3matrixcalculator.calculations.Advanced.java
com.alexkang.x3matrixcalculator.calculations.Basic.java
com.alexkang.x3matrixcalculator.calculations.RationalAdvanced.java
com.alexkang.x3matrixcalculator.calculations.RationalBasic.java
com.alexkang.x3matrixcalculator.calculations.RationalCalc.java
com.alexkang.x3matrixcalculator.calculations.Rational.java