public static Polinomial operator *(Polinomial fpol, Polinomial spol) { Polinomial res = new Polinomial(fpol.Degree + spol.Degree + 1); for (int k1 = 0; k1 <= fpol.Degree; k1++) { for (int k2 = 0; k2 <= spol.Degree; k2++) { res.coef[k1 + k2] += fpol.coef[k1] * spol.coef[k2]; } } return(res); }
public static Polinomial operator -(Polinomial Fpol, Polinomial Spol) { Polinomial result = new Polinomial(); if (Fpol.Degree > Spol.Degree) { result.coef = Spol.coef.Concat(Enumerable.Repeat(0.0, Fpol.Degree - Spol.Degree).ToList()).ToList(); result.coef = Fpol.coef.Zip(result.coef, (x, y) => x - y).ToList(); } else { result.coef = Fpol.coef.Concat(Enumerable.Repeat(0.0, Spol.Degree - Fpol.Degree).ToList()).ToList(); result.coef = Spol.coef.Zip(result.coef, (x, y) => y - x).ToList(); } return(result); }
public override bool Equals(Object obj) { Polinomial temp = (Polinomial)obj; bool res = true; if (this.Degree != temp.Degree) { res = false; } else { for (int i = 0; i < this.Degree + 1; i++) { if (this[i] != temp[i]) { res = false; } } } return(res); }