public static Polynom Subtract(Polynom polynom1, Polynom polynom2) { if (polynom1 == null) throw new ArgumentNullException("polinom1 is null"); if (polynom2 == null) throw new ArgumentNullException("polinom2 is null"); return polynom1 + (-polynom2); }
public void Equals_PolynomOverride(Polynom polynom1, Polynom polynom2) { Polynom polynom3 = polynom1; Assert.AreEqual(polynom1.Equals(polynom1), true); Assert.AreEqual(polynom1.Equals(polynom2), polynom2.Equals(polynom1)); Assert.AreEqual(polynom1.Equals(null), false); Assert.AreEqual(polynom3.Equals(polynom1), true); }
public Polynom(Polynom polinom) { if (polinom == null) throw new ArgumentNullException("polinom is null"); coefficient = new double[polinom.coefficient.Length]; for (int i = 0; i < polinom.coefficient.Length; i++) coefficient[i] = polinom.coefficient[i]; degree = polinom.degree; }
public static Polynom Add(Polynom polinom1, Polynom polinom2) { if (polinom1 == null) throw new ArgumentNullException("'polinom1' is null"); if (polinom2 == null) throw new ArgumentNullException("'polinom2' is null"); int maxDegree = Math.Max(polinom1.degree, polinom2.degree); double[] buffArray = new double[maxDegree]; for (int i = 0; i < maxDegree; i++) { double temp = 0; if (i < polinom1.degree) temp += polinom1.coefficient[i]; if (i < polinom2.degree) temp += polinom2.coefficient[i]; buffArray[i] = temp; } return new Polynom(buffArray); }
public Polynom Subtract_TwoPolynom_Test(Polynom polynom1, Polynom polynom2) { Polynom result = polynom1 - polynom2; return result; }
public Polynom Add(Polynom polynom1, Polynom polynom2) { Polynom result = polynom1 + polynom2; return result; }
public double Calculate_Polynom_Test(Polynom polynom1, double x) { double result = polynom1.Calculate(x); return result; }
public Polynom Multiply_TwoPolynom_Test(Polynom polynom1, Polynom polynom2) { Polynom result = polynom1 * polynom2; return result; }
public static Polynom Multiply(Polynom polinom1, Polynom polinom2) { double[] result = new double[polinom1.degree + polinom2.degree - 1]; for (int i = 0; i < polinom1.degree; i++) { for (int j = 0; j < polinom2.degree; j++) { result[i + j] += polinom1[i] * polinom2[j]; } } return new Polynom(result); }