public int Compare(SymbolicExpression x, SymbolicExpression y)
        {
            var(ux, uy) = (ExpressionSimplifier.UnwrapFactors(x), ExpressionSimplifier.UnwrapFactors(y));

            int result = Comparer <byte> .Default.Compare(ux.Expression.GetSortOrder(), uy.Expression.GetSortOrder());

            if (result == 0)
            {
                result = CompareUnwrapped(ux.Expression, uy.Expression);
            }

            if (result == 0)
            {
                result = Comparer <long> .Default.Compare(ux.Factor, uy.Factor);
            }

            return(result);
        }
Exemplo n.º 2
0
 public static SymbolicExpression Ln(SymbolicExpression x)
 => ExpressionSimplifier.TrySimplifyLn(x)
 ?? new UnaryOperationExpression(UnaryOperator.Ln, x);
Exemplo n.º 3
0
 public static SymbolicExpression Cos(SymbolicExpression x)
 => ExpressionSimplifier.TrySimplifyCos(x)
 ?? new UnaryOperationExpression(UnaryOperator.Cos, x);
Exemplo n.º 4
0
 public static SymbolicExpression Root(SymbolicExpression x, SymbolicExpression y)
 => ExpressionSimplifier.TrySimplifyRoot(x, y)
 ?? new BinaryOperationExpression(BinaryOperator.Root, x, y);
Exemplo n.º 5
0
 public static SymbolicExpression Pow(SymbolicExpression x, SymbolicExpression y)
 => ExpressionSimplifier.TrySimplifyPower(x, y)
 ?? new BinaryOperationExpression(BinaryOperator.Power, x, y);
Exemplo n.º 6
0
 public static SymbolicExpression Divide(SymbolicExpression a, SymbolicExpression b)
 => ExpressionSimplifier.TrySimplifyDivision(a, b)
 ?? new BinaryOperationExpression(BinaryOperator.Division, a, b);
Exemplo n.º 7
0
 public static SymbolicExpression Multiply(ImmutableArray <SymbolicExpression> operands)
 => ExpressionSimplifier.TrySimplifyMultiplication(operands)
 ?? new VariadicOperationExpression(VariadicOperator.Multiplication, operands);
Exemplo n.º 8
0
 public static SymbolicExpression Multiply(SymbolicExpression a, SymbolicExpression b)
 => ExpressionSimplifier.TrySimplifyMultiplication(a, b)
 ?? new BinaryOperationExpression(BinaryOperator.Multiplication, a, b);
Exemplo n.º 9
0
 public static SymbolicExpression Subtract(SymbolicExpression a, SymbolicExpression b)
 => ExpressionSimplifier.TrySimplifySubtraction(a, b)
 ?? new BinaryOperationExpression(BinaryOperator.Subtraction, a, b);
Exemplo n.º 10
0
 public static SymbolicExpression Add(ImmutableArray <SymbolicExpression> operands)
 => ExpressionSimplifier.TrySimplifyAddition(operands)
 ?? new VariadicOperationExpression(VariadicOperator.Addition, operands);
Exemplo n.º 11
0
 public static SymbolicExpression Add(SymbolicExpression a, SymbolicExpression b)
 => ExpressionSimplifier.TrySimplifyAddition(a, b)
 ?? new BinaryOperationExpression(BinaryOperator.Addition, a, b);
Exemplo n.º 12
0
 public static SymbolicExpression Negate(SymbolicExpression e)
 => ExpressionSimplifier.TrySimplifyNegation(e)
 ?? new UnaryOperationExpression(UnaryOperator.Minus, e);