use of org.matheclipse.core.interfaces.IFraction in project symja_android_library by axkr.
the class ComplexSym method normalize.
@Override
public INumber normalize() {
if (fImaginary.isZero()) {
if (fReal instanceof IFraction) {
if (fReal.getDenominator().isOne()) {
return fReal.getNumerator();
}
if (fReal.getNumerator().isZero()) {
return F.C0;
}
}
return fReal;
}
boolean evaled = false;
IRational newRe = fReal;
IRational newIm = fImaginary;
if (fReal instanceof IFraction) {
if (fReal.getDenominator().isOne()) {
newRe = fReal.getNumerator();
evaled = true;
}
if (fReal.getNumerator().isZero()) {
newRe = F.C0;
evaled = true;
}
}
if (fImaginary instanceof IFraction && fImaginary.getDenominator().isOne()) {
newIm = fImaginary.getNumerator();
evaled = true;
}
return evaled ? valueOf(newRe, newIm) : this;
}
use of org.matheclipse.core.interfaces.IFraction in project symja_android_library by axkr.
the class FractionSym method add.
@Override
public IRational add(IRational parm1) {
if (parm1.isZero()) {
return this;
}
if (parm1 instanceof IFraction) {
return add((IFraction) parm1);
}
if (parm1 instanceof IntegerSym) {
IntegerSym is = (IntegerSym) parm1;
long newnum = fNumerator + (long) fDenominator * (long) is.fIntValue;
return valueOf(newnum, fDenominator);
}
BigInteger newnum = toBigNumerator().add(toBigDenominator().multiply(parm1.toBigNumerator()));
return valueOf(newnum, toBigDenominator());
}
use of org.matheclipse.core.interfaces.IFraction in project symja_android_library by axkr.
the class BigFractionSym method add.
@Override
public IRational add(IRational parm1) {
if (parm1.isZero()) {
return this;
}
if (parm1 instanceof IFraction) {
return add((IFraction) parm1);
}
IInteger p1 = (IInteger) parm1;
BigInteger newnum = toBigNumerator().add(toBigDenominator().multiply(p1.toBigNumerator()));
return valueOf(newnum, toBigDenominator());
}
use of org.matheclipse.core.interfaces.IFraction in project symja_android_library by axkr.
the class BigIntegerSym method add.
@Override
public IRational add(IRational parm1) {
if (parm1.isZero()) {
return this;
}
if (parm1 instanceof IFraction) {
return ((IFraction) parm1).add(this);
}
IInteger p1 = (IInteger) parm1;
BigInteger newnum = toBigNumerator().add(p1.toBigNumerator());
return valueOf(newnum);
}
use of org.matheclipse.core.interfaces.IFraction in project symja_android_library by axkr.
the class BigIntegerSym method multiply.
@Override
public IRational multiply(IRational parm1) {
if (parm1.isZero()) {
return F.C0;
}
if (parm1.isOne()) {
return this;
}
if (parm1.isMinusOne()) {
return this.negate();
}
if (parm1 instanceof IFraction) {
return ((IFraction) parm1).multiply(this);
}
IInteger p1 = (IInteger) parm1;
BigInteger newnum = toBigNumerator().multiply(p1.toBigNumerator());
return valueOf(newnum);
}
Aggregations