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