public override object Evaluate() { Complex value = LeftExpression.EvaluateAsComplex(); int digits = RightExpression.EvaluateAsInt32(); return(Complex.Round(value, digits)); }
public override void GetIntCode(BuildICCode codeManager) { RightExpression.GetIntCode(codeManager); var(x, type) = codeManager.variableManager.Peek(Id.Text); if (type is null) { type = codeManager.virtualTable.getAttrType(codeManager.variableManager.ClassName, Id.Text); } if ((RightExpression.StaticType.Text == "Int" || RightExpression.StaticType.Text == "Bool" || RightExpression.StaticType.Text == "String") && type == "Object") { codeManager.codeLines.Add(new ICPushParams(codeManager.variableManager.PeekCounter())); codeManager.codeLines.Add(new ICCallLabel(new ICLabel("_wrapper", RightExpression.StaticType.Text), codeManager.variableManager.PeekCounter())); codeManager.codeLines.Add(new ICPopParams(1)); } if (x != -1) { codeManager.codeLines.Add(new ICAssignVarToVar(x, codeManager.variableManager.PeekCounter())); } else { var offset = codeManager.virtualTable.getOffset(codeManager.variableManager.ClassName, Id.Text); codeManager.codeLines.Add(new ICAssignVarToMem(0, codeManager.variableManager.PeekCounter(), offset)); } }
public override object Evaluate() { Complex value = LeftExpression.EvaluateAsComplex(); Complex exp = RightExpression.EvaluateAsComplex(); return(Complex.Pow(value, 1.0 / exp)); }
public override object Evaluate() { double x = LeftExpression.EvaluateAsReal(); double y = RightExpression.EvaluateAsReal(); return((Complex)(x % y)); }
/// <summary> /// Evaluates the expression. /// </summary> /// <param name="context">Evaluation context.</param> /// <returns>Expression result.</returns> protected override object EvaluateNode(LogEventInfo context) { var v1 = LeftExpression.Evaluate(context); var v2 = RightExpression.Evaluate(context); return(Compare(v1, v2, RelationalOperator)); }
public override object Evaluate() { double y = LeftExpression.EvaluateAsReal(); double x = RightExpression.EvaluateAsReal(); return((Complex)Math.Atan2(y, x)); }
public override object Evaluate() { IList <Complex> m1 = LeftExpression.EvaluateAsExpandableComplexArray(); IList <Complex> m2 = RightExpression.EvaluateAsExpandableComplexArray(); return(MathStats.Correlation(m1, m2)); }
public override object Evaluate() { IList <double> v = LeftExpression.EvaluateAsRealVector(); if (RightExpression == Expression <Object> .Null) { return(new CMatrix(MathStats.Histogram(v))); } else { object intvals = RightExpression.Evaluate(); if (intvals is Complex) { return(new CMatrix(MathStats.Histogram(v, ExpressionExtensions.AsInt32((Complex)intvals)))); } else if (intvals is CMatrix) { return(new CMatrix(MathStats.Histogram(v, ExpressionExtensions.AsRealVector((CMatrix)intvals)))); } else { throw ExceptionHelper.ThrowWrongArgumentType(intvals); } } }
public override object Evaluate() { CPolynomial poly = LeftExpression.EvaluateAsCPolynomial(); int order = RightExpression.EvaluateAsInt32(); return(new CMatrix(poly.NthDerivative(order).ToArray())); }
public override object Evaluate() { CMatrix m = LeftExpression.EvaluateAsCMatrix(); int order = RightExpression.EvaluateAsInt32(); return(MathStats.PopulationCentralMoment(m, order)); }
public override object Evaluate() { CPolynomial poly1 = LeftExpression.EvaluateAsCPolynomial(); CPolynomial poly2 = RightExpression.EvaluateAsCPolynomial(); return(new CMatrix(CPolynomial.Modulus(poly1, poly2).ToArray())); }
public override object Evaluate() { IList <double> xValues = LeftExpression.EvaluateAsRealVector(); IList <double> yValues = RightExpression.EvaluateAsRealVector(); return(new CMatrix(CPolynomial.InterpolatingPolynomial(xValues, yValues).ToArray())); }
public override double Evaluate() { double left = LeftExpression.Evaluate(); double right = RightExpression.Evaluate(); return(left + Random.NextDouble() * (right - left)); }
public override object Evaluate() { double r = LeftExpression.EvaluateAsReal(); double theta = RightExpression.EvaluateAsReal(); return(new CMatrix(CoordSysConverter.PolarToCartesian(r, theta))); }
public override Object Evaluate() { object left = LeftExpression.Evaluate(); object right = RightExpression.Evaluate(); if (left is Complex) { if (right is Complex) { return(EvaluateComplexComplex((Complex)left, (Complex)right)); } else { throw ThrowWrongArgumentType("^"); } } else if (left is CMatrix) { if (right is Complex) { return(EvaluateCMatrixComplex((CMatrix)left, (Complex)right)); } else { throw ThrowWrongArgumentType("^"); } } else { throw ThrowWrongArgumentType("^"); } }
public override string AsString() { StringBuilder sb = new StringBuilder(); sb.Append("("); sb.Append(LeftExpression.ToString()); switch (BinaryOperator) { case ExpressionBinaryOperator.AND: sb.Append(" AND "); break; case ExpressionBinaryOperator.OR: sb.Append(" OR "); break; case ExpressionBinaryOperator.EQUALS: sb.Append(" EQUALS "); break; case ExpressionBinaryOperator.NOTEQUALS: sb.Append(" NOTEQUALS "); break; case ExpressionBinaryOperator.LESSTHAN: sb.Append(" LESSTHAN "); break; case ExpressionBinaryOperator.GREATERTHAN: sb.Append(" GREATERTHAN "); break; case ExpressionBinaryOperator.PLUS: sb.Append(" PLUS "); break; case ExpressionBinaryOperator.MINUS: sb.Append(" MINUS "); break; case ExpressionBinaryOperator.TIMES: sb.Append(" TIMES "); break; case ExpressionBinaryOperator.DIVIDEDBY: sb.Append(" DIVIDEDBY "); break; } sb.Append(RightExpression.ToString()); sb.Append(")"); return(sb.ToString()); }
public override object Evaluate() { double x = LeftExpression.EvaluateAsReal(); double y = RightExpression.EvaluateAsReal(); return(new CMatrix(CoordSysConverter.CartesianToPolar(x, y))); }
private static Rule GetRule(LeftExpression leftExpression, RightExpression rightExpression) { var rule = new Rule(leftExpression.View); rule.Initialize(leftExpression, rightExpression); return(rule); }
public ValueExpression Evaluate() { var leftValue = LeftExpression.Evaluate().Value; var rightValue = RightExpression.Evaluate().Value; switch (Operator) { case Operator.Plus: return(new ValueExpression { Value = leftValue + rightValue }); case Operator.Minus: return(new ValueExpression { Value = leftValue - rightValue }); case Operator.Asterisk: return(new ValueExpression { Value = leftValue * rightValue }); case Operator.Slash: return(new ValueExpression { Value = leftValue / rightValue }); } throw new InvalidOperationException(); }
/// <summary> /// Evaluates the expression. /// </summary> /// <param name="context">Evaluation context.</param> /// <returns>Expression result.</returns> protected override object EvaluateNode(LogEventInfo context) { object v1 = LeftExpression.Evaluate(context); object v2 = RightExpression.Evaluate(context); return(Compare(v1, v2, RelationalOperator) ? BoxedTrue : BoxedFalse); }
public override object Evaluate() { double rate = LeftExpression.EvaluateAsReal(); double x = RightExpression.EvaluateAsReal(); return((Complex) new ExponentialDistribution(rate).CumulativeDistributionFunction(x)); }
public override object Evaluate() { double rate = LeftExpression.EvaluateAsReal(); double x = RightExpression.EvaluateAsReal(); return((Complex) new ExponentialDistribution(rate).ProbabilityDensityFunction(x)); }
public override object Evaluate() { double a = LeftExpression.EvaluateAsReal(); double b = RightExpression.EvaluateAsReal(); return((Complex) new UniformDistribution(a, b).GetRandomVariable(_random)); }
public override string Template() { return($"{LeftExpression.Template()}" + "\nmovq\t%rax,%rcx" + $"\n{RightExpression.Template()}" + $"\n{AssignmentTemplate}\t# assign {RightExpression} to {LeftExpression}" + $"\n{LeftExpression.Save()}"); }
public override int Evaluate() { if (RightExpression.Evaluate() == 0) { throw new DivideByZeroException("divide by zero exception"); } return(LeftExpression.Evaluate() / RightExpression.Evaluate()); }
public override bool Eval(PCBObject Obj) { if (LeftExpression.Eval(Obj) == true) { return(true); } return(RightExpression.Eval(Obj)); }
public override object Evaluate() { int rows = LeftExpression.EvaluateAsInt32(); int cols = RightExpression.EvaluateAsInt32(); PerformanceManager.Current.EnsureAcceptableArraySize(rows * cols); return(new CMatrix(rows, cols)); }
private Margin GetMargin(LeftExpression leftExpression, RightExpression rightExpression) { if (rightExpression.Constant == null) { return(new Margin()); } // assumes all constants are in Dp var constantPx = DpToPx(leftExpression.View.Context, rightExpression.Constant.Value); switch (leftExpression.Position) { case Position.Top: return(new Margin { Top = constantPx }); case Position.Baseline: return(new Margin { Top = constantPx }); case Position.Right: return(new Margin { Right = -constantPx }); case Position.Bottom: return(new Margin { Bottom = -constantPx }); case Position.Left: return(new Margin { Left = constantPx }); case Position.Width: return(new Margin()); case Position.Height: return(new Margin()); case Position.CenterX: return(constantPx > 0 ? new Margin { Left = constantPx } : new Margin() { Right = -constantPx }); default: throw new ArgumentException($"Constant expressions with {rightExpression.Position} are currently unsupported."); } }
public void Initialize(LeftExpression leftExpression, RightExpression rightExpression) { if (!rightExpression.IsParent) { RelativeToViewId = rightExpression.Id; } SetMargin(leftExpression, rightExpression); SetLayoutRule(leftExpression, rightExpression); SetHeightWidth(leftExpression, rightExpression); }
public override string Template() { return ($"{LeftExpression.Template()}" + "\npush\t%rax" + $"\n{RightExpression.Template()}" + "\nmovq\t%rax,%rbx" + "\npop\t%rax" + "\ncqo" + $"\n{BinaryTemplate}"); }