public static IFinitaryOperation <double> GetOperation( this PolynomialDivision operation, params PolynomialTerm[] variables) { return(new PolynomialFinitaryOperation( variables: variables, valueCalculation: x => operation.Value(x))); }
public PolynomialDivision Composition(char variable, PolynomialDivision replacement) { var remaining = new PolynomialTerm(_coefficient, _indeterminates.AsList().Where(kv => kv.Variable != variable)); IReadOnlyList <IndeterminateExpression> toReplace = _indeterminates.AsList().Where(kv => kv.Variable == variable).ToArray(); PolynomialDivision inPlace = 1; if (toReplace.Count > 0) { if (toReplace.Count > 1 && toReplace.Any(i => i.HasUnaryModifier)) { throw new NotSupportedException("Composition of variables used in modifiers is not supported"); } uint power = toReplace.Single().Power; for (uint i = 0; i < power; ++i) { inPlace *= replacement; } } return(remaining * inPlace); }
public static PolynomialDivision operator /(PolynomialTerm a, PolynomialTerm b) { return(PolynomialDivision.SimplifyPolynomialDivision(numerator: a, denominator: b)); }