public bool OperatorNotEqualsTest(double[] coefs1, double[] coefs2) { Polynomial p1 = new Polynomial(coefs1); Polynomial p2 = new Polynomial(coefs2); return p1 != p2; }
public string OperatorMinusTest(double[] coefs1, double[] coefs2) { Polynomial p1 = new Polynomial(coefs1); Polynomial p2 = new Polynomial(coefs2); return (p1 - p2).ToString(); }
public void GetValueTest() { double param = 4; var pol = new Polynomial(1, 2, -3); double result = pol.GetValue(param); Assert.AreEqual(result, -39); }
public void PolynomialEqualTest() { var a = new Polynomial(1, 2, 3, 4); var b = new Polynomial(1, 2, 3, 4); Polynomial c = null; Assert.AreEqual(a.Equals(b), true); Assert.AreEqual(a == b, true); Assert.AreEqual(a != b, false); Assert.AreEqual(a == null, false); }
public void PolynomialEqualsTest() { var lsh = new Polynomial(1, 2, 3, 4); var rsh = new Polynomial(1, 2, 3, 4); int a = 4; int b = -3; Polynomial c = rsh; Assert.AreEqual(lsh.Equals(rsh), true); Assert.AreEqual(lsh == rsh, true); Assert.AreEqual(lsh != rsh, false); Assert.AreEqual(c == rsh, true); }
public void EqualsTest() { var a = new Polynomial(1, 2, 3, 4); var b = new Polynomial(1, 2, 3, 4); Polynomial c = null; Assert.AreEqual(a.Equals(a),true); Assert.AreEqual(a.Equals(b), true); Assert.AreEqual(a == b, true); Assert.AreEqual(a == b, b == a); Assert.AreEqual(a != b, false); Assert.AreEqual(a.Equals(b), b.Equals(a)); Assert.AreEqual(a.Equals((object)a), true); Assert.AreEqual(a.Equals(null), false); Assert.AreEqual(a == c, false); Assert.AreEqual(c == null, (object)c==null); a = new Polynomial(1, 2, 0); Assert.AreEqual(a.Degree,1); }
public static Polynomial Substract(Polynomial a, Polynomial b) { return a - b; }
public static Polynomial Multiply(Polynomial a,Polynomial b) { return a * b; }
public string SubtractMethod_SameAsOperatorMinus(double[] coefs) { Polynomial p = new Polynomial(coefs); return p.Subtract(new Polynomial(6, 6, 6)).ToString(); }
public string ToStringTest(double[] c) { Polynomial p = new Polynomial(c); return p.ToString(); }
public Polynomial AddOperatorTest(Polynomial a,Polynomial b) { return a + b; }
public string ToStringTest(Polynomial a) { return a.ToString(); }
private static Polynomial Calculate(Polynomial a, Polynomial b, ArithmeticalOperation methodArithmeticalOperation) { var multipliers = a._multipliers.Length > b._multipliers.Length ? new double[a._multipliers.Length] : new double[b._multipliers.Length]; int i = 0; double m = 0.0; do { if (a._multipliers.Length - 1 < i) { AppendMulsOver(ref multipliers, i, b._multipliers); return new Polynomial(multipliers); } else if (b._multipliers.Length - 1 < i) { AppendMulsOver(ref multipliers, i, a._multipliers); return new Polynomial(multipliers); } m = methodArithmeticalOperation(a._multipliers[i], b._multipliers[i]); multipliers[i] = m; ++i; } while (i <= a._multipliers.Length && i <= b._multipliers.Length); return new Polynomial(multipliers); }
public bool Equals(Polynomial a) { if ((object)a == null) { return false; } if (this.Exponent != a.Exponent) return false; return this._coefficientArray.SequenceEqual(a._coefficientArray); }
public static Polynomial Subtraction(Polynomial a, Polynomial b) { return a - b; }
public void EqualsWithObjectTest() { object c = new object(); Polynomial p = new Polynomial(1); object sameRef = p; Assert.AreEqual(false, p.Equals(c)); Assert.AreEqual(false, p.Equals(null)); Assert.AreEqual(true, p.Equals(sameRef)); }
public bool GetHashCodeEqualityTest(double[] coefs1, double[] coefs2) { Polynomial p1 = new Polynomial(coefs1); Polynomial p2 = new Polynomial(coefs2); return p1.GetHashCode() == p2.GetHashCode(); }
public Polynomial AddTest(Polynomial a, Polynomial b) { return Polynomial.Add(a,b); }
public double IndexatorTest(double[] c, int i) { Polynomial p = new Polynomial(c); return p[i]; }
public Polynomial SubOperatorTest(Polynomial a, Polynomial b) { return a - b; }
public string OperatorMultiplyTest(double[] coefs, double k) { Polynomial p = new Polynomial(coefs); return (p * k).ToString(); }
public Polynomial SubTest(Polynomial a, Polynomial b) { return Polynomial.Substract(a, b); }
public string AddMethod_SameAsOperatorPlus(double[] coefs) { Polynomial p = new Polynomial(coefs); return p.Add(new Polynomial(6, 6, 6)).ToString(); }
public Polynomial MulOperatorTest(Polynomial a, Polynomial b) { return a * b; }
public double GetValueTest(double[] coefs, double value) { Polynomial p = new Polynomial(coefs); return p.GetValue(value); }
public Polynomial MulTest(Polynomial a, Polynomial b) { return Polynomial.Multiply(a, b); }
public bool Equals(Polynomial p) { if ((object)p == null) return false; if (_odds.Length != p._odds.Length) return false; // return _odds.SequenceEqual(p._odds); for (int i = 0; i < _odds.Length; i++) { if (this[i] != p[i]) return false; } return true; }
public string AddItemTest(double[] coefs, double item) { Polynomial p = new Polynomial(coefs); p.AddItem(item); return p.ToString(); }
public static Polynomial Add(Polynomial a,Polynomial b) { return a + b; }
public bool EqualsWithPolynomTest(double[] coefs1, double[] coefs2) { Polynomial p1 = new Polynomial(coefs1); Polynomial p2 = new Polynomial(coefs2); return p1.Equals(p2); }