public Polinom PolinomMultTest(double[] coef1, double[] coef2) { Polinom p1 = new Polinom(coef1); Polinom p2 = new Polinom(coef2); return Polinom.Mult(p1, p2); }
public Polinom PolinomSumTest(double[] coef1, double[] coef2) { Polinom p1 = new Polinom(coef1); Polinom p2 = new Polinom(coef2); return Polinom.Add(p1, p2); }
public Polinom PolinomCreateTest(double[] coef) { Polinom obj = new Polinom(coef); return obj; }
public Polinom PolinomDiffTest(double[] coef1, double[] coef2) { Polinom p1 = new Polinom(coef1); Polinom p2 = new Polinom(coef2); return Polinom.Sub(p1, p2); }
public bool Equals(Polinom p) { if (ReferenceEquals(p, null)) return false; if (ReferenceEquals(p, this)) return true; if (p.degree != degree) return false; //!!!!!!!!!!!! for (int i = 0; i < degree; i++) { if (Math.Abs(coef[i] - p[i]) > eps) return false; } return true; }
public override bool Equals(object obj) { if (ReferenceEquals(obj, null)) return false; if (ReferenceEquals(obj, this)) return true; Polinom p = new Polinom(); if (p.GetType() != obj.GetType()) return false; p = (Polinom)obj; return Equals(p); }
public static Polinom Sub(Polinom lhs, Polinom rhs) { return lhs - rhs; }
public static Polinom Mult(Polinom lhs, Polinom rhs) { if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null)) throw new ArgumentNullException(); Polinom p2 = new Polinom(new double[lhs.degree + rhs.degree + 1]); for (int i = 0; i < lhs.degree; i++) { Polinom p1 = rhs * lhs[i]; for (int k = 0; k < rhs.degree; k++) { p2[i + k] += p1[i]; } } return p2; }
public static Polinom Add(Polinom lhs, Polinom rhs) { return lhs + rhs; }