public Polynomial <T, TField> Divide(Polynomial <T, TField> t1, Polynomial <T, TField> t2, out Polynomial <T, TField> r) { return(Polynomial <T, TField> .Divide(t1, t2, out r)); }
public Polynomial <T, TField> Gcd(Polynomial <T, TField> t1, Polynomial <T, TField> t2) { return(Polynomial <T, TField> .Gcd(t1, t2)); }
public Polynomial <T, TField> Pow(Polynomial <T, TField> t, int n) { return(t.Pow(n)); }
public BigInteger Euclidean(Polynomial <T, TField> t) { return(t.Degree); }
public static Polynomial <T, TField> Divide(Polynomial <T, TField> p1, Polynomial <T, TField> p2) { Polynomial <T, TField> rem; return(Divide(p1, p2, out rem)); }
public Polynomial <T, TField> Multiply(Polynomial <T, TField> t, int n) { return(t * _field.Multiply(_field.One, n)); }
public Polynomial <T, TField> Negate(Polynomial <T, TField> t) { return(-t); }
public bool IsApproxZero(Polynomial <T, TField> t) { return(t.Degree == 0 && _field.IsApproxZero(t.CoefficientAt(0))); }
public static Polynomial <T, TField> Spread(int n, Polynomial <T, TField> x) { return((x.Field.One - ChebyshevT(n, x.Field.One - x * 2)) / 2); }
public Polynomial <T, TField> Add(Polynomial <T, TField> t1, Polynomial <T, TField> t2) { return(t1 + t2); }
public static Polynomial <T, TField> Lcm(Polynomial <T, TField> p1, Polynomial <T, TField> p2) { return((p1 / Gcd(p1, p2)) * p2); }
public static Polynomial <T, TField> FromPolynomial <U, UField>(Polynomial <U, UField> p, Func <U, T> f) where U : IEquatable <U> where UField : IField <U>, new() { return(new Polynomial <T, TField>(p.Select(term => new Term <T>(term.Deg, f(term.Coeff))))); }
public static Polynomial <T, TField> FromPolynomial <UField>(Polynomial <T, UField> p) where UField : IField <T>, new() { return(new Polynomial <T, TField>(p.CloneArray())); }
public Polynomial <T, TField> Lcm(Polynomial <T, TField> t1, Polynomial <T, TField> t2) { return(Polynomial <T, TField> .Lcm(t1, t2)); }
public Polynomial <T, TField> Subtract(Polynomial <T, TField> t1, Polynomial <T, TField> t2) { return(t1 - t2); }
public Polynomial <T, TField> Divide(Polynomial <T, TField> t, int n) { return(t / _field.Multiply(_field.One, n)); }
public Polynomial <T, TField> Multiply(Polynomial <T, TField> t1, Polynomial <T, TField> t2) { return(t1 * t2); }
public bool IsUnit(Polynomial <T, TField> t) { return(t.Degree == 0 && _field.IsUnit(t.CoefficientAt(0))); }
public static Polynomial <T, TField> Divide(Polynomial <T, TField> p1, Polynomial <T, TField> p2, out Polynomial <T, TField> rem) { IField <T> field = p1.Field; T leadingCoeff; T[] dividList; T[] divisList; T[] quotList; T[] workList; if (p2.Degree > p1.Degree) { rem = p1; return(Polynomial <T, TField> .Zero); } if (p2.Degree == 0) { rem = new Polynomial <T, TField>(); return(Divide(p1, p2[0].Coeff)); } dividList = p1.ToCoefficientList(); divisList = p2.ToCoefficientListForDivisor(out leadingCoeff); quotList = new T[p1.Degree - p2.Degree + 1]; workList = new T[divisList.Length]; if (!field.IsOne(leadingCoeff)) { // Fix the dividend. for (int i = 0; i < dividList.Length; i++) { dividList[i] = field.Divide(dividList[i], leadingCoeff); } } // Initialize the work list. Array.Copy(dividList, workList, workList.Length); for (int i = 0; i < quotList.Length; i++) { // Save the quotient cofficient. quotList[i] = workList[0]; // Shift left, take in from dividend. Array.Copy(workList, 1, workList, 0, workList.Length - 1); workList[workList.Length - 1] = dividList[i + workList.Length]; // Copy the divisor and multiply with the last quotient // coefficient. Add this to the work list. Note that this // is all done in one step. for (int j = 0; j < workList.Length; j++) { workList[j] = field.Add(workList[j], field.Multiply(divisList[j], quotList[i])); } } if (!field.IsOne(leadingCoeff)) { // Fix the remainder. for (int i = 0; i < workList.Length; i++) { workList[i] = field.Multiply(workList[i], leadingCoeff); } } rem = FromCoefficientList(workList); return(FromCoefficientList(quotList)); }