public double getXScale() { double diff = xMax - xMin; if (F.isZero(diff)) { return 0.0; } return width / diff; }
/** {@inheritDoc} */ @Override public boolean isPi() { return F.isZero(fDouble - Math.PI); }
@Override public boolean isSame(IExpr expression, double epsilon) { if (expression instanceof Num) { return F.isZero(fDouble - ((Num) expression).fDouble, epsilon); } return false; }
/** {@inheritDoc} */ @Override public boolean isMinusOne() { return F.isZero(fDouble + 1.0); }
@Override public boolean isZero() { return F.isZero(fDouble); // return fDouble == 0.0; }
/** * Test if the absolute value is less <code>Config.DOUBLE_EPSILON</code>. * * @param value * @return */ public static boolean isZero(double value) { return isZero(value, Config.DOUBLE_EPSILON); }
@Override public double applyAsDouble(double operand) { if (F.isZero(operand)) { // Pi / 2 return Math.PI / 2.0; } return Math.atan(1 / operand); }
/** * {@inheritDoc} */ public int toInt() throws ArithmeticException { if (fDouble > Integer.MAX_VALUE || fDouble < Integer.MIN_VALUE) { throw new ArithmeticException("toInt: double value not in int range"); } int result = Double.valueOf(fDouble).intValue(); if (F.isZero(fDouble - result)) { return result; } throw new ArithmeticException("toInt: double value is not an int value"); }
@Override public IExpr e1DblArg(final double d) { // log(1+Sqrt(1-d^2) / d) if (F.isZero(d)) { return F.Indeterminate; } return F.num(Math.log((1 + Math.sqrt(1 - d * d)) / d)); }
@Override public double applyAsDouble(double operand) { if (F.isZero(operand)) { return Double.NEGATIVE_INFINITY; } return de.lab4inf.math.functions.ExponentialIntegalFunction.ei(operand); }
/** {@inheritDoc} */ @Override public boolean isRationalValue(IRational value) { return F.isZero(fDouble - value.doubleValue()); }
@Override public double applyAsDouble(double operand) { if (F.isZero(operand)) { throw new ComplexResultException("ArcCoth(0)"); } double c = 1.0 / operand; return (Math.log(1.0 + c) - Math.log(1.0 - c)) / 2.0; }
@Override public double evalReal(final double[] stack, final int top, final int size) { if (size != 1) { throw new UnsupportedOperationException(); } if (F.isZero(stack[top])) { return Double.NEGATIVE_INFINITY; } return de.lab4inf.math.functions.ExponentialIntegalFunction.ei(stack[top]); }
@Override public IExpr e1DblArg(final double arg1) { if (F.isZero(arg1)) { return F.CComplexInfinity; } return F.num(Math.asin(1 / arg1)); }
public boolean isSame(IExpr expression, double epsilon) { if (expression instanceof ComplexNum) { return F.isZero(fComplex.getReal() - ((ComplexNum) expression).fComplex.getReal(), epsilon) && F.isZero(fComplex.getImaginary() - ((ComplexNum) expression).fComplex.getImaginary(), epsilon); // return Math.abs(fComplex.getReal() - ((ComplexNum) // expression).fComplex.getReal()) < epsilon // && Math.abs(fComplex.getImaginary() - ((ComplexNum) // expression).fComplex.getImaginary()) < epsilon; } return false; }
@Override public IExpr e1DblArg(final double arg1) { if (F.isZero(arg1)) { return F.CNInfinity; } return F.num(de.lab4inf.math.functions.ExponentialIntegalFunction.ei(arg1)); }
@Override public boolean isSame(IExpr expression, double epsilon) { if (expression instanceof ComplexNum) { return F.isZero(fComplex.getReal() - ((ComplexNum) expression).fComplex.getReal(), epsilon) && F.isZero(fComplex.getImaginary() - ((ComplexNum) expression).fComplex.getImaginary(), epsilon); } return false; }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine){ if (F.isZero(getImaginaryPart())) { return F.num(getRealPart()); } return null; }
@Override public IExpr e1DblArg(final double arg1) { if (F.isZero(arg1)) { return F.C0; } if (F.isEqual(arg1, 1.0)) { return F.CNInfinity; } return F.num(de.lab4inf.math.functions.LogarithmicIntegalFunction.li(arg1)); }
public static INumber jas2Numeric(edu.jas.poly.Complex<BigRational> c, double epsilon) { IFraction re = F.fraction(c.getRe().numerator(), c.getRe().denominator()); double red = re.doubleValue(); IFraction im = F.fraction(c.getIm().numerator(), c.getIm().denominator()); double imd = im.doubleValue(); if (F.isZero(imd, epsilon)) { return F.num(red); } return F.complexNum(red, imd); } }