/** * Create a "fractional" number * * @param numerator * numerator of the fractional number * @param denominator * denumerator of the fractional number * @return IFraction */ public static IFraction fraction(final IInteger numerator, final IInteger denominator) { return FractionSym.valueOf(numerator, denominator); }
/** * Create a "fractional" number * * @param numerator * numerator of the fractional number * @param denominator * denumerator of the fractional number * @return IFraction */ public static IFraction fraction(final BigInteger numerator, final BigInteger denominator) { return FractionSym.valueOf(numerator, denominator); }
/** * Create a "fractional" number * * @param value * the double value which should be converted to a fractional number * @return IFraction */ public static IFraction fraction(final double value) { return FractionSym.valueOf(value); }
/** * Returns the fractional part of the rational, i.e. the number this.sub(this.floor()). * * @return Next smaller integer of <code>this</code>. */ @Override public IFraction fractionalPart() { if (fDenominator == 1) { return AbstractFractionSym.ZERO; } return valueOf(fNumerator % fDenominator, fDenominator); }
/** * Create a "fractional" number * * @param numerator * numerator of the fractional number * @param denominator * denumerator of the fractional number * @return IFraction */ public static IFraction fraction(final long numerator, final long denominator) { return FractionSym.valueOf(numerator, denominator); }
public IFraction getIm() { return FractionSym.valueOf(_imaginary); }
/** * Returns a new rational representing the inverse of <code>this</code>. * * @return Inverse of <code>this</code>. */ @Override public IFraction inverse() { return valueOf(fDenominator, fNumerator); }
public IFraction getRe() { return FractionSym.valueOf(_real); }
public static IFraction fraction(final edu.jas.arith.BigRational value) { return FractionSym.valueOf(value.num, value.den); }
/** * Compute the absolute of this rational. * * @return Rational that is equal to the absolute value of this rational. */ @Override public IFraction abs() { return valueOf(Math.abs((long) fNumerator), fDenominator); }
/** * Create a symbolic complex number * * @param realPart * the real double value part which should be converted to a complex * number * @param imagPart * the imaginary double value part which should be converted to a * complex number * @return IFraction */ public static IComplex complex(final double realPart, final double imagPart) { return ComplexSym.valueOf(FractionSym.valueOf(realPart), FractionSym.valueOf(imagPart)); }
/** * Create a "fractional" number * * @param value * the rational value which should be converted to a fractional * number * @return IFraction */ public static IFraction fraction(final BigFraction value) { return FractionSym.valueOf(value.getNumerator(), value.getDenominator()); }
/** {@inheritDoc} */ @Override public IExpr times(final IExpr that) { if (that instanceof FractionSym) { return this.multiply((FractionSym) that); } if (that instanceof IntegerSym) { return this.multiply(valueOf(((IntegerSym) that).fInteger)); } return super.times(that); }
/** * @param that * @return */ @Override public IExpr plus(final IExpr that) { if (that instanceof FractionSym) { return this.add((FractionSym) that); } if (that instanceof IntegerSym) { return this.add(valueOf(((IntegerSym) that).fInteger)); } return super.plus(that); }
public IExpr evaluate(final IAST ast) { if (ast.size() == 2) { final long begin = System.currentTimeMillis(); final EvalEngine engine = EvalEngine.get(); final IExpr result = engine.evaluate(ast.get(1)); return List(Times(FractionSym.valueOf((System .currentTimeMillis() - begin), 1000L), F.Second), result); } return null; }
@Override public IExpr plus(final IExpr that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that); } if (isZero()) { return that; } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).add((FractionSym) that); } return super.plus(that); }
public IExpr eabs() { return F.Sqrt(FractionSym.valueOf(_real.multiply(_real).add(_imaginary.multiply(_imaginary)))); }
public ISignedNumber minus(ISignedNumber that) { if (that instanceof IntegerSym) { return this.add((IntegerSym) that.negate()); } if (isZero()) { return that.negate(); } if (that instanceof FractionSym) { return FractionSym.valueOf(fInteger).minus(that); } return Num.valueOf(fInteger.doubleValue() - that.doubleValue()); }
/** {@inheritDoc} */ public ISignedNumber minus(ISignedNumber that) { if (that instanceof FractionSym) { return this.add((FractionSym) that.negate()); } if (isZero()) { return that.negate(); } if (that instanceof IntegerSym) { return this.minus(valueOf(((IntegerSym) that).fInteger)); } return Num.valueOf(doubleValue() - that.doubleValue()); }