public static Expression Add(params Expression[] terms) { TypeInference type = new TypeInference(terms); return type.CastToMaxNumeric() .Where(x => !Elementary.IsConstantZero(x)) .Reduce(Expression.Add, Zero()); }
public static Expression Add(params Expression[] terms) { TypeInference type = new TypeInference(terms); return(type.CastToMaxNumeric() .Where(x => !Elementary.IsConstantZero(x)) .Reduce(Expression.Add, Zero())); }
public static Expression Multiply(params Expression[] terms) { TypeInference type = new TypeInference(terms); List <Expression> factors = type.CastToMaxNumeric() .Where(x => !Elementary.IsConstantOne(x)) .ToList(); if (factors.Exists(Elementary.IsConstantZero)) { return(Zero()); } return(factors.Reduce(Expression.Multiply, One())); }
public static Expression Multiply(params Expression[] terms) { TypeInference type = new TypeInference(terms); List<Expression> factors = type.CastToMaxNumeric() .Where(x => !Elementary.IsConstantOne(x)) .ToList(); if(factors.Exists(Elementary.IsConstantZero)) { return Zero(); } return factors.Reduce(Expression.Multiply, One()); }