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