public Exprs.NumberExpr NextPrime(EvalContext argContext, Exprs.Expr n) { var pInt = Integer(argContext, n); var pRet = BigInteger.NextProbablePrime(pInt, argContext.CancelToken); return(Exprs.Expr.Number(pRet)); }
public Exprs.ListExpr Primes(EvalContext argContext, Exprs.Expr start, Exprs.Expr end) { var pStartInt = Integer(argContext, start); var pEndInt = Integer(argContext, end); var pPrimes = from n in Math.MathEx.Primes(pStartInt, pEndInt, PrimePNumberOfTest, argContext.CancelToken) select Exprs.Expr.Number(n); return(Exprs.Expr.List(pPrimes)); }
public Exprs.BooleanExpr PrimeP(EvalContext argContext, Exprs.Expr n) { var pInt = Integer(argContext, n); var pRet = BigInteger.IsProbablePrime(pInt, PrimePNumberOfTest, argContext.CancelToken); return(Exprs.Expr.Boolean(pRet)); }
public BigInteger Integer(EvalContext argContext, Exprs.Expr e) { if (!Integer(argContext, e, out Exprs.Expr argRet, out BigInteger argInteger)) { throw new EvalException(string.Format(Properties.Resources.NoExprIntegerException, e)); } return(argInteger); }
public void AddInOut(Exprs.Expr i, Exprs.Expr o, out string argNameVarOut) { lock (mInOutExprs) { mInOutExprs.Add(new InOutExpr { In = i, Out = o }); argNameVarOut = OutNVar(mInOutExprs.Count); } }
public string Tex(EvalContext argContext, Exprs.Expr e) { argContext.CancelToken.ThrowIfCancellationRequested(); switch (e.TypeExpr) { case Exprs.ETypeExpr.List: return(Tex(argContext, (Exprs.ListExpr)e)); default: return(e.ToString()); } }
public InOutExpr AddInOut(Exprs.Expr i, Exprs.Expr o, out string argNameVarIn, out string argNameVarOut) { lock (mInOutExprs) { var pIOE = new InOutExpr { In = i, Out = o }; mInOutExprs.Add(pIOE); argNameVarIn = InNVar(mInOutExprs.Count); argNameVarOut = OutNVar(mInOutExprs.Count); return(pIOE); } }
public bool Integer(EvalContext argContext, Exprs.Expr e, out Exprs.Expr argRet, out BigInteger argInteger) { var pRet = Approx(argContext, Exprs.EPrecisionNumber.Integer, e); argRet = pRet; if (pRet.TypeExpr == Exprs.ETypeExpr.Number && pRet is Exprs.IntegerNumberExpr en) { argInteger = en.PrecisionValue; return(true); } argInteger = null; return(false); }
public Exprs.Expr Eval(EvalContext argContext, Exprs.Expr e) { switch (e.TypeExpr) { case Exprs.ETypeExpr.Number: if (e is Exprs.NumberExpr ne) { return(ne.ConverTo(argContext.Precision, FPPrec)); } break; case Exprs.ETypeExpr.Function: if (e is Exprs.FunctionExpr pFn) { return(Eval(argContext, pFn)); } break; } return(e); }
protected virtual void PrintExpr(string argNameVarPrompt, Exprs.Expr e) { }
public virtual void PrintExprOut(string argNameVarPrompt, Exprs.Expr e) => PrintExpr(argNameVarPrompt, e);
public Exprs.Expr Eval(Exprs.Expr e, IVars argVars, CancellationToken argCancelToken) => e;
public Exprs.Expr Approx(EvalContext argContext, Exprs.EPrecisionNumber argPrecision, Exprs.Expr e) { var c = new EvalContext(argContext, argPrecision); var e1 = Eval(c, e); // falta aplicar operaciones y funciones matemáticas var e2 = e1; return((e2.TypeExpr == Exprs.ETypeExpr.Number && e2 is Exprs.NumberExpr ne) ? ne.ConverTo(argPrecision, FPPrec) : e2); }
public Exprs.Expr EvalIn(EvalContext argContext, Exprs.Expr e) { var pExpr = (e.TypeExpr == Exprs.ETypeExpr.Function && e is Exprs.FunctionExpr pFn) ? Eval(argContext, pFn, false) : Eval(argContext, e); return(pExpr); }