public static IAST List(final double... numbers) { INum a[] = new INum[numbers.length]; for (int i = 0; i < numbers.length; i++) { a[i] = F.num(numbers[i]); } return ast(a, List); }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine){ if (engine.isNumericMode()) { return F.num(this); } return null; }
/** * Get the first argument (i.e. the second element of the underlying list structure) of the <code>AST</code> function (i.e. get(1) * ). <br /> * <b>Example:</b> for the AST representing the expression <code>Sin(x)</code>, <code>arg1()</code> returns <code>x</code>. * * @return the first argument of the function represented by this <code>AST</code>. * @see IExpr#head() */ @Override public IExpr arg1() { return F.num(vector.getEntry(0)); }
/** * Get the third argument (i.e. the fourth element of the underlying list structure) of the <code>AST</code> function (i.e. get(3) * ).<br /> * <b>Example:</b> for the AST representing the expression <code>f(a, b, c)</code>, <code>arg3()</code> returns <code>c</code>. * * @return the third argument of the function represented by this <code>AST</code>. * @see IExpr#head() */ @Override public IExpr arg3() { return F.num(vector.getEntry(2)); }
/** {@inheritDoc} */ @Override public ISignedNumber fractionalPart() { return F.num(fApfloat.frac()); }
@Override public IExpr e1DblArg(final double arg1) { if (F.isZero(arg1)) { return F.CComplexInfinity; } return F.num(Math.acos(1 / arg1)); }
/** {@inheritDoc} */ @Override public ISignedNumber im() { return F.num(getImaginaryPart()); }
@Override public IExpr evaluate(final IAST ast) { if (ast.size() == 1) { // RandomReal[] gives a double value between 0.0 and 1.0 double r = Math.random(); return F.num(r); } return null; }
@Override public IExpr e1DblArg(final double arg1) { double val = FastMath.asinh(arg1); return F.num(val); }
@Override public IExpr numericEvalD1(final Num arg1) { double x = arg1.doubleValue(); if (x > 0.0) { double gamma; gamma = org.apache.commons.math3.special.Gamma.logGamma(x); gamma = Math.exp(gamma); return F.num(gamma); } return null; }
@Override public IExpr numericEvalD1(final Num arg1) { double d = org.apache.commons.math3.special.Gamma.logGamma(arg1.doubleValue() + 1); return F.num(Math.exp(d)); }
@Override public IExpr e1DblArg(INum num) { double d = de.lab4inf.math.functions.Zeta.zeta(num.doubleValue()); return F.num(d); }
@Override public IExpr e1DblArg(final double arg1) { double val = Math.acos(arg1); if (Double.isNaN(val)) { return F.complexNum(Complex.valueOf(arg1).acos()); } return F.num(val); }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine) { if (engine.isNumericMode()) { return F.num(this); } if (getBigDenominator().equals(BigInteger.ONE)) { return F.integer(getBigNumerator()); } return null; }
/** {@inheritDoc} */ @Override public IExpr evaluate(EvalEngine engine){ if (F.isZero(getImaginaryPart())) { return F.num(getRealPart()); } return null; }
public IExpr numericEval(final IAST ast) { Validate.checkSize(ast, 2); double[] values = Expr2Object.toDoubleVector(ast.getAST(1)); return F.num(StatUtils.geometricMean(values)); } }
@Override public IExpr numericEval(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); double[] values = ast.getAST(1).toDoubleVector(); return F.num(StatUtils.geometricMean(values)); } }
@Override public IExpr e1ApfloatArg(Apfloat arg1) { if (arg1.equals(Apcomplex.ZERO)) { // I*Pi / 2 return F.complexNum( new Apcomplex(Apcomplex.ZERO, ApfloatMath.pi(arg1.precision())).divide(new Apfloat(2))); } return F.num(ApfloatMath.atanh(ApfloatMath.inverseRoot(arg1, 1))); }
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); } }