public static Polinomial operator *(Polinomial a, Polinomial b) { Polinomial result = new Polinomial(); for (int i = 0; i < a.coefficients.Count + b.coefficients.Count - 1; i++) { result.AddCoefficient(0d); } for (int i = 0; i < a.coefficients.Count; i++) { for (int j = 0; j < b.coefficients.Count; j++) { result[i + j] += (a[i] * b[j]); } } return(result); }
public static Polinomial operator +(Polinomial a, Polinomial b) { Polinomial result = new Polinomial(); double curAddRes = 0d; for (int i = 0; i < Math.Max(a.coefficients.Count, b.coefficients.Count); i++) { if (i < a.coefficients.Count) { curAddRes += a[i]; } if (i < b.coefficients.Count) { curAddRes += b[i]; } result.AddCoefficient(curAddRes); curAddRes = 0d; } return(result); }